Skip to content

Commit

Permalink
fix: update Lançamento with allowed Favorecidos
Browse files Browse the repository at this point in the history
- wip: remove obsolete role "admin finan"
  • Loading branch information
yxuo committed Sep 19, 2024
1 parent c6c174b commit 1d7cb16
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 40 deletions.
1 change: 0 additions & 1 deletion src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class AuthService {
RoleEnum.admin,
RoleEnum.aprovador_financeiro,
RoleEnum.lancador_financeiro,
RoleEnum.admin_finan,
]
: [RoleEnum.user];

Expand Down
15 changes: 12 additions & 3 deletions src/cnab/cnab.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export class CnabController {

@Get('clientes-favorecidos')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(RoleEnum.master, RoleEnum.admin, RoleEnum.admin_finan, RoleEnum.lancador_financeiro, RoleEnum.aprovador_financeiro)
@Roles(
RoleEnum.master, //
RoleEnum.admin,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
@ApiBearerAuth()
@ApiQuery({ name: 'nome', description: 'Pesquisa por parte do nome, sem distinção de acento ou maiúsculas.', required: false, type: String })
@ApiQuery({ name: 'nomeNot', description: 'Ignora nomes com parte do nome, sem distinção de acento ou maiúsculas.', required: false, type: String })
Expand All @@ -55,8 +60,12 @@ export class CnabController {
@Get('extratoLancamento')
@HttpCode(HttpStatus.OK)
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(RoleEnum.master, RoleEnum.admin_finan, RoleEnum.lancador_financeiro, RoleEnum.aprovador_financeiro)
@ApiOperation({description: 'Verifica o saldo do '})
@Roles(
RoleEnum.master, //
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
@ApiOperation({ description: 'Verifica o saldo do ' })
@ApiBearerAuth()
@ApiQuery({ name: 'conta', required: true, type: String })
@ApiQuery({ name: 'dt_inicio', required: true, type: String, example: '2024-01-01' })
Expand Down
15 changes: 0 additions & 15 deletions src/database/seeds/role/role-seed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,5 @@ export class RoleSeedService {
}),
);
}

const admin_finan = await this.roleRepository.count({
where: {
id: RoleEnum.admin_finan,
},
});

if (!admin_finan) {
await this.roleRepository.save(
this.roleRepository.create({
id: RoleEnum.admin_finan,
name: 'Admin Finan',
}),
);
}
}
}
12 changes: 2 additions & 10 deletions src/database/seeds/user/user-seed-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ LIMIT 5
fullName: 'Simone Costa',
email: 'simonecosta.smtr@gmail.com',
password: this.generateRandomPassword(),
role: new Role(RoleEnum.admin_finan),
role: new Role(RoleEnum.aprovador_financeiro),
status: new Status(StatusEnum.active),
},
{
fullName: 'Luciana Fernandes',
email: 'lucianafernandes.smtr@gmail.com',
password: this.generateRandomPassword(),
role: new Role(RoleEnum.admin_finan),
role: new Role(RoleEnum.aprovador_financeiro),
status: new Status(StatusEnum.active),
},

Expand Down Expand Up @@ -267,14 +267,6 @@ LIMIT 5
role: { id: RoleEnum.user } as Role,
status: { id: StatusEnum.active } as Status,
},
{
fullName: 'Administrador Financeiro Teste',
email: 'finan.admin@example.com',
password: 'ob>&+H%=<!?J',
permitCode: 'permitCode_admin',
role: { id: RoleEnum.admin_finan } as Role,
status: { id: StatusEnum.active } as Status,
},
{
fullName: 'Lançador Financeiro Teste',
email: 'finan.lancador@example.com',
Expand Down
8 changes: 0 additions & 8 deletions src/lancamento/lancamento.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand Down Expand Up @@ -59,7 +58,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand All @@ -79,7 +77,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand All @@ -104,7 +101,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand All @@ -124,7 +120,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.aprovador_financeiro,
)
@ApiOperation({ description: `Inclui uma autorização do usuário autenticado para o Lançamento.` })
Expand All @@ -145,7 +140,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand All @@ -166,7 +160,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand All @@ -180,7 +173,6 @@ export class LancamentoController {
@UseGuards(AuthGuard('jwt'), RolesGuard)
@Roles(
RoleEnum.master, //
RoleEnum.admin_finan,
RoleEnum.lancador_financeiro,
RoleEnum.aprovador_financeiro,
)
Expand Down
2 changes: 1 addition & 1 deletion src/lancamento/lancamento.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class LancamentoService {
if (!favorecido) {
throw CommonHttpException.message('id_cliente_favorecido: Favorecido não encontrado no sistema');
}
if (!validFavorecidoNames.includes(favorecido.nome)) {
if (!validFavorecidoCpfCnpjs.includes(favorecido.cpfCnpj)) {
throw CommonHttpException.messageArgs('id_cliente_favorecido: Favorecido não permitido para Lançamento.', { validFavorecidos: validFavorecidoNames });
}
if (lancamento.clienteFavorecido.id !== updateDto.id_cliente_favorecido) {
Expand Down
7 changes: 5 additions & 2 deletions src/roles/roles.enum.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export enum RoleEnum {
/** Admin de todas as funcionalidades + manutenção */
'master' = 0,
/** Admin vanzeiros */
/** Admin da func. vanzeiros */
'admin' = 1,
/** Usuário da func. vanzeiros */
'user' = 2,
/** Usuário da func. financeiro */
'lancador_financeiro' = 3,
/** Admin da func. financeiro */
'aprovador_financeiro' = 4,
'admin_finan' = 5,
}

0 comments on commit 1d7cb16

Please sign in to comment.