Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#196-cnab-migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
yxuo committed Mar 7, 2024
2 parents ae335db + 1c3a95d commit 95caf29
Show file tree
Hide file tree
Showing 12 changed files with 338 additions and 13 deletions.
37 changes: 37 additions & 0 deletions src/cnab/dto/arquivo-publicacao.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export class ArquivoPublicacaoDTO {
constructor(dto?: ArquivoPublicacaoDTO) {
if (dto) {
Object.assign(this, dto);
}
}
id_arquivo_publicacao: number;

id_header_arquivo: number;
id_transacao: number;
id_header_lote: number;
dt_geracao_remessa: Date;
hr_geracao_remessa: Date;
dt_geracao_retorno: Date;
hr_geracao_retorno: Date;

lote_servico: string;
nome_pagador: string;
agencia_pagador: string;
dv_agencia_pagador: string;
conta_pagador: string;
dv_conta_pagador: string;

nome_cliente?: string;
cpf_cnpj_cliente?: string;
cod_banco_cliente?: string;
agencia_cliente?: string;
dv_agencia_cliente?: string;
conta_corrente_cliente?: string;
dv_conta_corrente_cliente?: string;

dt_vencimento?: Date;
valor_lancamento?: number;
data_efetivacao?: Date;
valor_real_efetivado?: number;
ocorrencias: string;
}
90 changes: 90 additions & 0 deletions src/cnab/entity/arquivo-publicacao.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { EntityHelper } from "src/utils/entity-helper";
import { Column, DeepPartial, PrimaryGeneratedColumn } from "typeorm";

export class ArquivoPublicacao extends EntityHelper {
constructor(
arquivoPublicacao?: ArquivoPublicacao | DeepPartial<ArquivoPublicacao>,
) {
super();
if (arquivoPublicacao !== undefined) {
Object.assign(this, arquivoPublicacao);
}
}
@PrimaryGeneratedColumn()
id_publicacao:number;

@Column({ type: String, unique: false, nullable: false})
id_header_arquivo: number;

@Column({ type: String, unique: false, nullable: false})
id_transacao: number;

@Column({ type: String, unique: false, nullable: false})
id_header_lote: number;

@Column({ type: Date, unique: false, nullable: false})
dt_geracao_remessa: Date;

@Column({ type: Date, unique: false, nullable: false})
hr_geracao_remessa: Date;

@Column({ type: Date, unique: false, nullable: false})
dt_geracao_retorno: Date;

@Column({ type: Date, unique: false, nullable: false})
hr_geracao_retorno: Date;

@Column({ type: String, unique: false, nullable: false})
lote_servico: string;

@Column({ type: String, unique: false, nullable: false})
nome_pagador: string;

@Column({ type: String, unique: false, nullable: false})
agencia_pagador: string;

@Column({ type: String, unique: false, nullable: false})
dv_agencia_pagador: string;

@Column({ type: String, unique: false, nullable: false})
conta_pagador: string;

@Column({ type: String, unique: false, nullable: false})
dv_conta_pagador: string;

@Column({ type: String, unique: false, nullable: false})
nome_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
cpf_cnpj_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
cod_banco_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
agencia_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
dv_agencia_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
conta_corrente_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
dv_conta_corrente_cliente?: string;

@Column({ type: String, unique: false, nullable: false})
dt_vencimento?: Date;

@Column({ type: String, unique: false, nullable: false})
valor_lancamento?: number;

@Column({ type: String, unique: false, nullable: false})
data_efetivacao?: Date;

@Column({ type: String, unique: false, nullable: false})
valor_real_efetivado?: number;

@Column({ type: String, unique: false, nullable: false})
ocorrencias: string;
}
21 changes: 21 additions & 0 deletions src/cnab/repository/arquivo-publicacao.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Injectable, Logger } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { ArquivoPublicacao } from "../entity/arquivo-publicacao.entity";
import { ArquivoPublicacaoDTO } from "../dto/arquivo-publicacao.dto";

