Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#196-integracao-views-jae
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfl2007 committed Mar 5, 2024
2 parents a4f242b + 36c9b1d commit 2baef0b
Show file tree
Hide file tree
Showing 54 changed files with 965 additions and 178 deletions.
18 changes: 16 additions & 2 deletions src/banks/banks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Repository } from 'typeorm';
import { Bank } from './entities/bank.entity';
import { Nullable } from 'src/utils/types/nullable.type';
import { EntityCondition } from 'src/utils/types/entity-condition.type';
import { CommonHttpException } from 'src/utils/http-exception/common-http-exception';

@Injectable()
export class BanksService {
Expand All @@ -12,13 +13,26 @@ export class BanksService {
private readonly banksRepository: Repository<Bank>,
) {}

async getAllowedBanks(): Promise<Bank[]> {
public async getAllowedBanks(): Promise<Bank[]> {
return this.banksRepository.find({ where: { isAllowed: true } });
}

findOne(fields: EntityCondition<Bank>): Promise<Nullable<Bank>> {
public findOne(fields: EntityCondition<Bank>): Promise<Nullable<Bank>> {
return this.banksRepository.findOne({
where: fields,
});
}

public async getOne(fields: EntityCondition<Bank>): Promise<Bank> {
const bank = await this.banksRepository.findOne({
where: fields,
});
if (!bank) {
const values = Object.values(fields).join(' or ');
throw CommonHttpException.notFound(
values ? `Bank.${values}` : 'any Bank',
);
}
return bank;
}
}
Empty file.
Empty file.
File renamed without changes.
20 changes: 6 additions & 14 deletions src/cnab/dto/cnab.dto.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { ICnab240_104DetalheA } from '../interfaces/cnab-240/104/cnab-240-104-detalhe-a.interface';
import { ICnab240_104DetalheB } from '../interfaces/cnab-240/104/cnab-240-104-detalhe-b.interface';
import { ICnab240_104HeaderArquivo } from '../interfaces/cnab-240/104/cnab-240-104-header-arquivo.interface';
import { ICnab240_104HeaderLote } from '../interfaces/cnab-240/104/cnab-240-104-header-lote.interface';
import { ICnab240_104TrailerArquivo } from '../interfaces/cnab-240/104/cnab-240-104-trailer-arquivo.interface';
import { ICnab240_104TrailerLote } from '../interfaces/cnab-240/104/cnab-240-104-trailer-lote.interface';
import { ItemTransacao } from '../entity/item-transacao.entity';
import { HeaderArquivoDTO } from './header-arquivo.dto';
import { HeaderLoteDTO } from './header-lote.dto';

export class CnabDto {
headerArquivo: ICnab240_104HeaderArquivo;
headerArquivo = HeaderArquivoDTO;
lotes: {
headerLote: ICnab240_104HeaderLote;
registros: {
detalheA: ICnab240_104DetalheA;
detalheB: ICnab240_104DetalheB;
}[];
trailerLote: ICnab240_104TrailerLote;
headerLote: HeaderLoteDTO;
detalhes: ItemTransacao[];
}[];
trailerArquivo: ICnab240_104TrailerArquivo;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsNotEmpty, ValidateIf } from 'class-validator';

function isCreate(object: SaveDetalheADTO): boolean {
function isCreate(object: DetalheADTO): boolean {
return object.id_detalhe_a === undefined;
}

export class SaveDetalheADTO {
export class DetalheADTO {
id_detalhe_a?: number;

@ValidateIf(isCreate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsNotEmpty, ValidateIf } from 'class-validator';

function isCreate(object: SaveDetalheBDTO): boolean {
function isCreate(object: DetalheBDTO): boolean {
return object.id_detalhe_a === undefined;
}

export class SaveDetalheBDTO {
export class DetalheBDTO {
id_detalhe_b?: number;

@ValidateIf(isCreate)
Expand Down
23 changes: 23 additions & 0 deletions src/cnab/dto/header-arquivo.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class HeaderArquivoDTO {
constructor(dto?: HeaderArquivoDTO) {
if (dto) {
Object.assign(this, dto);
}
}

id_header_arquivo: number;
tipo_arquivo: string;
cod_banco: string;
tipo_inscricao: string;
num_inscricao: string;
cod_convenio: string;
param_transmissao: string;
agencia: string;
dv_agencia: string;
num_conta: string;
dv_conta: string;
nome_empresa: string;
dt_geracao: Date;
hr_geracao: Date;
id_transacao: number;
}
17 changes: 17 additions & 0 deletions src/cnab/dto/header-lote.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export class HeaderLoteDTO {
constructor(dto?: HeaderLoteDTO) {
if (dto) {
Object.assign(this, dto);
}
}

id_header_lote: number;
id_header_arquivo: number;
lote_servico: string;
tipo_inscricao: string;
num_inscricao: string;
cod_convenio_banco: string;
tipo_compromisso: string;
param_transmissao: string;
id_pagador: number;
}
11 changes: 3 additions & 8 deletions src/cnab/dto/item-transacao.dto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

export class ItemTransacaoDTO {
id_item_transacao: number;
dt_transacao: Date;
dt_processamento: Date;
dt_captura: Date;
nome_consorcio: string;
id_tipo_pagamento: number;
tipo_transacao: string;
valor_item_transacao: number;
id_transacao: number;
dt_processamento;
dt_captura;
modo: string;
id_cliente_favorecido:number;
}
4 changes: 4 additions & 0 deletions src/cnab/dto/pagador.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ export class PagadorDTO {
@ValidateIf(isCreate)
@IsNotEmpty()
uf: string;

@ValidateIf(isCreate)
@IsNotEmpty()
cpf_cnpj: string;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IsNotEmpty, ValidateIf } from 'class-validator';

function isCreate(object: SaveTransacaoClienteItemDTO): boolean {
function isCreate(object: TransacaoClienteItemDTO): boolean {
return object.id === undefined;
}

export class SaveTransacaoClienteItemDTO {
export class TransacaoClienteItemDTO {
id?: number;

@ValidateIf(isCreate)
Expand Down
1 change: 1 addition & 0 deletions src/cnab/dto/transacao.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ export class TransacaoDTO {
@ValidateIf(isCreate)
@IsNotEmpty()
id_pagador?: number;

}
35 changes: 19 additions & 16 deletions src/cnab/entity/detalhe-a.entity.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import { DeepPartial, Entity } from 'typeorm';
import { EntityHelper } from './../../utils/entity-helper';
import { EntityHelper } from 'src/utils/entity-helper';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
@Entity('detalhe_a')
export class DetalheA extends EntityHelper {
constructor(detalheA?: DetalheA | DeepPartial<DetalheA>) {
super();
if (detalheA !== undefined) {
Object.assign(this, detalheA);
}
}

@PrimaryGeneratedColumn()
id_detalhe_a: number;
@Column({ type: Number, unique: false, nullable: true })
id_header_lote: number;
@Column({ type: String, unique: false, nullable: true })
lote_servico: string;
@Column({ type: Number, unique: false, nullable: true })
id_cliente_favorecido: number;
@Column({ type: String, unique: false, nullable: true })
tipo_finalidade_conta: string;
@Column({ type: Date, unique: false, nullable: true })
dt_vencimento: Date;
@Column({ type: String, unique: false, nullable: true })
tipo_moeda: string;
qtde_moeda: number;
@Column({ type: String, unique: false, nullable: true })
valor_lancamento: number;
@Column({ type: String, unique: false, nullable: true })
num_doc_lancamento: string;
@Column({ type: String, unique: false, nullable: true })
qtde_parcelas: number;
@Column({ type: String, unique: false, nullable: true })
indicador_bloqueio: string;
@Column({ type: String, unique: false, nullable: true })
indicador_forma_parcelamento: string;
@Column({ type: Date, unique: false, nullable: true })
periodo_vencimento: Date;
@Column({ type: String, unique: false, nullable: true })
num_parcela: number;
@Column({ type: Date, unique: false, nullable: true })
data_efetivacao: Date;
@Column({ type: Number, unique: false, nullable: true })
valor_real_efetivado: number;

public getLogInfo(): string {
const response = `#${this.id_detalhe_a}`;
return response;
}
}
17 changes: 16 additions & 1 deletion src/cnab/entity/header-arquivo.entity.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
import { EntityHelper } from 'src/utils/entity-helper';
import { Entity } from 'typeorm';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class HeaderArquivo extends EntityHelper {
@PrimaryGeneratedColumn()
id_header_arquivo: number;
@Column({ type: Number, unique: false, nullable: true })
tipo_arquivo: string;
@Column({ type: String, unique: false, nullable: true })
cod_banco: string;
@Column({ type: String, unique: false, nullable: true })
tipo_inscricao: string;
@Column({ type: String, unique: false, nullable: true })
num_inscricao: string;
@Column({ type: String, unique: false, nullable: true })
cod_convenio: string;
@Column({ type: String, unique: false, nullable: true })
param_transmissao: string;
@Column({ type: String, unique: false, nullable: true })
agencia: string;
@Column({ type: String, unique: false, nullable: true })
dv_agencia: string;
@Column({ type: String, unique: false, nullable: true })
num_conta: string;
@Column({ type: String, unique: false, nullable: true })
dv_conta: string;
@Column({ type: String, unique: false, nullable: true })
nome_empresa: string;
@Column({ type: String, unique: false, nullable: true })
dt_geracao: Date;
@Column({ type: String, unique: false, nullable: true })
hr_geracao: Date;
@Column({ type: Number, unique: false, nullable: true })
id_transacao: number;
}
14 changes: 10 additions & 4 deletions src/cnab/entity/header-lote.entity.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { EntityHelper } from 'src/utils/entity-helper';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class HeaderLote extends EntityHelper {
@PrimaryGeneratedColumn()
id_header_lote: number;
@Column({ type: Number, unique: false, nullable: true })
id_header_arquivo: number;
@Column({ type: String, unique: false, nullable: true })
lote_servico: string;
@Column({ type: String, unique: false, nullable: true })
tipo_inscricao: string;
@Column({ type: String, unique: false, nullable: true })
num_inscricao: string;
@Column({ type: String, unique: false, nullable: true })
cod_convenio_banco: string;
@Column({ type: String, unique: false, nullable: true })
tipo_compromisso: string;
@Column({ type: String, unique: false, nullable: true })
param_transmissao: string;
@Column({ type: Number, unique: false, nullable: true })
id_pagadora: number;
}

function Entity(): (target: typeof HeaderLote) => void | typeof HeaderLote {
throw new Error('Function not implemented.');
}
13 changes: 3 additions & 10 deletions src/cnab/entity/item-transacao.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
export class ItemTransacao extends EntityHelper {
@PrimaryGeneratedColumn()
id_item_transacao: number;

@Column({ type: String, unique: false, nullable: true })
dt_transacao: string;
@Column({ type: String, unique: false, nullable: true })
dt_processamento: string;
@Column({ type: Date, unique: false, nullable: true })
dt_captura: Date;
@Column({ type: String, unique: false, nullable: true })
nome_consorcio: string;
@Column({ type: Number, unique: false, nullable: true })
id_tipo_pagamento: number;
@Column({ type: String, unique: false, nullable: true })
tipo_transacao: string;
@Column({ type: Number, unique: false, nullable: true })
valor_item_transacao: number;
@Column({ type: String, unique: false, nullable: true })
id_transacao: number;
modo: string;
@Column({ type: String, unique: false, nullable: true })
id_cliente_transacao: number;
id_cliente_favorecido: number;
}
3 changes: 3 additions & 0 deletions src/cnab/entity/pagador.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class Pagador extends EntityHelper {
@Column({ type: String, unique: false, nullable: true, length: 2 })
uf: string;

@Column({ type: String, unique: false, nullable: true, length: 2 })
cpf_cnpj: string;

public getLogInfo(): string {
const response =
`#${this.id_pagador}` + ` '${this.nome_empresa.substring(0, 15)}...'`;
Expand Down
30 changes: 0 additions & 30 deletions src/cnab/entity/transacao-cliente-item.entity.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/cnab/entity/transacao.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export class Transacao extends EntityHelper {
@PrimaryGeneratedColumn()
id_transacao: number;

@Column({ type: String, unique: false, nullable: true })
dt_ordem: string;
@Column({ type: Date, unique: false, nullable: true })
dt_ordem: Date;

@Column({ type: String, unique: false, nullable: true })
dt_pagamento: string;
@Column({ type: Date, unique: false, nullable: true })
dt_pagamento: Date;

@Column({ type: String, unique: false, nullable: true, length: 200 })
nome_consorcio: string;
Expand Down
4 changes: 4 additions & 0 deletions src/cnab/enums/104/cnab-104-ambiente-cliente.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum Cnab104AmbienteCliente {
Teste = 'T',
Producao = 'P',
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum Cnab104IndicadorParcelamento {
export enum Cnab104FormaParcelamento {
DataFixa = '1',
Periodico = '2',
DiaUtil = '3',
Expand Down
Loading

0 comments on commit 2baef0b

Please sign in to comment.