@plasoft/boletos 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.mts CHANGED
@@ -51,10 +51,10 @@ interface IDadosPDF$4 {
51
51
  agenciaDigito: string;
52
52
  conta: string;
53
53
  contaDigito: string;
54
- juros?: number;
55
- multa?: number;
56
- desconto?: number;
57
- protesto?: number;
54
+ juros: number;
55
+ multa: number;
56
+ desconto: number;
57
+ protesto: number;
58
58
  };
59
59
  endereco: {
60
60
  logradouro: string;
@@ -91,7 +91,7 @@ interface IDadosPDF$4 {
91
91
  instrucao2?: string;
92
92
  instrucao3?: string;
93
93
  instrucao4?: string;
94
- observacoes?: string;
94
+ observacoes?: string[];
95
95
  nfs: string;
96
96
  };
97
97
  }
@@ -367,10 +367,10 @@ interface IDadosPDF$2 {
367
367
  agencia: string;
368
368
  numero: string;
369
369
  posto: string;
370
- juros?: number;
371
- multa?: number;
372
- desconto?: number;
373
- protesto?: number;
370
+ juros: number;
371
+ multa: number;
372
+ desconto: number;
373
+ protesto: number;
374
374
  };
375
375
  endereco: {
376
376
  logradouro: string;
@@ -407,6 +407,7 @@ interface IDadosPDF$2 {
407
407
  instrucao2?: string;
408
408
  instrucao3?: string;
409
409
  instrucao4?: string;
410
+ observacoes?: string[];
410
411
  nfs: string;
411
412
  };
412
413
  }
