Skip to content

Commit

Permalink
feat: minimal working
Browse files Browse the repository at this point in the history
  • Loading branch information
yxuo committed Mar 7, 2024
1 parent aff489b commit 615fce3
Show file tree
Hide file tree
Showing 27 changed files with 548 additions and 319 deletions.
12 changes: 2 additions & 10 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ import { BigqueryModule } from './bigquery/bigquery.module';
import { TestModule } from './test/test.module';
import { CnabModule } from './cnab/cnab.module';
import { SftpModule } from './sftp/sftp.module';
import sftpConfig from './config/sftp.config';

@Module({
imports: [
SftpModule.forRoot(
{
host: '',
port: 0,
username: '',
password: ''
},
false,
),
ConfigModule.forRoot({
isGlobal: true,
load: [
Expand All @@ -65,6 +57,7 @@ import { SftpModule } from './sftp/sftp.module';
googleConfig,
twitterConfig,
appleConfig,
sftpConfig,
],
envFilePath: ['.env'],
}),
Expand Down Expand Up @@ -119,7 +112,6 @@ import { SftpModule } from './sftp/sftp.module';
TestModule,
CnabModule,
SftpModule,
// SftpModule,
],
})
export class AppModule {}
19 changes: 15 additions & 4 deletions src/bigquery/bigquery.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { Module } from '@nestjs/common';
import { BigqueryService } from './bigquery.service';
import { ConfigModule } from '@nestjs/config';
import { BigqueryOrdemPagamentoService } from './services/bigquery-ordem-pagamento.service';
import { BigqueryOrdemPagamentoRepository } from './repositories/bigquery-ordem-pagamento.repository';
import { SettingsModule } from 'src/settings/settings.module';

@Module({
imports: [ConfigModule],
providers: [BigqueryService],
exports: [BigqueryService],
imports: [ConfigModule, SettingsModule],
providers: [
BigqueryService,
BigqueryOrdemPagamentoService,
BigqueryOrdemPagamentoRepository,
],
exports: [
BigqueryService,
BigqueryOrdemPagamentoService,
BigqueryOrdemPagamentoRepository,
],
})
export class BigqueryModule {}
export class BigqueryModule { }
92 changes: 91 additions & 1 deletion src/cnab/cnab.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,97 @@
import { Module } from '@nestjs/common';
import { CnabService } from './service/cnab.service';
import { HeaderArquivoService } from './service/header-arquivo.service';
import { HeaderLoteRepository } from './repository/header-lote.repository';
import { HeaderLoteService } from './service/header-lote.service';
import { DetalheAService } from './service/detalhe-a.service';
import { DetalheARepository } from './repository/detalhe-a.repository';
import { DetalheBService } from './service/detalhe-b.service';
import { DetalheBRepository } from './repository/detalhe-b.repository';
import { ClienteFavorecidoService } from './service/cliente-favorecido.service';
import { ClienteFavorecidoRepository } from './repository/cliente-favorecido.repository';
import { PagadorService } from './service/pagador.service';
import { PagadorRepository } from './repository/pagador.repository';
import { ArquivoPublicacaoRepository } from './repository/arquivo-publicacao.repository';
import { TransacaoService } from './service/transacao.service';
import { TransacaoRepository } from './repository/transacao.repository';
import { ItemTransacaoService } from './service/item-transacao.service';
import { ItemTransacaoRepository } from './repository/item-transacao.repository';
import { SftpModule } from 'src/sftp/sftp.module';
import { HeaderArquivoRepository } from './repository/header-arquivo.repository';
import { Cnab104Service } from './service/cnab-104.service';
import { BanksModule } from 'src/banks/banks.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { HeaderArquivo } from './entity/header-arquivo.entity';
import { HeaderLote } from './entity/header-lote.entity';
import { DetalheA } from './entity/detalhe-a.entity';
import { DetalheB } from './entity/detalhe-b.entiy';
import { ClienteFavorecido } from './entity/cliente-favorecido.entity';
import { ArquivoPublicacao } from './entity/arquivo-publicacao.entity';
import { Transacao } from './entity/transacao.entity';
import { ItemTransacao } from './entity/item-transacao.entity';
import { Pagador } from './entity/pagador.entity';
import { UsersModule } from 'src/users/users.module';
import { BigqueryModule } from 'src/bigquery/bigquery.module';