@Injectable()
export class ArquivoPublicacaoRepository {
private logger: Logger = new Logger('ArquivoPublicacaoRepository', {
timestamp: true,
});

constructor(
@InjectRepository(ArquivoPublicacao)
private arquivoPublicacaoRepository: Repository<ArquivoPublicacao>,
) { }

public async save(dto: ArquivoPublicacaoDTO): Promise<ArquivoPublicacao> {
return this.arquivoPublicacaoRepository.save(dto);
}
}
1 change: 1 addition & 0 deletions src/cnab/repository/cliente-favorecido.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CommonHttpException } from 'src/utils/http-exception/common-http-except

@Injectable()
export class ClienteFavorecidoRepository {

private logger: Logger = new Logger('ClienteFavorecidoRepository', {
timestamp: true,
});
Expand Down
6 changes: 4 additions & 2 deletions src/cnab/repository/header-arquivo.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class HeaderArquivoRepository {
});
}

public async findAll(): Promise<HeaderArquivo[]> {
return await this.HeaderArquivoRepository.find();
public async findAll(fields: EntityCondition<HeaderArquivo> | EntityCondition<HeaderArquivo>[]): Promise<HeaderArquivo[]> {
return await this.HeaderArquivoRepository.find({
where: fields
});
}
}
1 change: 0 additions & 1 deletion src/cnab/repository/transacao.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class TransacaoRepository {

public async save(dto: TransacaoDTO): Promise<Transacao> {
return this.transacaoRepository.save(dto);

}

public async findOne(
Expand Down
30 changes: 28 additions & 2 deletions src/cnab/service/cliente-favorecido.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Injectable, Logger } from '@nestjs/common';
import { HttpStatus, Injectable, Logger } from '@nestjs/common';
import { User } from 'src/users/entities/user.entity';
import { UsersService } from 'src/users/users.service';
import { ClienteFavorecido } from '../entity/cliente-favorecido.entity';
import { ClienteFavorecidoRepository } from '../repository/cliente-favorecido.repository';
import { SaveClienteFavorecidoDTO } from '../dto/cliente-favorecido.dto';
import { validateDTO } from 'src/utils/validation-utils';
import { CommonHttpException } from 'src/utils/http-exception/common-http-exception';
import { EntityCondition } from 'src/utils/types/entity-condition.type';
import { Nullable } from 'src/utils/types/nullable.type';

@Injectable()
export class ClienteFavorecidoService {
Expand Down Expand Up @@ -44,6 +47,22 @@ export class ClienteFavorecidoService {
return await this.clienteFavorecidoRepository.findAll({});
}

public async getOneByIdClienteFavorecido(
id_cliente_favorecido: number,
): Promise<ClienteFavorecido> {
const cliente_favorecido =
await this.clienteFavorecidoRepository.getOne({ id_cliente_favorecido: id_cliente_favorecido });
if (!cliente_favorecido) {
throw CommonHttpException.errorDetails(
'cliente_favorecido.conta not found',
{ pagadorConta: id_cliente_favorecido },
HttpStatus.NOT_FOUND,
);
} else {
return cliente_favorecido;
}
}

private async saveFavorecidoFromUser(
user: User,
existingId_facorecido?: number,
Expand All @@ -69,4 +88,11 @@ export class ClienteFavorecidoService {
await validateDTO(SaveClienteFavorecidoDTO, saveObject);
await this.clienteFavorecidoRepository.save(saveObject);
}
}

public async findOne(
fields: EntityCondition<ClienteFavorecido> | EntityCondition<ClienteFavorecido>[],
): Promise<Nullable<ClienteFavorecido>> {
return await this.clienteFavorecidoRepository.getOne(fields);
}

}
8 changes: 7 additions & 1 deletion src/cnab/service/cnab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ export class CnabService {
console.log(a);
return true;
}
}

public async getArquivoRetornoCNAB(){
//await this.headerArquivoService.saveArquivoRetorno();
await this.headerArquivoService.compareRemessaToRetorno();
}

}
Loading

0 comments on commit 95caf29

Please sign in to comment.