@@ -640,15 +641,16 @@ interface IDadosPDF {
640
641
  cnpj: string;
641
642
  dadosBancario: {
642
643
  carteira: string;
644
+ variacao_carteira: string;
643
645
  convenio: string;
644
646
  agencia: string;
645
647
  agenciaDigito: string;
646
648
  conta: string;
647
649
  contaDigito: string;
648
- juros?: number;
649
- multa?: number;
650
- desconto?: number;
651
- protesto?: number;
650
+ juros: number;
651
+ multa: number;
652
+ desconto: number;
653
+ protesto: number;
652
654
  };
653
655
  endereco: {
654
656
  logradouro: string;
@@ -685,7 +687,8 @@ interface IDadosPDF {
685
687
  instrucao2?: string;
686
688
  instrucao3?: string;
687
689
  instrucao4?: string;
688
- observacoes?: string;
690
+ observacoes?: string[];
691
+ nfs: string;
689
692
  };
690
693
  }
691
694
  interface IGerarRemessaBancoBrasil {
@@ -709,6 +712,7 @@ interface IDadosRemessa {
709
712
  };
710
713
  dadosBancario: {
711
714
  carteira: string;
715
+ variacao_carteira: string;
712
716
  convenio: string;
713
717
  agencia: string;
714
718
  agenciaDigito: string;
@@ -721,6 +725,8 @@ interface IDadosRemessa {
721
725
  diasProtesto: number;
722
726
  };
723
727
  boletos: {
728
+ tipoDocumento: 'NFE' | 'FIN' | 'FAT';
729
+ id_boleto: number;
724
730
  identificacaoTitulo: string;
725
731
  vencimento: string | Date;
726
732
  valor: number | string;
package/build/index.d.ts CHANGED
@@ -51,10 +51,10 @@ interface IDadosPDF$4 {
51
51
  agenciaDigito: string;
52
52
  conta: string;
53
53
  contaDigito: string;
54
- juros?: number;
55
- multa?: number;
56
- desconto?: number;
57
- protesto?: number;
54
+ juros: number;
55
+ multa: number;
56
+ desconto: number;
57
+ protesto: number;
58
58
  };
59
59
  endereco: {
60
60
  logradouro: string;
@@ -91,7 +91,7 @@ interface IDadosPDF$4 {
91
91
  instrucao2?: string;
92
92
  instrucao3?: string;
93
93
  instrucao4?: string;
94
- observacoes?: string;
94
+ observacoes?: string[];
95
95
  nfs: string;
96
96
  };
97
97
  }
@@ -367,10 +367,10 @@ interface IDadosPDF$2 {
367
367
  agencia: string;
368
368
  numero: string;
369
369
  posto: string;
370
- juros?: number;
371
- multa?: number;
372
- desconto?: number;
373
- protesto?: number;
370
+ juros: number;
371
+ multa: number;
372
+ desconto: number;
373
+ protesto: number;
374
374
  };
375
375
  endereco: {
376
376
  logradouro: string;
@@ -407,6 +407,7 @@ interface IDadosPDF$2 {
407
407
  instrucao2?: string;
408
408
  instrucao3?: string;
409
409
  instrucao4?: string;
410
+ observacoes?: string[];
410
411
  nfs: string;
411
412
  };
412
413
  }
@@ -640,15 +641,16 @@ interface IDadosPDF {
640
641
  cnpj: string;
641
642
  dadosBancario: {
642
643
  carteira: string;
644
+ variacao_carteira: string;
643
645
  convenio: string;
644
646
  agencia: string;
645
647
  agenciaDigito: string;
646
648
  conta: string;
647
649
  contaDigito: string;
648
- juros?: number;
649
- multa?: number;
650
- desconto?: number;
651
- protesto?: number;
650
+ juros: number;
651
+ multa: number;
652
+ desconto: number;
653
+ protesto: number;
652
654
  };
653
655
  endereco: {
654
656
  logradouro: string;
@@ -685,7 +687,8 @@ interface IDadosPDF {
685
687
  instrucao2?: string;
686
688
  instrucao3?: string;
687
689
  instrucao4?: string;
688
- observacoes?: string;
690
+ observacoes?: string[];
691
+ nfs: string;
689
692
  };
690
693
  }
691
694
  interface IGerarRemessaBancoBrasil {
@@ -709,6 +712,7 @@ interface IDadosRemessa {
709
712
  };
710
713
  dadosBancario: {
711
714
  carteira: string;
715
+ variacao_carteira: string;
712
716
  convenio: string;
713
717
  agencia: string;
714
718
  agenciaDigito: string;
@@ -721,6 +725,8 @@ interface IDadosRemessa {
721
725
  diasProtesto: number;
722
726
  };
723
727
  boletos: {
728
+ tipoDocumento: 'NFE' | 'FIN' | 'FAT';
729
+ id_boleto: number;
724
730
  identificacaoTitulo: string;
725
731
  vencimento: string | Date;
726
732
  valor: number | string;
package/build/index.js CHANGED
@@ -256,7 +256,6 @@ function decompress(input) {
256
256
  // src/banks/ailos/gerarPDF.ts
257
257
  function gerarPDF(_0) {
258
258
  return __async(this, arguments, function* ({ dados }) {
259
- var _a, _b, _c, _d, _e, _f, _g, _h;
260
259
  try {
261
260
  const { generatePDF, dadosPDF } = dados;
262
261
  const codigoBarra2 = yield import_bwip_js.default.toBuffer({
@@ -287,6 +286,7 @@ function gerarPDF(_0) {
287
286
  dadosPDF.boleto.valorDescontoAbatimento = maskFormat_default.numberToReal(
288
287
  dadosPDF.boleto.valorDescontoAbatimento
289
288
  );
289
+ const valorDocumento = Number(dadosPDF.boleto.valorDocumento);
290
290
  dadosPDF.boleto.valorDocumento = maskFormat_default.numberToReal(
291
291
  dadosPDF.boleto.valorDocumento
292
292
  );
@@ -297,21 +297,21 @@ function gerarPDF(_0) {
297
297
  if (dadosPDF.boleto.quantidade) {
298
298
  dadosPDF.boleto.quantidade = maskFormat_default.numberToReal(dadosPDF.boleto.quantidade);
299
299
  }
300
- const jurosMes = Number(((_a = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _a.juros) || 0);
301
- const jurosAoDia = jurosMes / 30;
302
- if (!((_b = dadosPDF.boleto.instrucao1) == null ? void 0 : _b.length) && jurosAoDia > 0) {
303
- dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE ${jurosAoDia}% AO DIA, AP\xD3S O VENCIMENTO`;
300
+ const jurosMes = dadosPDF.beneficiario.dadosBancario.juros;
301
+ const jurosDia = jurosMes / 100 / 30 * valorDocumento;
302
+ if (jurosDia > 0) {
303
+ dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${maskFormat_default.numberToReal(jurosDia)} AO DIA, AP\xD3S O VENCIMENTO`;
304
304
  }
305
- const descontoVencimento = Number(((_c = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _c.desconto) || 0);
306
- if (!((_d = dadosPDF.boleto.instrucao2) == null ? void 0 : _d.length) && descontoVencimento > 0) {
305
+ const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto || 0;
306
+ if (descontoVencimento > 0) {
307
307
  dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
308
308
  }
309
- const multaAtraso = Number(((_e = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _e.multa) || 0);
310
- if (!((_f = dadosPDF.boleto.instrucao3) == null ? void 0 : _f.length) && multaAtraso > 0) {
311
- dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso} %`;
309
+ const multaAtraso = dadosPDF.beneficiario.dadosBancario.multa || 0;
310
+ if (multaAtraso > 0) {
311
+ dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso}%`;
312
312
  }
313
- const protestoDias = Number(((_g = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _g.protesto) || 0);
314
- if (!((_h = dadosPDF.boleto.instrucao4) == null ? void 0 : _h.length) && protestoDias > 0) {
313
+ const protestoDias = dadosPDF.beneficiario.dadosBancario.protesto || 0;
314
+ if (protestoDias > 0) {
315
315
  dadosPDF.boleto.instrucao4 = `PROTESTAR AP\xD3S ${protestoDias} DIAS CORRIDOS DO VENCIMENTO`;
316
316
  }
317
317
  dadosPDF.boleto.valor = maskFormat_default.numberToReal(dadosPDF.boleto.valor);
@@ -1259,7 +1259,6 @@ function getDigito3(texto) {
1259
1259
  var import_bwip_js3 = __toESM(require("bwip-js"));
1260
1260
  function gerarPDF3(_0) {
1261
1261
  return __async(this, arguments, function* ({ dados }) {
1262
- var _a, _b, _c, _d, _e, _f, _g;
1263
1262
  try {
1264
1263
  const { generatePDF, dadosPDF } = dados;
1265
1264
  const codigoBarra2 = yield import_bwip_js3.default.toBuffer({
@@ -1289,6 +1288,7 @@ function gerarPDF3(_0) {
1289
1288
  dadosPDF.boleto.valorDescontoAbatimento = maskFormat_default.numberToReal(
1290
1289
  dadosPDF.boleto.valorDescontoAbatimento
1291
1290
  );
1291
+ const valorDocumento = Number(dadosPDF.boleto.valorDocumento);
1292
1292
  dadosPDF.boleto.valorDocumento = maskFormat_default.numberToReal(
1293
1293
  dadosPDF.boleto.valorDocumento
1294
1294
  );
@@ -1299,20 +1299,20 @@ function gerarPDF3(_0) {
1299
1299
  if (dadosPDF.boleto.quantidade) {
1300
1300
  dadosPDF.boleto.quantidade = maskFormat_default.numberToReal(dadosPDF.boleto.quantidade);
1301
1301
  }
1302
- const jurosMes = Number(((_a = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _a.juros) || 0);
1303
- const jurosAoDia = jurosMes > 0 ? jurosMes / 30 : 0;
1304
- if (!((_b = dadosPDF.boleto.instrucao1) == null ? void 0 : _b.length) && jurosAoDia > 0) {
1305
- dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE ${jurosAoDia}% AO DIA, AP\xD3S O VENCIMENTO`;
1302
+ const jurosMes = dadosPDF.beneficiario.dadosBancario.juros;
1303
+ const jurosDia = jurosMes / 100 / 30 * valorDocumento;
1304
+ if (jurosDia > 0) {
1305
+ dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${maskFormat_default.numberToReal(jurosDia)} AO DIA, AP\xD3S O VENCIMENTO`;
1306
1306
  }
1307
- const descontoVencimento = Number(((_c = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _c.desconto) || 0);
1308
- if (!((_d = dadosPDF.boleto.instrucao2) == null ? void 0 : _d.length) && descontoVencimento > 0) {
1307
+ const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto || 0;
1308
+ if (descontoVencimento > 0) {
1309
1309
  dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
1310
1310
  }
1311
- const multaAtraso = Number(((_e = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _e.multa) || 0);
1312
- if (!((_f = dadosPDF.boleto.instrucao3) == null ? void 0 : _f.length) && multaAtraso > 0) {
1313
- dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso} %`;
1311
+ const multaAtraso = dadosPDF.beneficiario.dadosBancario.multa || 0;
1312
+ if (multaAtraso > 0) {
1313
+ dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso}%`;
1314
1314
  }
1315
- const protestoDias = Number(((_g = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _g.protesto) || 0);
1315
+ const protestoDias = dadosPDF.beneficiario.dadosBancario.protesto || 0;
1316
1316
  if (protestoDias > 0) {
1317
1317
  dadosPDF.boleto.instrucao4 = `PROTESTAR AP\xD3S ${protestoDias} DIAS CORRIDOS DO VENCIMENTO`;
1318
1318
  }
@@ -1997,10 +1997,19 @@ function gerarDadosBoleto5({ dados }) {
1997
1997
  parcela.valor = Number(parcela.valor);
1998
1998
  const fatorVencimento = getFatorVencimento(parcela.vencimento);
1999
1999
  const valor = getValor5(parcela.valor);
2000
- const convenio = padLeft(bancario.convenio, 6);
2001
- const numeroDocumento = padLeft(`${parcela.id_boleto}2`, 5);
2002
- const nossoNumero = getNossoNumero3(`${convenio}${numeroDocumento}`);
2003
- const campoLivre = copy(nossoNumero, 1, 11) + padLeft(bancario.agencia, 4) + padLeft(`${bancario.numero}${bancario.numero_dv}`, 8) + padLeft(bancario.carteira, 2);
2000
+ const convenio = bancario.convenio;
2001
+ let nossoNumero = "";
2002
+ let numeroDocumento = "";
2003
+ let campoLivre = "";
2004
+ if (convenio.length === 6) {
2005
+ numeroDocumento = padLeft(`${parcela.id_boleto}2`, 5);
2006
+ nossoNumero = getNossoNumero3(`${convenio}${numeroDocumento}2`);
2007
+ campoLivre = copy(nossoNumero, 1, 11) + padLeft(bancario.agencia, 4) + padLeft(`${bancario.numero}${bancario.numero_dv}`, 8) + padLeft(bancario.carteira, 2);
2008
+ } else if (convenio.length === 7) {
2009
+ numeroDocumento = padLeft(`${parcela.id_boleto}2`, 10);
2010
+ nossoNumero = `${convenio}${numeroDocumento}`;
2011
+ campoLivre = `000000${nossoNumero}${padLeft(bancario.carteira, 2)}`;
2012
+ }
2004
2013
  const digitoGeral = getDigitoGeral5(`0019${fatorVencimento}${valor}${campoLivre}`);
2005
2014
  const codigoBarra2 = `0019${digitoGeral}${fatorVencimento}${valor}${campoLivre}`;
2006
2015
  const campo1 = copy(codigoBarra2, 1, 3) + copy(codigoBarra2, 4, 4) + copy(codigoBarra2, 20, 24);
@@ -2095,7 +2104,6 @@ function getDigito5(texto) {
2095
2104
  var import_bwip_js5 = __toESM(require("bwip-js"));
2096
2105
  function gerarPDF5(_0) {
2097
2106
  return __async(this, arguments, function* ({ dados }) {
2098
- var _a, _b, _c, _d, _e, _f, _g, _h;
2099
2107
  try {
2100
2108
  const { dadosPDF } = dados;
2101
2109
  const codigoBarra2 = yield import_bwip_js5.default.toBuffer({
@@ -2126,6 +2134,7 @@ function gerarPDF5(_0) {
2126
2134
  dadosPDF.boleto.valorDescontoAbatimento = maskFormat_default.numberToReal(
2127
2135
  dadosPDF.boleto.valorDescontoAbatimento
2128
2136
  );
2137
+ const valorDocumento = Number(dadosPDF.boleto.valorDocumento);
2129
2138
  dadosPDF.boleto.valorDocumento = maskFormat_default.numberToReal(
2130
2139
  dadosPDF.boleto.valorDocumento
2131
2140
  );
@@ -2136,21 +2145,21 @@ function gerarPDF5(_0) {
2136
2145
  if (dadosPDF.boleto.quantidade) {
2137
2146
  dadosPDF.boleto.quantidade = maskFormat_default.numberToReal(dadosPDF.boleto.quantidade);
2138
2147
  }
2139
- const jurosMes = Number(((_a = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _a.juros) || 0);
2140
- const jurosAoDia = jurosMes / 30;
2141
- if (!((_b = dadosPDF.boleto.instrucao1) == null ? void 0 : _b.length) && jurosAoDia > 0) {
2142
- dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE ${jurosMes}% AO DIA, AP\xD3S O VENCIMENTO`;
2148
+ const jurosMes = dadosPDF.beneficiario.dadosBancario.juros;
2149
+ const jurosDia = jurosMes / 100 / 30 * valorDocumento;
2150
+ if (jurosDia > 0) {
2151
+ dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${jurosDia} AO DIA, AP\xD3S O VENCIMENTO`;
2143
2152
  }
2144
- const descontoVencimento = Number(((_c = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _c.desconto) || 0);
2145
- if (!((_d = dadosPDF.boleto.instrucao2) == null ? void 0 : _d.length) && descontoVencimento > 0) {
2153
+ const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto || 0;
2154
+ if (descontoVencimento > 0) {
2146
2155
  dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
2147
2156
  }
2148
- const multaAtraso = Number(((_e = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _e.multa) || 0);
2149
- if (!((_f = dadosPDF.boleto.instrucao3) == null ? void 0 : _f.length) && multaAtraso > 0) {
2150
- dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso} %`;
2157
+ const multaAtraso = dadosPDF.beneficiario.dadosBancario.multa || 0;
2158
+ if (multaAtraso > 0) {
2159
+ dadosPDF.boleto.instrucao3 = `MULTA DE ${multaAtraso}%`;
2151
2160
  }
2152
- const protestoDias = Number(((_g = dadosPDF.beneficiario.dadosBancario) == null ? void 0 : _g.protesto) || 0);
2153
- if (!((_h = dadosPDF.boleto.instrucao4) == null ? void 0 : _h.length) && protestoDias > 0) {
2161
+ const protestoDias = dadosPDF.beneficiario.dadosBancario.protesto || 0;
2162
+ if (protestoDias > 0) {
2154
2163
  dadosPDF.boleto.instrucao4 = `PROTESTAR AP\xD3S ${protestoDias} DIAS CORRIDOS DO VENCIMENTO`;
2155
2164
  }
2156
2165
  dadosPDF.boleto.valor = maskFormat_default.numberToReal(dadosPDF.boleto.valor);
@@ -2186,58 +2195,69 @@ function gerarPDF5(_0) {
2186
2195
  var import_date_fns6 = require("date-fns");
2187
2196
  function gerarRemessa5({ dados }) {
2188
2197
  try {
2189
- const { dadosBancario, beneficiario, boletos } = dados.remessa;
2198
+ const {
2199
+ dadosBancario,
2200
+ beneficiario,
2201
+ boletos
2202
+ } = dados.remessa;
2190
2203
  const arquivo = new Arquivo();
2191
2204
  const dataAtual = /* @__PURE__ */ new Date();
2192
2205
  const data = (0, import_date_fns6.format)(dataAtual, "ddMMyyyy");
2193
2206
  const hora = (0, import_date_fns6.format)(dataAtual, "HHmmss");
2194
- const convenio = dadosBancario.convenio.padStart(7, "0");
2195
- const numero = dadosBancario.conta.padStart(7, "0") + dadosBancario.contaDigito;
2196
- const remessa2 = `REM${convenio}-${numero}-${data}.REM`;
2197
- arquivo.add("085");
2207
+ const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(5, "0")}.CNAB`;
2208
+ arquivo.add("001");
2198
2209
  arquivo.add("0000");
2199
2210
  arquivo.add("0");
2200
- arquivo.add(" ");
2211
+ arquivo.add(" ".padEnd(9, " "));
2201
2212
  arquivo.add("2");
2202
- arquivo.add(beneficiario.cnpj);
2203
- arquivo.add(dadosBancario.convenio.padEnd(20, " "));
2204
- arquivo.add(dadosBancario.agencia.padStart(5, "0"));
2205
- arquivo.add(dadosBancario.agenciaDigito);
2206
- arquivo.add(dadosBancario.conta.padStart(12, "0"));
2207
- arquivo.add(dadosBancario.contaDigito);
2213
+ arquivo.add(beneficiario.cnpj.padStart(14, "0"));
2214
+ arquivo.add(dadosBancario.convenio.padStart(9, "0"));
2215
+ arquivo.add("0014");
2216
+ arquivo.add(dadosBancario.carteira.padStart(2, "0"));
2217
+ arquivo.add(dadosBancario.variacao_carteira.padStart(3, "0"));
2218
+ arquivo.add(" ");
2219
+ arquivo.add("0");
2220
+ arquivo.add(`${dadosBancario.agencia}${dadosBancario.agenciaDigito}`.padStart(5, "0"));
2221
+ arquivo.add("00000");
2222
+ arquivo.add(`${dadosBancario.conta}${dadosBancario.contaDigito}`.padStart(8, "0"));
2208
2223
  arquivo.add(" ");
2209
2224
  arquivo.add(removerAcentos(beneficiario.nome).substring(0, 30).padEnd(30, " "));
2210
- arquivo.add("AILOS".padEnd(30, " "));
2211
- arquivo.add(" ");
2225
+ arquivo.add("BANCO DO BRASIL S.A.".padEnd(30, " "));
2226
+ arquivo.add(" ".padEnd(10, " "));
2212
2227
  arquivo.add("1");
2213
2228
  arquivo.add(data);
2214
2229
  arquivo.add(hora);
2215
2230
  arquivo.add(dadosBancario.numeroRemessa.padStart(6, "0"));
2216
- arquivo.add("087");
2231
+ arquivo.add("030");
2217
2232
  arquivo.add("00000");
2218
- arquivo.add(" ".padEnd(20, " "));
2219
- arquivo.add(" ".padEnd(20, " "));
2220
- arquivo.add(" ".padEnd(29, " "));
2233
+ arquivo.add(" ".padEnd(40, " "));
2234
+ arquivo.add(" ".padEnd(11, " "));
2235
+ arquivo.add("CSP");
2236
+ arquivo.add("000");
2237
+ arquivo.add(" ".padEnd(12, " "));
2221
2238
  arquivo.addLine();
2222
- arquivo.add("085");
2239
+ arquivo.add("001");
2223
2240
  arquivo.add("0001");
2224
2241
  arquivo.add("1");
2225
2242
  arquivo.add("R");
2226
2243
  arquivo.add("01");
2227
- arquivo.add(" ");
2228
- arquivo.add("045");
2244
+ arquivo.add("00");
2245
+ arquivo.add("020");
2229
2246
  arquivo.add(" ");
2230
2247
  arquivo.add("2");
2231
2248
  arquivo.add(beneficiario.cnpj.padStart(15, "0"));
2232
- arquivo.add(dadosBancario.convenio.padEnd(20, " "));
2233
- arquivo.add(dadosBancario.agencia.padStart(5, "0"));
2234
- arquivo.add(dadosBancario.agenciaDigito);
2235
- arquivo.add(dadosBancario.conta.padStart(12, "0"));
2236
- arquivo.add(dadosBancario.contaDigito);
2249
+ arquivo.add(dadosBancario.convenio.padEnd(9, " "));
2250
+ arquivo.add("0014");
2251
+ arquivo.add(dadosBancario.carteira.padStart(2, "0"));
2252
+ arquivo.add(dadosBancario.variacao_carteira.padStart(3, "0"));
2253
+ arquivo.add(" ");
2254
+ arquivo.add("0");
2255
+ arquivo.add(`${dadosBancario.agencia}${dadosBancario.agenciaDigito}`.padStart(5, "0"));
2256
+ arquivo.add("00000");
2257
+ arquivo.add(`${dadosBancario.conta}${dadosBancario.contaDigito}`.padStart(8, "0"));
2237
2258
  arquivo.add(" ");
2238
2259
  arquivo.add(removerAcentos(beneficiario.nome).substring(0, 30).padEnd(30, " "));
2239
- arquivo.add(" ".padEnd(40, " "));
2240
- arquivo.add(" ".padEnd(40, " "));
2260
+ arquivo.add(" ".padEnd(80, " "));
2241
2261
  arquivo.add(dadosBancario.numeroRemessa.padStart(8, "0"));
2242
2262
  arquivo.add(data);
2243
2263
  arquivo.add("00000000");
@@ -2247,72 +2267,97 @@ function gerarRemessa5({ dados }) {
2247
2267
  let quantidadeRegistro = 0;
2248
2268
  let total = 0;
2249
2269
  for (const boleto of boletos) {
2270
+ const convenio = dadosBancario.convenio;
2271
+ let nosso_numero = "";
2272
+ if (convenio.length === 6) {
2273
+ switch (boleto.tipoDocumento) {
2274
+ case "NFE": {
2275
+ nosso_numero = getNossoNumero3(`${convenio}${boleto.id_boleto}2`);
2276
+ break;
2277
+ }
2278
+ case "FAT": {
2279
+ nosso_numero = getNossoNumero3(`${convenio}${boleto.id_boleto}4`);
2280
+ break;
2281
+ }
2282
+ case "FIN": {
2283
+ nosso_numero = getNossoNumero3(`${convenio}${boleto.id_boleto}5`);
2284
+ break;
2285
+ }
2286
+ }
2287
+ } else if (convenio.length === 7) {
2288
+ switch (boleto.tipoDocumento) {
2289
+ case "NFE": {
2290
+ nosso_numero = `${convenio}${boleto.id_boleto.toString().padStart(10, "0")}2`;
2291
+ break;
2292
+ }
2293
+ case "FAT": {
2294
+ nosso_numero = `${convenio}${boleto.id_boleto.toString().padStart(10, "0")}4`;
2295
+ break;
2296
+ }
2297
+ case "FIN": {
2298
+ nosso_numero = `${convenio}${boleto.id_boleto.toString().padStart(10, "0")}5`;
2299
+ break;
2300
+ }
2301
+ }
2302
+ }
2303
+ const valorJurosDia = dadosBancario.jurosMes > 0 ? Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30 : 0;
2250
2304
  const { pagador } = boleto;
2305
+ const tipoInscricao = pagador.pessoa === "F" ? "1" : "2";
2251
2306
  const vencimento = (0, import_date_fns6.format)(new Date(boleto.vencimento), "ddMMyyyy");
2252
2307
  total += Number(boleto.valor);
2253
- const codigoJuro = dadosBancario.jurosMes > 0 ? "2" : "3";
2254
- const juros = dadosBancario.jurosMes > 0 ? dadosBancario.jurosMes.toFixed(2) : "000000000000000";
2255
- const jurosVencimento = (0, import_date_fns6.format)(
2256
- (0, import_date_fns6.addDays)(new Date(boleto.vencimento), 1),
2257
- "ddMMyyyy"
2258
- );
2259
- const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
2260
- const desconto = dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
2261
- const protesto = dadosBancario.diasProtesto > 0 ? "1" : "3";
2262
- const diasProtesto = protesto === "1" ? dadosBancario.diasProtesto.toString() : "00";
2263
- arquivo.add("085");
2308
+ let protesto = "3";
2309
+ let diasProtesto = "00";
2310
+ let baixarDevolver = "1";
2311
+ let diasBaixa = "000";
2312
+ if (dadosBancario.diasProtesto) {
2313
+ protesto = "1";
2314
+ diasProtesto = dadosBancario.diasProtesto.toString().padStart(2, "0");
2315
+ baixarDevolver = "2";
2316
+ diasBaixa = "060";
2317
+ }
2318
+ arquivo.add("001");
2264
2319
  arquivo.add("0001");
2265
2320
  arquivo.add("3");
2266
2321
  arquivo.add((++sequencia).toString().padStart(5, "0"));
2267
2322
  arquivo.add("P");
2268
2323
  arquivo.add(" ");
2269
2324
  arquivo.add("01");
2270
- arquivo.add(dadosBancario.agencia.padStart(5, "0"));
2271
- arquivo.add(dadosBancario.agenciaDigito);
2272
- arquivo.add(dadosBancario.conta.padStart(12, "0"));
2273
- arquivo.add(dadosBancario.contaDigito);
2325
+ arquivo.add("0");
2326
+ arquivo.add(`${dadosBancario.agencia}${dadosBancario.agenciaDigito}`.padStart(5, "0"));
2327
+ arquivo.add("00000");
2328
+ arquivo.add(`${dadosBancario.conta}${dadosBancario.contaDigito}`.padStart(8, "0"));
2274
2329
  arquivo.add(" ");
2275
- arquivo.add(boleto.nossoNumero.padEnd(20, " "));
2276
- arquivo.add("1");
2277
- arquivo.add("1");
2278
- arquivo.add("1");
2279
- arquivo.add("2");
2280
- arquivo.add("2");
2281
- arquivo.add(`${boleto.numeroDocumento}/${boleto.parcela}`.padEnd(15, " "));
2330
+ arquivo.add(nosso_numero.padEnd(20, " "));
2331
+ arquivo.add("7");
2332
+ arquivo.add("1122");
2333
+ arquivo.add(`${boleto.numeroDocumento.padStart(6, "0")}-${boleto.parcela.toString().padStart(2, "0")}`.padEnd(15, " "));
2282
2334
  arquivo.add(vencimento);
2283
2335
  arquivo.add(
2284
2336
  Number(boleto.valor).toFixed(2).replace(".", "").padStart(15, "0")
2285
2337
  );
2286
- arquivo.add(dadosBancario.agencia.padStart(5, "0"));
2287
- arquivo.add(dadosBancario.agenciaDigito);
2338
+ arquivo.add("00000 ");
2288
2339
  arquivo.add("02");
2289
- arquivo.add("A");
2340
+ arquivo.add("N");
2290
2341
  arquivo.add(data);
2291
- arquivo.add(codigoJuro);
2292
- arquivo.add(jurosVencimento);
2293
- arquivo.add(juros.replace(".", "").padStart(15, "0"));
2294
- arquivo.add(codigoDesconto);
2295
- arquivo.add(vencimento);
2296
- arquivo.add(desconto.replace(".", "").padStart(15, "0"));
2342
+ arquivo.add("1");
2343
+ arquivo.add("00000000");
2344
+ arquivo.add(valorJurosDia.toFixed(2).replace(".", "").padStart(15, "0"));
2345
+ arquivo.add("0");
2346
+ arquivo.add("00000000");
2297
2347
  arquivo.add("000000000000000");
2298
2348
  arquivo.add("000000000000000");
2299
- arquivo.add(boleto.identificacaoTitulo.padEnd(25, " "));
2349
+ arquivo.add("000000000000000");
2350
+ arquivo.add(" ".padEnd(25, " "));
2300
2351
  arquivo.add(protesto);
2301
- arquivo.add(diasProtesto.padStart(1, "0"));
2302
- arquivo.add("2");
2303
- arquivo.add(" ");
2352
+ arquivo.add(diasProtesto);
2353
+ arquivo.add(baixarDevolver);
2354
+ arquivo.add(diasBaixa);
2304
2355
  arquivo.add("09");
2305
2356
  arquivo.add("0000000000");
2306
2357
  arquivo.add(" ");
2307
2358
  arquivo.addLine();
2308
- let tipoInscricao = "1";
2309
- if (pagador.pessoa === "F") {
2310
- tipoInscricao = "1";
2311
- } else {
2312
- tipoInscricao = "2";
2313
- }
2314
2359
  pagador.endereco.logradouro = `${removerAcentos(pagador.endereco.logradouro).substring(0, 32).padEnd(32, " ")}${pagador.endereco.numero.padEnd(8, " ")}`;
2315
- arquivo.add("085");
2360
+ arquivo.add("001");
2316
2361
  arquivo.add("0001");
2317
2362
  arquivo.add("3");
2318
2363
  arquivo.add((++sequencia).toString().padStart(5, "0"));
@@ -2324,21 +2369,19 @@ function gerarRemessa5({ dados }) {
2324
2369
  arquivo.add(removerAcentos(pagador.nome).substring(0, 40).padEnd(40, " "));
2325
2370
  arquivo.add(removerAcentos(pagador.endereco.logradouro).substring(0, 40).padEnd(40, " "));
2326
2371
  arquivo.add(removerAcentos(pagador.endereco.bairro).substring(0, 15).padEnd(15, " "));
2327
- arquivo.add(pagador.endereco.cep.substring(0, 5).padStart(5, "0"));
2328
- arquivo.add(pagador.endereco.cep.substring(5, 7).padStart(3, "0"));
2372
+ arquivo.add(pagador.endereco.cep);
2329
2373
  arquivo.add(removerAcentos(pagador.endereco.municipio).substring(0, 15).padEnd(15, " "));
2330
2374
  arquivo.add(removerAcentos(pagador.endereco.uf).padEnd(2, " "));
2331
2375
  arquivo.add("0");
2332
2376
  arquivo.add("000000000000000");
2333
2377
  arquivo.add(" ".padEnd(40, " "));
2334
2378
  arquivo.add("000");
2335
- arquivo.add(" ".padEnd(20, " "));
2336
- arquivo.add(" ".padEnd(8, " "));
2379
+ arquivo.add(" ".padEnd(28, " "));
2337
2380
  arquivo.addLine();
2338
2381
  dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
2339
2382
  if (dadosBancario.multaAtraso > 0) {
2340
2383
  const multa = dadosBancario.multaAtraso.toFixed(2);
2341
- arquivo.add("085");
2384
+ arquivo.add("001");
2342
2385
  arquivo.add("0001");
2343
2386
  arquivo.add("3");
2344
2387
  arquivo.add((++sequencia).toString().padStart(5, "0"));
@@ -2363,31 +2406,25 @@ function gerarRemessa5({ dados }) {
2363
2406
  arquivo.add("00000");
2364
2407
  arquivo.add(" ");
2365
2408
  arquivo.add("000000000000");
2366
- arquivo.add(" ");
2367
- arquivo.add(" ");
2409
+ arquivo.add(" ");
2368
2410
  arquivo.add("0");
2369
- arquivo.add("000000000");
2411
+ arquivo.add(" ".padEnd(9, " "));
2370
2412
  arquivo.addLine();
2371
2413
  }
2372
2414
  quantidadeRegistro++;
2373
2415
  }
2374
- arquivo.add("085");
2416
+ arquivo.add("001");
2375
2417
  arquivo.add("0001");
2376
2418
  arquivo.add("5");
2377
2419
  arquivo.add(" ".padEnd(9, " "));
2378
2420
  arquivo.add((sequencia + 3).toString().padStart(6, "0"));
2379
- arquivo.add(quantidadeRegistro.toString().padStart(6, "0"));
2380
- arquivo.add(total.toFixed(2).replace(".", "").padStart(17, "0"));
2381
- arquivo.add("0".padStart(6, "0"));
2382
- arquivo.add("0".padStart(17, "0"));
2383
- arquivo.add("0".padStart(6, "0"));
2384
- arquivo.add("0".padStart(17, "0"));
2385
- arquivo.add("0".padStart(6, "0"));
2386
- arquivo.add("0".padStart(17, "0"));
2387
- arquivo.add(" ".padStart(8, " "));
2388
- arquivo.add(" ".padStart(117, " "));
2421
+ arquivo.add("000000");
2422
+ arquivo.add("00");
2423
+ arquivo.add("000000000000000");
2424
+ arquivo.add("000000000000000000000000000000000000000000000000000000000000000000000");
2425
+ arquivo.add(" ".padEnd(125, " "));
2389
2426
  arquivo.addLine();
2390
- arquivo.add("085");
2427
+ arquivo.add("001");
2391
2428
  arquivo.add("9999");
2392
2429
  arquivo.add("9");
2393
2430
  arquivo.add(" ".padEnd(9, " "));
@@ -2395,6 +2432,7 @@ function gerarRemessa5({ dados }) {
2395
2432
  arquivo.add((sequencia + 4).toString().padStart(6, "0"));
2396
2433
  arquivo.add("000000");
2397
2434
  arquivo.add(" ".padEnd(205, " "));
2435
+ arquivo.addLine();
2398
2436
  return {
2399
2437
  download: remessa2,
2400
2438
  arquivo: arquivo.getArquivo()