@plasoft/boletos 1.0.57 → 1.0.59
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 +2 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +96 -41
- package/build/index.js.map +1 -1
- package/build/index.mjs +95 -40
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
package/build/index.d.mts
CHANGED
|
@@ -168,6 +168,7 @@ interface IDocumentoRetornoAilos {
|
|
|
168
168
|
valor_juros: number;
|
|
169
169
|
valor_desconto: number;
|
|
170
170
|
valor_total: number;
|
|
171
|
+
data: Date | string;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
interface IGerarBoletoBradesco {
|
|
@@ -876,7 +877,7 @@ declare function remessa({ banco, dados }: IGerarRemessa): {
|
|
|
876
877
|
arquivo: string;
|
|
877
878
|
} | null> | null | undefined;
|
|
878
879
|
|
|
879
|
-
declare function retorno({ banco, dados }: IGerarRetorno): IDocumentoRetornoAilos[] | null | undefined;
|
|
880
|
+
declare function retorno({ banco, dados }: IGerarRetorno): Record<string, IDocumentoRetornoAilos[]> | null | undefined;
|
|
880
881
|
|
|
881
882
|
interface IConfig {
|
|
882
883
|
apiClient?: {
|
package/build/index.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ interface IDocumentoRetornoAilos {
|
|
|
168
168
|
valor_juros: number;
|
|
169
169
|
valor_desconto: number;
|
|
170
170
|
valor_total: number;
|
|
171
|
+
data: Date | string;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
interface IGerarBoletoBradesco {
|
|
@@ -876,7 +877,7 @@ declare function remessa({ banco, dados }: IGerarRemessa): {
|
|
|
876
877
|
arquivo: string;
|
|
877
878
|
} | null> | null | undefined;
|
|
878
879
|
|
|
879
|
-
declare function retorno({ banco, dados }: IGerarRetorno): IDocumentoRetornoAilos[] | null | undefined;
|
|
880
|
+
declare function retorno({ banco, dados }: IGerarRetorno): Record<string, IDocumentoRetornoAilos[]> | null | undefined;
|
|
880
881
|
|
|
881
882
|
interface IConfig {
|
|
882
883
|
apiClient?: {
|
package/build/index.js
CHANGED
|
@@ -655,6 +655,22 @@ function gerarRemessa({ dados }) {
|
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
657
|
|
|
658
|
+
// src/banks/ailos/gerarRetorno.ts
|
|
659
|
+
var import_date_fns4 = require("date-fns");
|
|
660
|
+
|
|
661
|
+
// src/utils/agruparRetorno.ts
|
|
662
|
+
var import_date_fns3 = require("date-fns");
|
|
663
|
+
function agruparRetorno(documentos) {
|
|
664
|
+
return documentos.reduce((acc, documento) => {
|
|
665
|
+
const dataKey = (0, import_date_fns3.format)(new Date(documento.data), "yyyy-MM-dd");
|
|
666
|
+
if (!acc[dataKey]) {
|
|
667
|
+
acc[dataKey] = [];
|
|
668
|
+
}
|
|
669
|
+
acc[dataKey].push(documento);
|
|
670
|
+
return acc;
|
|
671
|
+
}, {});
|
|
672
|
+
}
|
|
673
|
+
|
|
658
674
|
// src/banks/ailos/gerarRetorno.ts
|
|
659
675
|
function gerarRetorno({ dados }) {
|
|
660
676
|
try {
|
|
@@ -680,6 +696,14 @@ function gerarRetorno({ dados }) {
|
|
|
680
696
|
linha = arquivo[index + 1];
|
|
681
697
|
segmento = linha.substring(13, 14);
|
|
682
698
|
if (segmento === "U") {
|
|
699
|
+
let dataCredito;
|
|
700
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
701
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
702
|
+
dataCredito = (0, import_date_fns4.parse)(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
703
|
+
} else {
|
|
704
|
+
const dataOcorrenciaString = linha.substring(157, 165);
|
|
705
|
+
dataCredito = (0, import_date_fns4.parse)(dataOcorrenciaString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
706
|
+
}
|
|
683
707
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
684
708
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
685
709
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -698,7 +722,8 @@ function gerarRetorno({ dados }) {
|
|
|
698
722
|
valor_multa: valorMulta,
|
|
699
723
|
valor_juros: valorJuros,
|
|
700
724
|
valor_desconto: valorDesconto,
|
|
701
|
-
valor_total: valorTotal
|
|
725
|
+
valor_total: valorTotal,
|
|
726
|
+
data: dataCredito
|
|
702
727
|
};
|
|
703
728
|
documentos.push(documento);
|
|
704
729
|
}
|
|
@@ -706,7 +731,8 @@ function gerarRetorno({ dados }) {
|
|
|
706
731
|
}
|
|
707
732
|
index++;
|
|
708
733
|
}
|
|
709
|
-
|
|
734
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
735
|
+
return documentoAgrupado;
|
|
710
736
|
} catch (error) {
|
|
711
737
|
console.log(error);
|
|
712
738
|
return null;
|
|
@@ -896,15 +922,15 @@ function gerarPDF2(_0) {
|
|
|
896
922
|
}
|
|
897
923
|
|
|
898
924
|
// src/banks/bradesco/gerarRemessa.ts
|
|
899
|
-
var
|
|
925
|
+
var import_date_fns5 = require("date-fns");
|
|
900
926
|
function gerarRemessa2(_0) {
|
|
901
927
|
return __async(this, arguments, function* ({ dados }) {
|
|
902
928
|
try {
|
|
903
929
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
904
930
|
const arquivo = new Arquivo();
|
|
905
931
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
906
|
-
const data = (0,
|
|
907
|
-
const hora = (0,
|
|
932
|
+
const data = (0, import_date_fns5.format)(dataAtual, "ddMMyyyy");
|
|
933
|
+
const hora = (0, import_date_fns5.format)(dataAtual, "HHmmss");
|
|
908
934
|
const convenio = dadosBancario.convenio.padStart(7, "0");
|
|
909
935
|
const numero = dadosBancario.conta.padStart(7, "0") + dadosBancario.contaDigito;
|
|
910
936
|
const remessa2 = `REM${convenio}-${numero}-${data}.REM`;
|
|
@@ -962,12 +988,12 @@ function gerarRemessa2(_0) {
|
|
|
962
988
|
let total = 0;
|
|
963
989
|
for (const boleto of boletos) {
|
|
964
990
|
const { pagador } = boleto;
|
|
965
|
-
const vencimento = (0,
|
|
991
|
+
const vencimento = (0, import_date_fns5.format)(new Date(boleto.vencimento), "ddMMyyyy");
|
|
966
992
|
total += Number(boleto.valor);
|
|
967
993
|
const codigoJuro = dadosBancario.jurosMes > 0 ? "2" : "3";
|
|
968
994
|
const juros = dadosBancario.jurosMes > 0 ? dadosBancario.jurosMes.toFixed(2) : "000000000000000";
|
|
969
|
-
const jurosVencimento = (0,
|
|
970
|
-
(0,
|
|
995
|
+
const jurosVencimento = (0, import_date_fns5.format)(
|
|
996
|
+
(0, import_date_fns5.addDays)(new Date(boleto.vencimento), 1),
|
|
971
997
|
"ddMMyyyy"
|
|
972
998
|
);
|
|
973
999
|
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
@@ -1165,7 +1191,8 @@ function gerarRetorno2({ dados }) {
|
|
|
1165
1191
|
valor_desconto: 0,
|
|
1166
1192
|
valor_juros: 0,
|
|
1167
1193
|
valor_multa: 0,
|
|
1168
|
-
valor_total: 0
|
|
1194
|
+
valor_total: 0,
|
|
1195
|
+
data: /* @__PURE__ */ new Date()
|
|
1169
1196
|
};
|
|
1170
1197
|
documentos.push(documento);
|
|
1171
1198
|
}
|
|
@@ -1173,7 +1200,8 @@ function gerarRetorno2({ dados }) {
|
|
|
1173
1200
|
}
|
|
1174
1201
|
index++;
|
|
1175
1202
|
}
|
|
1176
|
-
|
|
1203
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
1204
|
+
return documentoAgrupado;
|
|
1177
1205
|
} catch (error) {
|
|
1178
1206
|
console.log(error);
|
|
1179
1207
|
return null;
|
|
@@ -1326,15 +1354,9 @@ function gerarPDF3(_0) {
|
|
|
1326
1354
|
if (!dadosPDF.pagador.cpfcnpj) {
|
|
1327
1355
|
throw new Error("CPF/CNPJ do pagador na\u0303o informado!");
|
|
1328
1356
|
}
|
|
1329
|
-
const codigoBarraText = dadosPDF.boleto.codigoBarra.replace(/\D/g, "");
|
|
1330
|
-
if (!/^\d+$/.test(codigoBarraText)) {
|
|
1331
|
-
throw new Error("C\xF3digo de barras cont\xE9m caracteres inv\xE1lidos. Apenas d\xEDgitos s\xE3o permitidos.");
|
|
1332
|
-
}
|
|
1333
|
-
console.log(dadosPDF.boleto.codigoBarra);
|
|
1334
|
-
console.log(codigoBarraText);
|
|
1335
1357
|
const codigoBarra2 = yield import_bwip_js3.default.toBuffer({
|
|
1336
1358
|
bcid: "interleaved2of5",
|
|
1337
|
-
text:
|
|
1359
|
+
text: dadosPDF.boleto.codigoBarra,
|
|
1338
1360
|
height: 20
|
|
1339
1361
|
});
|
|
1340
1362
|
dadosPDF.beneficiario.dadosBancario.agencia = dadosPDF.beneficiario.dadosBancario.agencia.padStart(4, "0");
|
|
@@ -1428,7 +1450,7 @@ function gerarPDF3(_0) {
|
|
|
1428
1450
|
}
|
|
1429
1451
|
|
|
1430
1452
|
// src/banks/sicredi/gerarRemessa.ts
|
|
1431
|
-
var
|
|
1453
|
+
var import_date_fns6 = require("date-fns");
|
|
1432
1454
|
function gerarRemessa3({ dados }) {
|
|
1433
1455
|
try {
|
|
1434
1456
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
@@ -1462,7 +1484,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1462
1484
|
arquivo.add(" ".padEnd(31, " "));
|
|
1463
1485
|
arquivo.add("748");
|
|
1464
1486
|
arquivo.add("SICREDI".padEnd(15, " "));
|
|
1465
|
-
arquivo.add((0,
|
|
1487
|
+
arquivo.add((0, import_date_fns6.format)(data, "yyyyMMdd"));
|
|
1466
1488
|
arquivo.add(" ".padEnd(8, " "));
|
|
1467
1489
|
arquivo.add(dadosBancario.numeroRemessa.padStart(7, "0"));
|
|
1468
1490
|
arquivo.add(" ".padEnd(273, " "));
|
|
@@ -1479,11 +1501,11 @@ function gerarRemessa3({ dados }) {
|
|
|
1479
1501
|
let dataDesconto = "000000";
|
|
1480
1502
|
if (boleto.desconto) {
|
|
1481
1503
|
desconto = boleto.desconto.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1482
|
-
dataDesconto = (0,
|
|
1504
|
+
dataDesconto = (0, import_date_fns6.format)(new Date(boleto.vencimento), "ddMMyy");
|
|
1483
1505
|
}
|
|
1484
1506
|
if (!boleto.desconto && dadosBancario.descontoPagamento) {
|
|
1485
1507
|
desconto = dadosBancario.descontoPagamento.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1486
|
-
dataDesconto = (0,
|
|
1508
|
+
dataDesconto = (0, import_date_fns6.format)(new Date(boleto.vencimento), "ddMMyy");
|
|
1487
1509
|
}
|
|
1488
1510
|
let valorJurosDias = Number(boleto.valor) * Number(dadosBancario.jurosMes) / 100 / 30;
|
|
1489
1511
|
let multaAtraso = String(dadosBancario.multaAtraso * 100);
|
|
@@ -1494,7 +1516,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1494
1516
|
arquivo.add(" ".padEnd(28, " "));
|
|
1495
1517
|
arquivo.add(boleto.nossoNumero.padEnd(9, " "));
|
|
1496
1518
|
arquivo.add(" ".padEnd(6, " "));
|
|
1497
|
-
arquivo.add((0,
|
|
1519
|
+
arquivo.add((0, import_date_fns6.format)(new Date(boleto.emissao), "yyyyMMdd"));
|
|
1498
1520
|
arquivo.add(" ");
|
|
1499
1521
|
arquivo.add("N");
|
|
1500
1522
|
arquivo.add(" ");
|
|
@@ -1506,12 +1528,12 @@ function gerarRemessa3({ dados }) {
|
|
|
1506
1528
|
arquivo.add(" ".padEnd(12, " "));
|
|
1507
1529
|
arquivo.add("01");
|
|
1508
1530
|
arquivo.add(boleto.identificacaoTitulo.padEnd(10, " "));
|
|
1509
|
-
arquivo.add((0,
|
|
1531
|
+
arquivo.add((0, import_date_fns6.format)(new Date(boleto.vencimento), "ddMMyy"));
|
|
1510
1532
|
arquivo.add(Number(boleto.valor).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
1511
1533
|
arquivo.add(" ".padEnd(9, " "));
|
|
1512
1534
|
arquivo.add("A");
|
|
1513
1535
|
arquivo.add(boleto.aceite);
|
|
1514
|
-
arquivo.add((0,
|
|
1536
|
+
arquivo.add((0, import_date_fns6.format)(new Date(boleto.emissao), "ddMMyy"));
|
|
1515
1537
|
arquivo.add(protestar);
|
|
1516
1538
|
arquivo.add(String(dadosBancario.diasProtesto).padStart(2, "0"));
|
|
1517
1539
|
arquivo.add(Number(valorJurosDias).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
@@ -1539,7 +1561,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1539
1561
|
arquivo.add(String(sequencia).padStart(6, "0"));
|
|
1540
1562
|
arquivo.addLine();
|
|
1541
1563
|
return {
|
|
1542
|
-
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${(0,
|
|
1564
|
+
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${(0, import_date_fns6.format)(data, "dd")}.crm`,
|
|
1543
1565
|
arquivo: arquivo.getArquivo()
|
|
1544
1566
|
};
|
|
1545
1567
|
} catch (error) {
|
|
@@ -1562,6 +1584,7 @@ function retornaMes(data) {
|
|
|
1562
1584
|
}
|
|
1563
1585
|
|
|
1564
1586
|
// src/banks/sicredi/gerarRetorno.ts
|
|
1587
|
+
var import_date_fns7 = require("date-fns");
|
|
1565
1588
|
function gerarRetorno3({ dados }) {
|
|
1566
1589
|
try {
|
|
1567
1590
|
const { arquivo } = dados;
|
|
@@ -1587,6 +1610,14 @@ function gerarRetorno3({ dados }) {
|
|
|
1587
1610
|
if (tipo_documento.length) {
|
|
1588
1611
|
especie = tipo_documento === "N" ? "NFE" : tipo_documento === "F" ? "FAT" : tipo_documento === "L" ? "FIN" : "INDEFINIDO";
|
|
1589
1612
|
}
|
|
1613
|
+
let dataCredito;
|
|
1614
|
+
const dataCreditoString = linha.substring(328, 336);
|
|
1615
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
1616
|
+
dataCredito = (0, import_date_fns7.parse)(dataCreditoString, "yyyyMMdd", /* @__PURE__ */ new Date());
|
|
1617
|
+
} else {
|
|
1618
|
+
const dataOcorrenciaString = linha.substring(110, 116);
|
|
1619
|
+
dataCredito = (0, import_date_fns7.parse)(dataOcorrenciaString, "ddMMyy", /* @__PURE__ */ new Date());
|
|
1620
|
+
}
|
|
1590
1621
|
const valor_titulo = Number(linha.substring(152, 165)) / 100;
|
|
1591
1622
|
const abatimento = Number(linha.substring(227, 240)) / 100;
|
|
1592
1623
|
let valor_desconto = Number(linha.substring(240, 253)) / 100;
|
|
@@ -1608,10 +1639,12 @@ function gerarRetorno3({ dados }) {
|
|
|
1608
1639
|
valor_multa,
|
|
1609
1640
|
valor_juros,
|
|
1610
1641
|
valor_desconto,
|
|
1611
|
-
valor_total
|
|
1642
|
+
valor_total,
|
|
1643
|
+
data: dataCredito
|
|
1612
1644
|
});
|
|
1613
1645
|
}
|
|
1614
|
-
|
|
1646
|
+
const documentosAgrupado = agruparRetorno(documentos);
|
|
1647
|
+
return documentosAgrupado;
|
|
1615
1648
|
} catch (error) {
|
|
1616
1649
|
console.log(error);
|
|
1617
1650
|
return null;
|
|
@@ -1736,14 +1769,14 @@ function getDigito4(texto) {
|
|
|
1736
1769
|
}
|
|
1737
1770
|
|
|
1738
1771
|
// src/banks/sicoob/gerarRemessa.ts
|
|
1739
|
-
var
|
|
1772
|
+
var import_date_fns8 = require("date-fns");
|
|
1740
1773
|
function gerarRemessa4({ dados }) {
|
|
1741
1774
|
try {
|
|
1742
1775
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
1743
1776
|
const arquivo = new Arquivo();
|
|
1744
1777
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
1745
|
-
const data = (0,
|
|
1746
|
-
const hora = (0,
|
|
1778
|
+
const data = (0, import_date_fns8.format)(dataAtual, "ddMMyyyy");
|
|
1779
|
+
const hora = (0, import_date_fns8.format)(dataAtual, "HHmmss");
|
|
1747
1780
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(6, "0")}.REM`;
|
|
1748
1781
|
arquivo.add("756");
|
|
1749
1782
|
arquivo.add("0000");
|
|
@@ -1796,7 +1829,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1796
1829
|
let total = 0;
|
|
1797
1830
|
for (const boleto of boletos) {
|
|
1798
1831
|
const { pagador } = boleto;
|
|
1799
|
-
const vencimento = (0,
|
|
1832
|
+
const vencimento = (0, import_date_fns8.format)(new Date(boleto.vencimento), "ddMMyyyy");
|
|
1800
1833
|
const valor_juros_dia = Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30;
|
|
1801
1834
|
let protesto = "3";
|
|
1802
1835
|
switch (dadosBancario.tipo_protesto) {
|
|
@@ -1840,7 +1873,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1840
1873
|
arquivo.add(boleto.aceite);
|
|
1841
1874
|
arquivo.add(data);
|
|
1842
1875
|
arquivo.add("1");
|
|
1843
|
-
arquivo.add((0,
|
|
1876
|
+
arquivo.add((0, import_date_fns8.format)((0, import_date_fns8.addDays)(new Date(boleto.vencimento), 1), "ddMMyyyy"));
|
|
1844
1877
|
arquivo.add(valor_juros_dia.toFixed(2).replace(".", "").padStart(15, "0"));
|
|
1845
1878
|
arquivo.add("0");
|
|
1846
1879
|
arquivo.add("00000000");
|
|
@@ -1890,7 +1923,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1890
1923
|
dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
|
|
1891
1924
|
if (dadosBancario.multaAtraso > 0) {
|
|
1892
1925
|
multa = "2";
|
|
1893
|
-
data_multa = (0,
|
|
1926
|
+
data_multa = (0, import_date_fns8.format)((0, import_date_fns8.addDays)(new Date(boleto.vencimento), 1), "ddMMyyyy");
|
|
1894
1927
|
valor_multa = dadosBancario.multaAtraso.toFixed(2).replace(".", "").padStart(15, "0");
|
|
1895
1928
|
}
|
|
1896
1929
|
arquivo.add("756");
|
|
@@ -2074,6 +2107,7 @@ function formatNossoNumero(parcela, nossoNumero) {
|
|
|
2074
2107
|
}
|
|
2075
2108
|
|
|
2076
2109
|
// src/banks/sicoob/gerarRetorno.ts
|
|
2110
|
+
var import_date_fns9 = require("date-fns");
|
|
2077
2111
|
function gerarRetorno4({ dados }) {
|
|
2078
2112
|
try {
|
|
2079
2113
|
const { arquivo } = dados;
|
|
@@ -2102,6 +2136,14 @@ function gerarRetorno4({ dados }) {
|
|
|
2102
2136
|
linha = arquivo[++i];
|
|
2103
2137
|
segmento = linha.substring(13, 14);
|
|
2104
2138
|
if (segmento === "U") {
|
|
2139
|
+
let dataCredito;
|
|
2140
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
2141
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
2142
|
+
dataCredito = (0, import_date_fns9.parse)(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2143
|
+
} else {
|
|
2144
|
+
const dataOcorrenciaString = linha.substring(137, 145);
|
|
2145
|
+
dataCredito = (0, import_date_fns9.parse)(dataOcorrenciaString, "ddMMyy", /* @__PURE__ */ new Date());
|
|
2146
|
+
}
|
|
2105
2147
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2106
2148
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2107
2149
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2120,13 +2162,15 @@ function gerarRetorno4({ dados }) {
|
|
|
2120
2162
|
valor_multa: valorMulta,
|
|
2121
2163
|
valor_juros: valorJuros,
|
|
2122
2164
|
valor_desconto: valorDesconto,
|
|
2123
|
-
valor_total: valorTotal
|
|
2165
|
+
valor_total: valorTotal,
|
|
2166
|
+
data: dataCredito
|
|
2124
2167
|
};
|
|
2125
2168
|
documentos.push(documento);
|
|
2126
2169
|
}
|
|
2127
2170
|
}
|
|
2128
2171
|
}
|
|
2129
|
-
|
|
2172
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2173
|
+
return documentoAgrupado;
|
|
2130
2174
|
} catch (error) {
|
|
2131
2175
|
console.log(error);
|
|
2132
2176
|
return null;
|
|
@@ -2376,7 +2420,7 @@ function gerarPDF5(_0) {
|
|
|
2376
2420
|
}
|
|
2377
2421
|
|
|
2378
2422
|
// src/banks/banco-brasil/gerarRemessa.ts
|
|
2379
|
-
var
|
|
2423
|
+
var import_date_fns10 = require("date-fns");
|
|
2380
2424
|
function gerarRemessa5({ dados }) {
|
|
2381
2425
|
try {
|
|
2382
2426
|
const {
|
|
@@ -2386,8 +2430,8 @@ function gerarRemessa5({ dados }) {
|
|
|
2386
2430
|
} = dados.remessa;
|
|
2387
2431
|
const arquivo = new Arquivo();
|
|
2388
2432
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
2389
|
-
const data = (0,
|
|
2390
|
-
const hora = (0,
|
|
2433
|
+
const data = (0, import_date_fns10.format)(dataAtual, "ddMMyyyy");
|
|
2434
|
+
const hora = (0, import_date_fns10.format)(dataAtual, "HHmmss");
|
|
2391
2435
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(5, "0")}.CNAB`;
|
|
2392
2436
|
arquivo.add("001");
|
|
2393
2437
|
arquivo.add("0000");
|
|
@@ -2487,7 +2531,7 @@ function gerarRemessa5({ dados }) {
|
|
|
2487
2531
|
const valorJurosDia = dadosBancario.jurosMes > 0 ? Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30 : 0;
|
|
2488
2532
|
const { pagador } = boleto;
|
|
2489
2533
|
const tipoInscricao = pagador.pessoa === "F" ? "1" : "2";
|
|
2490
|
-
const vencimento = (0,
|
|
2534
|
+
const vencimento = (0, import_date_fns10.format)(new Date(boleto.vencimento), "ddMMyyyy");
|
|
2491
2535
|
total += Number(boleto.valor);
|
|
2492
2536
|
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
2493
2537
|
const desconto = boleto.desconto > 0 ? boleto.desconto.toFixed(2) : dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
@@ -2650,6 +2694,7 @@ function gerarRemessa5({ dados }) {
|
|
|
2650
2694
|
}
|
|
2651
2695
|
|
|
2652
2696
|
// src/banks/banco-brasil/gerarRetorno.ts
|
|
2697
|
+
var import_date_fns11 = require("date-fns");
|
|
2653
2698
|
function gerarRetorno5({ dados }) {
|
|
2654
2699
|
try {
|
|
2655
2700
|
const { arquivo } = dados;
|
|
@@ -2678,6 +2723,14 @@ function gerarRetorno5({ dados }) {
|
|
|
2678
2723
|
linha = arquivo[++i];
|
|
2679
2724
|
segmento = linha.substring(13, 14);
|
|
2680
2725
|
if (segmento === "U") {
|
|
2726
|
+
let dataCredito;
|
|
2727
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
2728
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
2729
|
+
dataCredito = (0, import_date_fns11.parse)(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2730
|
+
} else {
|
|
2731
|
+
const dataOcorrenciaString = linha.substring(137, 145);
|
|
2732
|
+
dataCredito = (0, import_date_fns11.parse)(dataOcorrenciaString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2733
|
+
}
|
|
2681
2734
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2682
2735
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2683
2736
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2696,13 +2749,15 @@ function gerarRetorno5({ dados }) {
|
|
|
2696
2749
|
valor_multa: valorMulta,
|
|
2697
2750
|
valor_juros: valorJuros,
|
|
2698
2751
|
valor_desconto: valorDesconto,
|
|
2699
|
-
valor_total: valorTotal
|
|
2752
|
+
valor_total: valorTotal,
|
|
2753
|
+
data: dataCredito
|
|
2700
2754
|
};
|
|
2701
2755
|
documentos.push(documento);
|
|
2702
2756
|
}
|
|
2703
2757
|
}
|
|
2704
2758
|
}
|
|
2705
|
-
|
|
2759
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2760
|
+
return documentoAgrupado;
|
|
2706
2761
|
} catch (error) {
|
|
2707
2762
|
console.log(error);
|
|
2708
2763
|
return null;
|