@Module({
providers: [CnabService],
imports: [
UsersModule,
SftpModule,
BanksModule,
BigqueryModule,
TypeOrmModule.forFeature([
HeaderArquivo,
HeaderLote,
DetalheA,
DetalheB,
ClienteFavorecido,
ArquivoPublicacao,
Transacao,
ItemTransacao,
Pagador,
])
],
providers: [
CnabService,
Cnab104Service,
HeaderArquivoService,
HeaderArquivoRepository,
HeaderLoteRepository,
HeaderLoteService,
DetalheAService,
DetalheARepository,
DetalheBService,
DetalheBRepository,
ClienteFavorecidoService,
ClienteFavorecidoRepository,
PagadorService,
PagadorRepository,
ArquivoPublicacaoRepository,
TransacaoService,
TransacaoRepository,
ItemTransacaoService,
ItemTransacaoRepository,
],
exports: [
CnabService,
Cnab104Service,
HeaderArquivoService,
HeaderArquivoRepository,
HeaderLoteRepository,
HeaderLoteService,
DetalheAService,
DetalheARepository,
DetalheBService,
DetalheBRepository,
ClienteFavorecidoService,
ClienteFavorecidoRepository,
PagadorService,
PagadorRepository,
ArquivoPublicacaoRepository,
TransacaoService,
TransacaoRepository,
ItemTransacaoService,
ItemTransacaoRepository,
]
})
export class CnabModule { }
6 changes: 4 additions & 2 deletions src/cnab/const/cnab-104.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ export const Cnab104Const = {
*
* @example '18122000'
*/
dateOutput: 'ddMMyyyy',
cnabDateOutput: 'ddMMyyyy',

/**
* HHMMSS - hour is 0-23
*
* @example '235911'
*/
hourOutput: 'HHmmss',
cnabHourOutput: 'HHmmss',

dateObjOutput: 'yyyy MM dd',
}
111 changes: 76 additions & 35 deletions src/cnab/dto/arquivo-publicacao.dto.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,78 @@
import { IsNotEmpty, ValidateIf } from "class-validator";

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

export class ArquivoPublicacaoDTO {
constructor(dto?: ArquivoPublicacaoDTO) {
if (dto) {
Object.assign(this, dto);
}
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;
}
}
id: number;

idHeaderArquivo: number;
idTransacao: number;
idHeaderLote: number;
dataGeracaoRemessa: Date;
horaGeracaoRemessa: Date;
dataGeracaoRetorno: Date;
horaGeracaoRetorno: Date;


loteServico: string;
nomePagador: string;
agenciaPagador: string;
dvAgenciaPagador: string;
contaPagador: string;
dvContaPagador: string;


@ValidateIf(isCreate)
@IsNotEmpty()
nomeCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
cpfCnpjCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
codBancoCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
agenciaCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
dvAgenciaCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
contaCorrenteCliente?: string;

@ValidateIf(isCreate)
@IsNotEmpty()
dvContaCorrenteCliente?: string;


@ValidateIf(isCreate)
@IsNotEmpty()
dataVencimento?: Date;

@ValidateIf(isCreate)
@IsNotEmpty()
valorLancamento?: number;

@ValidateIf(isCreate)
@IsNotEmpty()
dataEfetivacao?: Date;

@ValidateIf(isCreate)
@IsNotEmpty()
valorRealEfetivado?: number;

ocorrencias: string;
}
30 changes: 15 additions & 15 deletions src/cnab/dto/detalhe-a.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,69 @@ export class DetalheADTO {

@ValidateIf(isCreate)
@IsNotEmpty()
loteServico?: string;
loteServico?: string | null;

@ValidateIf(isCreate)
@IsNotEmpty()
clienteFavorecido?: DeepPartial<ClienteFavorecido>;

@ValidateIf(isCreate)
@IsNotEmpty()
tipoFinalidadeConta?: string;
tipoFinalidadeConta?: string | null;

@ValidateIf(isCreate)
@IsNotEmpty()
dataVencimento?: Date;
dataVencimento?: Date | null;

@ValidateIf(isCreate)
@IsNotEmpty()
tipoMoeda?: string;
tipoMoeda?: string | null;

@ValidateIf(isCreate)
@IsNotEmpty()
quantidadeMoeda?: number;
quantidadeMoeda?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
valorLancamento?: number;
valorLancamento?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
numeroDocumentoLancamento?: number;
numeroDocumentoLancamento?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
quantidadeParcelas?: number;
quantidadeParcelas?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
indicadorBloqueio?: string;
indicadorBloqueio?: string | null;

@ValidateIf(isCreate)
@IsNotEmpty()
indicadorFormaParcelamento?: string;
indicadorFormaParcelamento?: string | null;

@ValidateIf(isCreate)
@IsNotEmpty()
periodoVencimento?: Date;
periodoVencimento?: Date | null;

@ValidateIf(isCreate)
@IsNotEmpty()
numeroParcela?: number;
numeroParcela?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
dataEfetivacao?: Date;
dataEfetivacao?: Date | null;

@ValidateIf(isCreate)
@IsNotEmpty()
valorRealEfetivado?: number;
valorRealEfetivado?: number | null;

@ValidateIf(isCreate)
@IsNotEmpty()
nsr?: number;

@ValidateIf(isCreate)
@IsNotEmpty()
ocorrencias: string;
ocorrencias: string | null;
}
Loading

0 comments on commit 615fce3

Please sign in to comment.