@plasoft/boletos 1.0.57 → 1.0.58
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.mjs
CHANGED
|
@@ -620,6 +620,22 @@ function gerarRemessa({ dados }) {
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
+
// src/banks/ailos/gerarRetorno.ts
|
|
624
|
+
import { parse } from "date-fns";
|
|
625
|
+
|
|
626
|
+
// src/utils/agruparRetorno.ts
|
|
627
|
+
import { format as format2 } from "date-fns";
|
|
628
|
+
function agruparRetorno(documentos) {
|
|
629
|
+
return documentos.reduce((acc, documento) => {
|
|
630
|
+
const dataKey = format2(new Date(documento.data), "yyyy-MM-dd");
|
|
631
|
+
if (!acc[dataKey]) {
|
|
632
|
+
acc[dataKey] = [];
|
|
633
|
+
}
|
|
634
|
+
acc[dataKey].push(documento);
|
|
635
|
+
return acc;
|
|
636
|
+
}, {});
|
|
637
|
+
}
|
|
638
|
+
|
|
623
639
|
// src/banks/ailos/gerarRetorno.ts
|
|
624
640
|
function gerarRetorno({ dados }) {
|
|
625
641
|
try {
|
|
@@ -645,6 +661,14 @@ function gerarRetorno({ dados }) {
|
|
|
645
661
|
linha = arquivo[index + 1];
|
|
646
662
|
segmento = linha.substring(13, 14);
|
|
647
663
|
if (segmento === "U") {
|
|
664
|
+
let dataCredito;
|
|
665
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
666
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
667
|
+
dataCredito = parse(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
668
|
+
} else {
|
|
669
|
+
const dataOcorrenciaString = linha.substring(157, 165);
|
|
670
|
+
dataCredito = parse(dataOcorrenciaString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
671
|
+
}
|
|
648
672
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
649
673
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
650
674
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -663,7 +687,8 @@ function gerarRetorno({ dados }) {
|
|
|
663
687
|
valor_multa: valorMulta,
|
|
664
688
|
valor_juros: valorJuros,
|
|
665
689
|
valor_desconto: valorDesconto,
|
|
666
|
-
valor_total: valorTotal
|
|
690
|
+
valor_total: valorTotal,
|
|
691
|
+
data: dataCredito
|
|
667
692
|
};
|
|
668
693
|
documentos.push(documento);
|
|
669
694
|
}
|
|
@@ -671,7 +696,8 @@ function gerarRetorno({ dados }) {
|
|
|
671
696
|
}
|
|
672
697
|
index++;
|
|
673
698
|
}
|
|
674
|
-
|
|
699
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
700
|
+
return documentoAgrupado;
|
|
675
701
|
} catch (error) {
|
|
676
702
|
console.log(error);
|
|
677
703
|
return null;
|
|
@@ -861,15 +887,15 @@ function gerarPDF2(_0) {
|
|
|
861
887
|
}
|
|
862
888
|
|
|
863
889
|
// src/banks/bradesco/gerarRemessa.ts
|
|
864
|
-
import { addDays as addDays2, format as
|
|
890
|
+
import { addDays as addDays2, format as format3 } from "date-fns";
|
|
865
891
|
function gerarRemessa2(_0) {
|
|
866
892
|
return __async(this, arguments, function* ({ dados }) {
|
|
867
893
|
try {
|
|
868
894
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
869
895
|
const arquivo = new Arquivo();
|
|
870
896
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
871
|
-
const data =
|
|
872
|
-
const hora =
|
|
897
|
+
const data = format3(dataAtual, "ddMMyyyy");
|
|
898
|
+
const hora = format3(dataAtual, "HHmmss");
|
|
873
899
|
const convenio = dadosBancario.convenio.padStart(7, "0");
|
|
874
900
|
const numero = dadosBancario.conta.padStart(7, "0") + dadosBancario.contaDigito;
|
|
875
901
|
const remessa2 = `REM${convenio}-${numero}-${data}.REM`;
|
|
@@ -927,11 +953,11 @@ function gerarRemessa2(_0) {
|
|
|
927
953
|
let total = 0;
|
|
928
954
|
for (const boleto of boletos) {
|
|
929
955
|
const { pagador } = boleto;
|
|
930
|
-
const vencimento =
|
|
956
|
+
const vencimento = format3(new Date(boleto.vencimento), "ddMMyyyy");
|
|
931
957
|
total += Number(boleto.valor);
|
|
932
958
|
const codigoJuro = dadosBancario.jurosMes > 0 ? "2" : "3";
|
|
933
959
|
const juros = dadosBancario.jurosMes > 0 ? dadosBancario.jurosMes.toFixed(2) : "000000000000000";
|
|
934
|
-
const jurosVencimento =
|
|
960
|
+
const jurosVencimento = format3(
|
|
935
961
|
addDays2(new Date(boleto.vencimento), 1),
|
|
936
962
|
"ddMMyyyy"
|
|
937
963
|
);
|
|
@@ -1130,7 +1156,8 @@ function gerarRetorno2({ dados }) {
|
|
|
1130
1156
|
valor_desconto: 0,
|
|
1131
1157
|
valor_juros: 0,
|
|
1132
1158
|
valor_multa: 0,
|
|
1133
|
-
valor_total: 0
|
|
1159
|
+
valor_total: 0,
|
|
1160
|
+
data: /* @__PURE__ */ new Date()
|
|
1134
1161
|
};
|
|
1135
1162
|
documentos.push(documento);
|
|
1136
1163
|
}
|
|
@@ -1138,7 +1165,8 @@ function gerarRetorno2({ dados }) {
|
|
|
1138
1165
|
}
|
|
1139
1166
|
index++;
|
|
1140
1167
|
}
|
|
1141
|
-
|
|
1168
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
1169
|
+
return documentoAgrupado;
|
|
1142
1170
|
} catch (error) {
|
|
1143
1171
|
console.log(error);
|
|
1144
1172
|
return null;
|
|
@@ -1291,15 +1319,9 @@ function gerarPDF3(_0) {
|
|
|
1291
1319
|
if (!dadosPDF.pagador.cpfcnpj) {
|
|
1292
1320
|
throw new Error("CPF/CNPJ do pagador na\u0303o informado!");
|
|
1293
1321
|
}
|
|
1294
|
-
const codigoBarraText = dadosPDF.boleto.codigoBarra.replace(/\D/g, "");
|
|
1295
|
-
if (!/^\d+$/.test(codigoBarraText)) {
|
|
1296
|
-
throw new Error("C\xF3digo de barras cont\xE9m caracteres inv\xE1lidos. Apenas d\xEDgitos s\xE3o permitidos.");
|
|
1297
|
-
}
|
|
1298
|
-
console.log(dadosPDF.boleto.codigoBarra);
|
|
1299
|
-
console.log(codigoBarraText);
|
|
1300
1322
|
const codigoBarra2 = yield BwipJs3.toBuffer({
|
|
1301
1323
|
bcid: "interleaved2of5",
|
|
1302
|
-
text:
|
|
1324
|
+
text: dadosPDF.boleto.codigoBarra,
|
|
1303
1325
|
height: 20
|
|
1304
1326
|
});
|
|
1305
1327
|
dadosPDF.beneficiario.dadosBancario.agencia = dadosPDF.beneficiario.dadosBancario.agencia.padStart(4, "0");
|
|
@@ -1393,7 +1415,7 @@ function gerarPDF3(_0) {
|
|
|
1393
1415
|
}
|
|
1394
1416
|
|
|
1395
1417
|
// src/banks/sicredi/gerarRemessa.ts
|
|
1396
|
-
import { format as
|
|
1418
|
+
import { format as format4 } from "date-fns";
|
|
1397
1419
|
function gerarRemessa3({ dados }) {
|
|
1398
1420
|
try {
|
|
1399
1421
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
@@ -1427,7 +1449,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1427
1449
|
arquivo.add(" ".padEnd(31, " "));
|
|
1428
1450
|
arquivo.add("748");
|
|
1429
1451
|
arquivo.add("SICREDI".padEnd(15, " "));
|
|
1430
|
-
arquivo.add(
|
|
1452
|
+
arquivo.add(format4(data, "yyyyMMdd"));
|
|
1431
1453
|
arquivo.add(" ".padEnd(8, " "));
|
|
1432
1454
|
arquivo.add(dadosBancario.numeroRemessa.padStart(7, "0"));
|
|
1433
1455
|
arquivo.add(" ".padEnd(273, " "));
|
|
@@ -1444,11 +1466,11 @@ function gerarRemessa3({ dados }) {
|
|
|
1444
1466
|
let dataDesconto = "000000";
|
|
1445
1467
|
if (boleto.desconto) {
|
|
1446
1468
|
desconto = boleto.desconto.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1447
|
-
dataDesconto =
|
|
1469
|
+
dataDesconto = format4(new Date(boleto.vencimento), "ddMMyy");
|
|
1448
1470
|
}
|
|
1449
1471
|
if (!boleto.desconto && dadosBancario.descontoPagamento) {
|
|
1450
1472
|
desconto = dadosBancario.descontoPagamento.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1451
|
-
dataDesconto =
|
|
1473
|
+
dataDesconto = format4(new Date(boleto.vencimento), "ddMMyy");
|
|
1452
1474
|
}
|
|
1453
1475
|
let valorJurosDias = Number(boleto.valor) * Number(dadosBancario.jurosMes) / 100 / 30;
|
|
1454
1476
|
let multaAtraso = String(dadosBancario.multaAtraso * 100);
|
|
@@ -1459,7 +1481,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1459
1481
|
arquivo.add(" ".padEnd(28, " "));
|
|
1460
1482
|
arquivo.add(boleto.nossoNumero.padEnd(9, " "));
|
|
1461
1483
|
arquivo.add(" ".padEnd(6, " "));
|
|
1462
|
-
arquivo.add(
|
|
1484
|
+
arquivo.add(format4(new Date(boleto.emissao), "yyyyMMdd"));
|
|
1463
1485
|
arquivo.add(" ");
|
|
1464
1486
|
arquivo.add("N");
|
|
1465
1487
|
arquivo.add(" ");
|
|
@@ -1471,12 +1493,12 @@ function gerarRemessa3({ dados }) {
|
|
|
1471
1493
|
arquivo.add(" ".padEnd(12, " "));
|
|
1472
1494
|
arquivo.add("01");
|
|
1473
1495
|
arquivo.add(boleto.identificacaoTitulo.padEnd(10, " "));
|
|
1474
|
-
arquivo.add(
|
|
1496
|
+
arquivo.add(format4(new Date(boleto.vencimento), "ddMMyy"));
|
|
1475
1497
|
arquivo.add(Number(boleto.valor).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
1476
1498
|
arquivo.add(" ".padEnd(9, " "));
|
|
1477
1499
|
arquivo.add("A");
|
|
1478
1500
|
arquivo.add(boleto.aceite);
|
|
1479
|
-
arquivo.add(
|
|
1501
|
+
arquivo.add(format4(new Date(boleto.emissao), "ddMMyy"));
|
|
1480
1502
|
arquivo.add(protestar);
|
|
1481
1503
|
arquivo.add(String(dadosBancario.diasProtesto).padStart(2, "0"));
|
|
1482
1504
|
arquivo.add(Number(valorJurosDias).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
@@ -1504,7 +1526,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1504
1526
|
arquivo.add(String(sequencia).padStart(6, "0"));
|
|
1505
1527
|
arquivo.addLine();
|
|
1506
1528
|
return {
|
|
1507
|
-
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${
|
|
1529
|
+
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${format4(data, "dd")}.crm`,
|
|
1508
1530
|
arquivo: arquivo.getArquivo()
|
|
1509
1531
|
};
|
|
1510
1532
|
} catch (error) {
|
|
@@ -1527,6 +1549,7 @@ function retornaMes(data) {
|
|
|
1527
1549
|
}
|
|
1528
1550
|
|
|
1529
1551
|
// src/banks/sicredi/gerarRetorno.ts
|
|
1552
|
+
import { parse as parse2 } from "date-fns";
|
|
1530
1553
|
function gerarRetorno3({ dados }) {
|
|
1531
1554
|
try {
|
|
1532
1555
|
const { arquivo } = dados;
|
|
@@ -1552,6 +1575,14 @@ function gerarRetorno3({ dados }) {
|
|
|
1552
1575
|
if (tipo_documento.length) {
|
|
1553
1576
|
especie = tipo_documento === "N" ? "NFE" : tipo_documento === "F" ? "FAT" : tipo_documento === "L" ? "FIN" : "INDEFINIDO";
|
|
1554
1577
|
}
|
|
1578
|
+
let dataCredito;
|
|
1579
|
+
const dataCreditoString = linha.substring(328, 336);
|
|
1580
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
1581
|
+
dataCredito = parse2(dataCreditoString, "yyyyMMdd", /* @__PURE__ */ new Date());
|
|
1582
|
+
} else {
|
|
1583
|
+
const dataOcorrenciaString = linha.substring(110, 116);
|
|
1584
|
+
dataCredito = parse2(dataOcorrenciaString, "ddMMyy", /* @__PURE__ */ new Date());
|
|
1585
|
+
}
|
|
1555
1586
|
const valor_titulo = Number(linha.substring(152, 165)) / 100;
|
|
1556
1587
|
const abatimento = Number(linha.substring(227, 240)) / 100;
|
|
1557
1588
|
let valor_desconto = Number(linha.substring(240, 253)) / 100;
|
|
@@ -1573,10 +1604,12 @@ function gerarRetorno3({ dados }) {
|
|
|
1573
1604
|
valor_multa,
|
|
1574
1605
|
valor_juros,
|
|
1575
1606
|
valor_desconto,
|
|
1576
|
-
valor_total
|
|
1607
|
+
valor_total,
|
|
1608
|
+
data: dataCredito
|
|
1577
1609
|
});
|
|
1578
1610
|
}
|
|
1579
|
-
|
|
1611
|
+
const documentosAgrupado = agruparRetorno(documentos);
|
|
1612
|
+
return documentosAgrupado;
|
|
1580
1613
|
} catch (error) {
|
|
1581
1614
|
console.log(error);
|
|
1582
1615
|
return null;
|
|
@@ -1701,14 +1734,14 @@ function getDigito4(texto) {
|
|
|
1701
1734
|
}
|
|
1702
1735
|
|
|
1703
1736
|
// src/banks/sicoob/gerarRemessa.ts
|
|
1704
|
-
import { addDays as addDays3, format as
|
|
1737
|
+
import { addDays as addDays3, format as format5 } from "date-fns";
|
|
1705
1738
|
function gerarRemessa4({ dados }) {
|
|
1706
1739
|
try {
|
|
1707
1740
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
1708
1741
|
const arquivo = new Arquivo();
|
|
1709
1742
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
1710
|
-
const data =
|
|
1711
|
-
const hora =
|
|
1743
|
+
const data = format5(dataAtual, "ddMMyyyy");
|
|
1744
|
+
const hora = format5(dataAtual, "HHmmss");
|
|
1712
1745
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(6, "0")}.REM`;
|
|
1713
1746
|
arquivo.add("756");
|
|
1714
1747
|
arquivo.add("0000");
|
|
@@ -1761,7 +1794,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1761
1794
|
let total = 0;
|
|
1762
1795
|
for (const boleto of boletos) {
|
|
1763
1796
|
const { pagador } = boleto;
|
|
1764
|
-
const vencimento =
|
|
1797
|
+
const vencimento = format5(new Date(boleto.vencimento), "ddMMyyyy");
|
|
1765
1798
|
const valor_juros_dia = Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30;
|
|
1766
1799
|
let protesto = "3";
|
|
1767
1800
|
switch (dadosBancario.tipo_protesto) {
|
|
@@ -1805,7 +1838,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1805
1838
|
arquivo.add(boleto.aceite);
|
|
1806
1839
|
arquivo.add(data);
|
|
1807
1840
|
arquivo.add("1");
|
|
1808
|
-
arquivo.add(
|
|
1841
|
+
arquivo.add(format5(addDays3(new Date(boleto.vencimento), 1), "ddMMyyyy"));
|
|
1809
1842
|
arquivo.add(valor_juros_dia.toFixed(2).replace(".", "").padStart(15, "0"));
|
|
1810
1843
|
arquivo.add("0");
|
|
1811
1844
|
arquivo.add("00000000");
|
|
@@ -1855,7 +1888,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1855
1888
|
dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
|
|
1856
1889
|
if (dadosBancario.multaAtraso > 0) {
|
|
1857
1890
|
multa = "2";
|
|
1858
|
-
data_multa =
|
|
1891
|
+
data_multa = format5(addDays3(new Date(boleto.vencimento), 1), "ddMMyyyy");
|
|
1859
1892
|
valor_multa = dadosBancario.multaAtraso.toFixed(2).replace(".", "").padStart(15, "0");
|
|
1860
1893
|
}
|
|
1861
1894
|
arquivo.add("756");
|
|
@@ -2039,6 +2072,7 @@ function formatNossoNumero(parcela, nossoNumero) {
|
|
|
2039
2072
|
}
|
|
2040
2073
|
|
|
2041
2074
|
// src/banks/sicoob/gerarRetorno.ts
|
|
2075
|
+
import { parse as parse3 } from "date-fns";
|
|
2042
2076
|
function gerarRetorno4({ dados }) {
|
|
2043
2077
|
try {
|
|
2044
2078
|
const { arquivo } = dados;
|
|
@@ -2067,6 +2101,14 @@ function gerarRetorno4({ dados }) {
|
|
|
2067
2101
|
linha = arquivo[++i];
|
|
2068
2102
|
segmento = linha.substring(13, 14);
|
|
2069
2103
|
if (segmento === "U") {
|
|
2104
|
+
let dataCredito;
|
|
2105
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
2106
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
2107
|
+
dataCredito = parse3(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2108
|
+
} else {
|
|
2109
|
+
const dataOcorrenciaString = linha.substring(137, 145);
|
|
2110
|
+
dataCredito = parse3(dataOcorrenciaString, "ddMMyy", /* @__PURE__ */ new Date());
|
|
2111
|
+
}
|
|
2070
2112
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2071
2113
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2072
2114
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2085,13 +2127,15 @@ function gerarRetorno4({ dados }) {
|
|
|
2085
2127
|
valor_multa: valorMulta,
|
|
2086
2128
|
valor_juros: valorJuros,
|
|
2087
2129
|
valor_desconto: valorDesconto,
|
|
2088
|
-
valor_total: valorTotal
|
|
2130
|
+
valor_total: valorTotal,
|
|
2131
|
+
data: dataCredito
|
|
2089
2132
|
};
|
|
2090
2133
|
documentos.push(documento);
|
|
2091
2134
|
}
|
|
2092
2135
|
}
|
|
2093
2136
|
}
|
|
2094
|
-
|
|
2137
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2138
|
+
return documentoAgrupado;
|
|
2095
2139
|
} catch (error) {
|
|
2096
2140
|
console.log(error);
|
|
2097
2141
|
return null;
|
|
@@ -2341,7 +2385,7 @@ function gerarPDF5(_0) {
|
|
|
2341
2385
|
}
|
|
2342
2386
|
|
|
2343
2387
|
// src/banks/banco-brasil/gerarRemessa.ts
|
|
2344
|
-
import { format as
|
|
2388
|
+
import { format as format6 } from "date-fns";
|
|
2345
2389
|
function gerarRemessa5({ dados }) {
|
|
2346
2390
|
try {
|
|
2347
2391
|
const {
|
|
@@ -2351,8 +2395,8 @@ function gerarRemessa5({ dados }) {
|
|
|
2351
2395
|
} = dados.remessa;
|
|
2352
2396
|
const arquivo = new Arquivo();
|
|
2353
2397
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
2354
|
-
const data =
|
|
2355
|
-
const hora =
|
|
2398
|
+
const data = format6(dataAtual, "ddMMyyyy");
|
|
2399
|
+
const hora = format6(dataAtual, "HHmmss");
|
|
2356
2400
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(5, "0")}.CNAB`;
|
|
2357
2401
|
arquivo.add("001");
|
|
2358
2402
|
arquivo.add("0000");
|
|
@@ -2452,7 +2496,7 @@ function gerarRemessa5({ dados }) {
|
|
|
2452
2496
|
const valorJurosDia = dadosBancario.jurosMes > 0 ? Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30 : 0;
|
|
2453
2497
|
const { pagador } = boleto;
|
|
2454
2498
|
const tipoInscricao = pagador.pessoa === "F" ? "1" : "2";
|
|
2455
|
-
const vencimento =
|
|
2499
|
+
const vencimento = format6(new Date(boleto.vencimento), "ddMMyyyy");
|
|
2456
2500
|
total += Number(boleto.valor);
|
|
2457
2501
|
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
2458
2502
|
const desconto = boleto.desconto > 0 ? boleto.desconto.toFixed(2) : dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
@@ -2615,6 +2659,7 @@ function gerarRemessa5({ dados }) {
|
|
|
2615
2659
|
}
|
|
2616
2660
|
|
|
2617
2661
|
// src/banks/banco-brasil/gerarRetorno.ts
|
|
2662
|
+
import { parse as parse4 } from "date-fns";
|
|
2618
2663
|
function gerarRetorno5({ dados }) {
|
|
2619
2664
|
try {
|
|
2620
2665
|
const { arquivo } = dados;
|
|
@@ -2643,6 +2688,14 @@ function gerarRetorno5({ dados }) {
|
|
|
2643
2688
|
linha = arquivo[++i];
|
|
2644
2689
|
segmento = linha.substring(13, 14);
|
|
2645
2690
|
if (segmento === "U") {
|
|
2691
|
+
let dataCredito;
|
|
2692
|
+
const dataCreditoString = linha.substring(145, 153);
|
|
2693
|
+
if (dataCreditoString && dataCreditoString !== "00000000") {
|
|
2694
|
+
dataCredito = parse4(dataCreditoString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2695
|
+
} else {
|
|
2696
|
+
const dataOcorrenciaString = linha.substring(137, 145);
|
|
2697
|
+
dataCredito = parse4(dataOcorrenciaString, "ddMMyyyy", /* @__PURE__ */ new Date());
|
|
2698
|
+
}
|
|
2646
2699
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2647
2700
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2648
2701
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2661,13 +2714,15 @@ function gerarRetorno5({ dados }) {
|
|
|
2661
2714
|
valor_multa: valorMulta,
|
|
2662
2715
|
valor_juros: valorJuros,
|
|
2663
2716
|
valor_desconto: valorDesconto,
|
|
2664
|
-
valor_total: valorTotal
|
|
2717
|
+
valor_total: valorTotal,
|
|
2718
|
+
data: dataCredito
|
|
2665
2719
|
};
|
|
2666
2720
|
documentos.push(documento);
|
|
2667
2721
|
}
|
|
2668
2722
|
}
|
|
2669
2723
|
}
|
|
2670
|
-
|
|
2724
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2725
|
+
return documentoAgrupado;
|
|
2671
2726
|
} catch (error) {
|
|
2672
2727
|
console.log(error);
|
|
2673
2728
|
return null;
|