-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#187 cnab
- Loading branch information
Showing
77 changed files
with
3,706 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CnabFile } from './types/cnab-file.type'; | ||
import { getCnabRegistros, stringifyCnabRegistro } from './utils/cnab-utils'; | ||
import { CNAB_EOL } from './cnab-consts'; | ||
|
||
@Injectable() | ||
export class CnabRemessaService { | ||
/** | ||
* Generate CNAB Remessa text content from CnabFile | ||
*/ | ||
generateRemessaCnab(cnab: CnabFile): string { | ||
const plainCnab = getCnabRegistros(cnab); | ||
const cnabTextList: string[] = []; | ||
for (const registro of plainCnab) { | ||
cnabTextList.push(stringifyCnabRegistro(registro)); | ||
} | ||
return cnabTextList.join(CNAB_EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const CNAB_SUPPORTED_FORMATS = [240]; | ||
export const CNAB_EOL = '\r\n'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { CnabService } from './cnab.service'; | ||
|
||
@Module({ | ||
providers: [CnabService], | ||
}) | ||
export class CnabModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { CnabService } from './cnab.service'; | ||
|
||
describe('CnabService', () => { | ||
let service: CnabService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [CnabService], | ||
}).compile(); | ||
|
||
service = module.get<CnabService>(CnabService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class CnabService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum Cnab104CamaraCompensacao { | ||
Ted = '018', | ||
DocEOp = '700', | ||
CreditoContaEGuiaDepositoJudiciario = '000', | ||
BoletoEIspb = '888', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum Cnab104CodigoSegmento { | ||
A = 'A', | ||
B = 'B', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export enum Cnab104FinalidadeDoc { | ||
CreditoConta = '01', | ||
PagamentoAluguelCondominio = '02', | ||
PagamentoDuplicataTitulos = '03', | ||
PagamentoDividendos = '04', | ||
PagamentoMensalidadeEscolar = '05', | ||
PagamentoSalarios = '06', | ||
PagamentoFornecedoresHonorarios = '07', | ||
OperacoesCambioFundosBolsaValores = '08', | ||
RepasseArrecadacaoPagamentoTributos = '09', | ||
TransferenciaInternacionalReal = '10', | ||
DocPoupanca = '11', | ||
Outros = '00', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum Cnab104FinalidadeTed { | ||
SemConta = '0', | ||
ContaCorrente = '1', | ||
Poupanca = '2', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export enum Cnab104FormaLancamento { | ||
CreditoContaCorrente = '01', | ||
ChequePagamento = '02', | ||
DOC = '03', | ||
CreditoContaPoupanca = '05', | ||
OPDisposicao = '10', | ||
PagamentoContasTributos = '11', | ||
PagamentoDARFSemBarras = '16', | ||
PagamentoGPSSemBarras = '17', | ||
LiquidacaoTitulosProprioBanco = '30', | ||
PagamentoTitulosOutrosBancos = '31', | ||
TED = '41', | ||
DebitoContaCorrenteRecebimento = '50', | ||
PagamentoGuiaDepositoJudicial = '71', | ||
PagamentoConcessionarias = '99', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum Cnab104IndicadorParcelamento { | ||
DataFixa = '1', | ||
Periodico = '2', | ||
DiaUtil = '3', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum Cnab104TipoCompromisso { | ||
PagamentoFornecedores = '01', | ||
PagamentoSalarios = '02', | ||
Autopagamento = '03', | ||
SalarioAmpliacaoBase = '06', | ||
DebitoContaDebitoAutomatico = '11', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum Cnab104TipoMovimento { | ||
Inclusao = '0', | ||
Exclusao = '9', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export enum Cnab104TipoServico { | ||
Optantes = '00', | ||
DebitosRecebimento = '05', | ||
PagamentoDividendos = '10', | ||
PagamentoFornecedor = '20', | ||
PagamentoTributos = '22', | ||
PagamentoSalarios = '30', | ||
PagamentoSinistrosSegurados = '50', | ||
PagamentoDespesasViajanteTransito = '60', | ||
PagamentoAutorizado = '70', | ||
PagamentoCredenciados = '75', | ||
PagamentoRepresentantesVendedoresAutorizados = '80', | ||
PagamentoBeneficios = '90', | ||
PagamentoDiversos = '98', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum CnabAllCodigoRegistro { | ||
HeaderArquivo = '0', | ||
HeaderLote = '1', | ||
|
||
/** Se aplica a todos os segmentos de detalhe. */ | ||
DetalheSegmento = '3', | ||
|
||
TrailerLote = '5', | ||
TrailerArquivo = '9', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum CnabFieldType { | ||
Date = 'date', | ||
Text = 'text', | ||
/** Integer or decimal number */ | ||
Number = 'number', | ||
} |
47 changes: 47 additions & 0 deletions
47
src/cnab/interfaces/cnab-240/104/cnab-240-104-detalhe-a.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { CnabAllCodigoRegistro } from 'src/cnab/enums/all/cnab-all-codigo-registro.enum'; | ||
import { | ||
CnabField, | ||
CnabFieldAs, | ||
CnabFields, | ||
} from '../../../types/cnab-field.type'; | ||
import { Cnab104CodigoSegmento } from 'src/cnab/enums/104/cnab-104-codigo-segmento.enum'; | ||
|
||
export interface ICnab240_104DetalheA extends CnabFields { | ||
codigoBanco: CnabField; | ||
loteServico: CnabField; | ||
codigoRegistro: CnabFieldAs<CnabAllCodigoRegistro>; | ||
nsr: CnabField; | ||
codigoSegmento: CnabFieldAs<Cnab104CodigoSegmento>; | ||
tipoMovimento: CnabField; | ||
codigoInstrucaoMovimento: CnabField; | ||
camaraCompensacao: CnabField; | ||
codigoBancoDestino: CnabField; | ||
codigoAgenciaDestino: CnabField; | ||
dvAgenciaDestino: CnabField; | ||
contaCorrenteDestino: CnabField; | ||
dvContaDestino: CnabField; | ||
dvAgenciaContaDestino: CnabField; | ||
nomeTerceiro: CnabField; | ||
numeroDocumento: CnabField; | ||
filler: CnabField; | ||
tipoContaFinalidadeTed: CnabField; | ||
dataVencimento: CnabField; | ||
tipoMoeda: CnabField; | ||
quantidadeMoeda: CnabField; | ||
valorLancamento: CnabField; | ||
numeroDocumentoBanco: CnabField; | ||
filler2: CnabField; | ||
quantidadeParcelas: CnabField; | ||
indicadorBloqueio: CnabField; | ||
indicadorFormaParcelamento: CnabField; | ||
periodoDiaVencimento: CnabField; | ||
numeroParcela: CnabField; | ||
dataEfetivacao: CnabField; | ||
valorRealEfetivado: CnabField; | ||
informacao2: CnabField; | ||
finalidadeDOC: CnabField; | ||
usoExclusivoFebraban: CnabField; | ||
avisoAoFavorecido: CnabField; | ||
/** Status do retorno CNAB */ | ||
ocorrencias: CnabField; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/cnab/interfaces/cnab-240/104/cnab-240-104-detalhe-b.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { CnabAllCodigoRegistro as CnabAllCodigoRegistro } from 'src/cnab/enums/all/cnab-all-codigo-registro.enum'; | ||
import { | ||
CnabField, | ||
CnabFieldAs, | ||
CnabFields, | ||
} from '../../../types/cnab-field.type'; | ||
import { Cnab104CodigoSegmento } from 'src/cnab/enums/104/cnab-104-codigo-segmento.enum'; | ||
|
||
export interface ICnab240_104DetalheB extends CnabFields { | ||
codigoBanco: CnabField; | ||
loteServico: CnabField; | ||
codigoRegistro: CnabFieldAs<CnabAllCodigoRegistro>; | ||
nsr: CnabField; | ||
codigoSegmento: CnabFieldAs<Cnab104CodigoSegmento>; | ||
usoExclusivoFebraban: CnabField; | ||
tipoInscricao: CnabField; | ||
numeroInscricao: CnabField; | ||
logradouro: CnabField; | ||
numeroLocal: CnabField; | ||
complemento: CnabField; | ||
bairro: CnabField; | ||
cidade: CnabField; | ||
cep: CnabField; | ||
complementoCep: CnabField; | ||
siglaEstado: CnabField; | ||
dataVencimento: CnabField; | ||
valorDocumento: CnabField; | ||
valorAbatimento: CnabField; | ||
valorDesconto: CnabField; | ||
valorMora: CnabField; | ||
valorMulta: CnabField; | ||
codigoDocumentoFavorecido: CnabField; | ||
usoExclusivoFebraban2: CnabField; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/cnab/interfaces/cnab-240/104/cnab-240-104-file.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ICnab240_104HeaderArquivo } from './cnab-240-104-header-arquivo.interface'; | ||
import { ICnab240_104Lote } from './cnab-240-104-lote.interface'; | ||
import { ICnab240_104TrailerArquivo } from './cnab-240-104-trailer-arquivo.interface'; | ||
|
||
export interface ICnab240_104File { | ||
headerArquivo: ICnab240_104HeaderArquivo; | ||
lotes: ICnab240_104Lote[]; | ||
trailerArquivo: ICnab240_104TrailerArquivo; | ||
} |
46 changes: 46 additions & 0 deletions
46
src/cnab/interfaces/cnab-240/104/cnab-240-104-header-arquivo.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { CnabAllCodigoRegistro } from 'src/cnab/enums/all/cnab-all-codigo-registro.enum'; | ||
import { | ||
CnabField, | ||
CnabFieldAs, | ||
CnabFields, | ||
} from '../../../types/cnab-field.type'; | ||
|
||
export interface ICnab240_104HeaderArquivo extends CnabFields { | ||
codigoBanco: CnabField; | ||
loteServico: CnabField; | ||
codigoRegistro: CnabFieldAs<CnabAllCodigoRegistro>; | ||
filler: CnabField; | ||
tipoInscricao: CnabField; | ||
numeroInscricao: CnabField; | ||
codigoConvenioBanco: CnabField; | ||
parametroTransmissao: CnabField; | ||
ambienteCliente: CnabField; | ||
ambienteCaixa: CnabField; | ||
origemAplicativo: CnabField; | ||
numeroVersao: CnabField; | ||
filler2: CnabField; | ||
agenciaContaCorrente: CnabField; | ||
numeroConta: CnabField; | ||
dvAgencia: CnabField; | ||
dvConta: CnabField; | ||
dvAgenciaConta: CnabField; | ||
nomeEmpresa: CnabField; | ||
nomeBanco: CnabField; | ||
filler3: CnabField; | ||
tipoArquivo: CnabField; | ||
dataGeracaoArquivo: CnabField; | ||
horaGeracaoArquivo: CnabField; | ||
|
||
/** Número sequencial de arquivo, id único do arquivo CNAB. */ | ||
nsa: CnabField; | ||
|
||
versaoLeiauteArquivo: CnabField; | ||
densidadeGravacao: CnabField; | ||
reservadoBanco: CnabField; | ||
reservadoEmpresa: CnabField; | ||
usoExclusivoFebraban: CnabField; | ||
identidadeCobranca: CnabField; | ||
usoExclusivoVan: CnabField; | ||
tipoServico: CnabField; | ||
ocorrenciaCobrancaSemPapel: CnabField; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/cnab/interfaces/cnab-240/104/cnab-240-104-header-lote.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CnabAllCodigoRegistro } from 'src/cnab/enums/all/cnab-all-codigo-registro.enum'; | ||
import { | ||
CnabField, | ||
CnabFieldAs, | ||
CnabFields, | ||
} from '../../../types/cnab-field.type'; | ||
|
||
export interface ICnab240_104HeaderLote extends CnabFields { | ||
codigoBanco: CnabField; | ||
loteServico: CnabField; | ||
codigoRegistro: CnabFieldAs<CnabAllCodigoRegistro>; | ||
tipoOperacao: CnabField; | ||
tipoServico: CnabField; | ||
formaLancamento: CnabField; | ||
versaoLeiauteLote: CnabField; | ||
filler: CnabField; | ||
tipoInscricao: CnabField; | ||
numeroInscricao: CnabField; | ||
codigoConvenioBanco: CnabField; | ||
tipoCompromisso: CnabField; | ||
codigoCompromisso: CnabField; | ||
parametroTransmissao: CnabField; | ||
filler2: CnabField; | ||
agenciaContaCorrente: CnabField; | ||
dvAgencia: CnabField; | ||
numeroConta: CnabField; | ||
dvConta: CnabField; | ||
dvAgenciaConta: CnabField; | ||
nomeEmpresa: CnabField; | ||
mensagemAviso: CnabField; | ||
logradouro: CnabField; | ||
numeroLocal: CnabField; | ||
/** @example "Apto 503" */ | ||
complemento: CnabField; | ||
cidade: CnabField; | ||
/** @example "12345" */ | ||
cep: CnabField; | ||
/** @example "678" */ | ||
complementoCep: CnabField; | ||
/** @example "RJ" */ | ||
siglaEstado: CnabField; | ||
usoExclusivoFebraban: CnabField; | ||
ocorrencias: CnabField; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/cnab/interfaces/cnab-240/104/cnab-240-104-lote.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ICnab240_104HeaderLote } from './cnab-240-104-header-lote.interface'; | ||
import { ICnab240_104Registro } from './cnab-240-104-registro.interface'; | ||
import { ICnab240_104TrailerLote } from './cnab-240-104-trailer-lote.interface'; | ||
|
||
export interface ICnab240_104Lote { | ||
headerLote: ICnab240_104HeaderLote; | ||
registros: ICnab240_104Registro[]; | ||
trailerLote: ICnab240_104TrailerLote; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/cnab/interfaces/cnab-240/104/cnab-240-104-registro-a-b.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ICnab240_104DetalheA } from './cnab-240-104-detalhe-a.interface'; | ||
import { ICnab240_104DetalheB } from './cnab-240-104-detalhe-b.interface'; | ||
|
||
export interface ICnab240_104RegistroAB { | ||
detalheA: ICnab240_104DetalheA; | ||
detalheB: ICnab240_104DetalheB; | ||
} |
7 changes: 7 additions & 0 deletions
7
src/cnab/interfaces/cnab-240/104/cnab-240-104-registro.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ICnab240_104DetalheA } from './cnab-240-104-detalhe-a.interface'; | ||
import { ICnab240_104DetalheB } from './cnab-240-104-detalhe-b.interface'; | ||
|
||
export interface ICnab240_104Registro { | ||
detalheA?: ICnab240_104DetalheA; | ||
detalheB?: ICnab240_104DetalheB; | ||
} |
Oops, something went wrong.