@plasoft/boletos 1.0.56 → 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 +8 -1
- package/build/index.d.ts +8 -1
- package/build/index.js +108 -41
- package/build/index.js.map +1 -1
- package/build/index.mjs +107 -40
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
package/build/index.mjs
CHANGED
|
@@ -287,7 +287,7 @@ function gerarPDF(_0) {
|
|
|
287
287
|
if (jurosDia > 0) {
|
|
288
288
|
dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${maskFormat_default.numberToReal(jurosDia)} AO DIA, AP\xD3S O VENCIMENTO`;
|
|
289
289
|
}
|
|
290
|
-
const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto
|
|
290
|
+
const descontoVencimento = dadosPDF.boleto.desconto > 0 ? dadosPDF.boleto.desconto : dadosPDF.beneficiario.dadosBancario.desconto > 0 ? dadosPDF.beneficiario.dadosBancario.desconto : 0;
|
|
291
291
|
if (descontoVencimento > 0) {
|
|
292
292
|
dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
|
|
293
293
|
}
|
|
@@ -454,7 +454,7 @@ function gerarRemessa({ dados }) {
|
|
|
454
454
|
"ddMMyyyy"
|
|
455
455
|
);
|
|
456
456
|
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
457
|
-
const desconto = dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
457
|
+
const desconto = boleto.desconto > 0 ? boleto.desconto.toFixed(2) : dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
458
458
|
let diasProtesto = "00";
|
|
459
459
|
let protesto = "3";
|
|
460
460
|
switch (dadosBancario.tipo_protesto) {
|
|
@@ -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;
|
|
@@ -1334,7 +1362,7 @@ function gerarPDF3(_0) {
|
|
|
1334
1362
|
if (jurosDia > 0) {
|
|
1335
1363
|
dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${maskFormat_default.numberToReal(jurosDia)} AO DIA, AP\xD3S O VENCIMENTO`;
|
|
1336
1364
|
}
|
|
1337
|
-
const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto
|
|
1365
|
+
const descontoVencimento = dadosPDF.boleto.desconto > 0 ? dadosPDF.boleto.desconto : dadosPDF.beneficiario.dadosBancario.desconto > 0 ? dadosPDF.beneficiario.dadosBancario.desconto : 0;
|
|
1338
1366
|
if (descontoVencimento > 0) {
|
|
1339
1367
|
dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
|
|
1340
1368
|
}
|
|
@@ -1387,7 +1415,7 @@ function gerarPDF3(_0) {
|
|
|
1387
1415
|
}
|
|
1388
1416
|
|
|
1389
1417
|
// src/banks/sicredi/gerarRemessa.ts
|
|
1390
|
-
import { format as
|
|
1418
|
+
import { format as format4 } from "date-fns";
|
|
1391
1419
|
function gerarRemessa3({ dados }) {
|
|
1392
1420
|
try {
|
|
1393
1421
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
@@ -1421,7 +1449,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1421
1449
|
arquivo.add(" ".padEnd(31, " "));
|
|
1422
1450
|
arquivo.add("748");
|
|
1423
1451
|
arquivo.add("SICREDI".padEnd(15, " "));
|
|
1424
|
-
arquivo.add(
|
|
1452
|
+
arquivo.add(format4(data, "yyyyMMdd"));
|
|
1425
1453
|
arquivo.add(" ".padEnd(8, " "));
|
|
1426
1454
|
arquivo.add(dadosBancario.numeroRemessa.padStart(7, "0"));
|
|
1427
1455
|
arquivo.add(" ".padEnd(273, " "));
|
|
@@ -1436,9 +1464,13 @@ function gerarRemessa3({ dados }) {
|
|
|
1436
1464
|
let tipoInscricao = pagador.pessoa === "F" ? "1" : "2";
|
|
1437
1465
|
let desconto = "0000000000000";
|
|
1438
1466
|
let dataDesconto = "000000";
|
|
1439
|
-
if (
|
|
1467
|
+
if (boleto.desconto) {
|
|
1468
|
+
desconto = boleto.desconto.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1469
|
+
dataDesconto = format4(new Date(boleto.vencimento), "ddMMyy");
|
|
1470
|
+
}
|
|
1471
|
+
if (!boleto.desconto && dadosBancario.descontoPagamento) {
|
|
1440
1472
|
desconto = dadosBancario.descontoPagamento.toFixed(2).replace(".", "").padStart(13, "0");
|
|
1441
|
-
dataDesconto =
|
|
1473
|
+
dataDesconto = format4(new Date(boleto.vencimento), "ddMMyy");
|
|
1442
1474
|
}
|
|
1443
1475
|
let valorJurosDias = Number(boleto.valor) * Number(dadosBancario.jurosMes) / 100 / 30;
|
|
1444
1476
|
let multaAtraso = String(dadosBancario.multaAtraso * 100);
|
|
@@ -1449,7 +1481,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1449
1481
|
arquivo.add(" ".padEnd(28, " "));
|
|
1450
1482
|
arquivo.add(boleto.nossoNumero.padEnd(9, " "));
|
|
1451
1483
|
arquivo.add(" ".padEnd(6, " "));
|
|
1452
|
-
arquivo.add(
|
|
1484
|
+
arquivo.add(format4(new Date(boleto.emissao), "yyyyMMdd"));
|
|
1453
1485
|
arquivo.add(" ");
|
|
1454
1486
|
arquivo.add("N");
|
|
1455
1487
|
arquivo.add(" ");
|
|
@@ -1461,12 +1493,12 @@ function gerarRemessa3({ dados }) {
|
|
|
1461
1493
|
arquivo.add(" ".padEnd(12, " "));
|
|
1462
1494
|
arquivo.add("01");
|
|
1463
1495
|
arquivo.add(boleto.identificacaoTitulo.padEnd(10, " "));
|
|
1464
|
-
arquivo.add(
|
|
1496
|
+
arquivo.add(format4(new Date(boleto.vencimento), "ddMMyy"));
|
|
1465
1497
|
arquivo.add(Number(boleto.valor).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
1466
1498
|
arquivo.add(" ".padEnd(9, " "));
|
|
1467
1499
|
arquivo.add("A");
|
|
1468
1500
|
arquivo.add(boleto.aceite);
|
|
1469
|
-
arquivo.add(
|
|
1501
|
+
arquivo.add(format4(new Date(boleto.emissao), "ddMMyy"));
|
|
1470
1502
|
arquivo.add(protestar);
|
|
1471
1503
|
arquivo.add(String(dadosBancario.diasProtesto).padStart(2, "0"));
|
|
1472
1504
|
arquivo.add(Number(valorJurosDias).toFixed(2).replace(".", "").padStart(13, "0"));
|
|
@@ -1494,7 +1526,7 @@ function gerarRemessa3({ dados }) {
|
|
|
1494
1526
|
arquivo.add(String(sequencia).padStart(6, "0"));
|
|
1495
1527
|
arquivo.addLine();
|
|
1496
1528
|
return {
|
|
1497
|
-
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${
|
|
1529
|
+
download: `${dadosBancario.codigo_cedente}${retornaMes(data)}${format4(data, "dd")}.crm`,
|
|
1498
1530
|
arquivo: arquivo.getArquivo()
|
|
1499
1531
|
};
|
|
1500
1532
|
} catch (error) {
|
|
@@ -1517,6 +1549,7 @@ function retornaMes(data) {
|
|
|
1517
1549
|
}
|
|
1518
1550
|
|
|
1519
1551
|
// src/banks/sicredi/gerarRetorno.ts
|
|
1552
|
+
import { parse as parse2 } from "date-fns";
|
|
1520
1553
|
function gerarRetorno3({ dados }) {
|
|
1521
1554
|
try {
|
|
1522
1555
|
const { arquivo } = dados;
|
|
@@ -1542,6 +1575,14 @@ function gerarRetorno3({ dados }) {
|
|
|
1542
1575
|
if (tipo_documento.length) {
|
|
1543
1576
|
especie = tipo_documento === "N" ? "NFE" : tipo_documento === "F" ? "FAT" : tipo_documento === "L" ? "FIN" : "INDEFINIDO";
|
|
1544
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
|
+
}
|
|
1545
1586
|
const valor_titulo = Number(linha.substring(152, 165)) / 100;
|
|
1546
1587
|
const abatimento = Number(linha.substring(227, 240)) / 100;
|
|
1547
1588
|
let valor_desconto = Number(linha.substring(240, 253)) / 100;
|
|
@@ -1563,10 +1604,12 @@ function gerarRetorno3({ dados }) {
|
|
|
1563
1604
|
valor_multa,
|
|
1564
1605
|
valor_juros,
|
|
1565
1606
|
valor_desconto,
|
|
1566
|
-
valor_total
|
|
1607
|
+
valor_total,
|
|
1608
|
+
data: dataCredito
|
|
1567
1609
|
});
|
|
1568
1610
|
}
|
|
1569
|
-
|
|
1611
|
+
const documentosAgrupado = agruparRetorno(documentos);
|
|
1612
|
+
return documentosAgrupado;
|
|
1570
1613
|
} catch (error) {
|
|
1571
1614
|
console.log(error);
|
|
1572
1615
|
return null;
|
|
@@ -1691,14 +1734,14 @@ function getDigito4(texto) {
|
|
|
1691
1734
|
}
|
|
1692
1735
|
|
|
1693
1736
|
// src/banks/sicoob/gerarRemessa.ts
|
|
1694
|
-
import { addDays as addDays3, format as
|
|
1737
|
+
import { addDays as addDays3, format as format5 } from "date-fns";
|
|
1695
1738
|
function gerarRemessa4({ dados }) {
|
|
1696
1739
|
try {
|
|
1697
1740
|
const { dadosBancario, beneficiario, boletos } = dados.remessa;
|
|
1698
1741
|
const arquivo = new Arquivo();
|
|
1699
1742
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
1700
|
-
const data =
|
|
1701
|
-
const hora =
|
|
1743
|
+
const data = format5(dataAtual, "ddMMyyyy");
|
|
1744
|
+
const hora = format5(dataAtual, "HHmmss");
|
|
1702
1745
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(6, "0")}.REM`;
|
|
1703
1746
|
arquivo.add("756");
|
|
1704
1747
|
arquivo.add("0000");
|
|
@@ -1751,7 +1794,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1751
1794
|
let total = 0;
|
|
1752
1795
|
for (const boleto of boletos) {
|
|
1753
1796
|
const { pagador } = boleto;
|
|
1754
|
-
const vencimento =
|
|
1797
|
+
const vencimento = format5(new Date(boleto.vencimento), "ddMMyyyy");
|
|
1755
1798
|
const valor_juros_dia = Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30;
|
|
1756
1799
|
let protesto = "3";
|
|
1757
1800
|
switch (dadosBancario.tipo_protesto) {
|
|
@@ -1795,7 +1838,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1795
1838
|
arquivo.add(boleto.aceite);
|
|
1796
1839
|
arquivo.add(data);
|
|
1797
1840
|
arquivo.add("1");
|
|
1798
|
-
arquivo.add(
|
|
1841
|
+
arquivo.add(format5(addDays3(new Date(boleto.vencimento), 1), "ddMMyyyy"));
|
|
1799
1842
|
arquivo.add(valor_juros_dia.toFixed(2).replace(".", "").padStart(15, "0"));
|
|
1800
1843
|
arquivo.add("0");
|
|
1801
1844
|
arquivo.add("00000000");
|
|
@@ -1845,7 +1888,7 @@ function gerarRemessa4({ dados }) {
|
|
|
1845
1888
|
dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
|
|
1846
1889
|
if (dadosBancario.multaAtraso > 0) {
|
|
1847
1890
|
multa = "2";
|
|
1848
|
-
data_multa =
|
|
1891
|
+
data_multa = format5(addDays3(new Date(boleto.vencimento), 1), "ddMMyyyy");
|
|
1849
1892
|
valor_multa = dadosBancario.multaAtraso.toFixed(2).replace(".", "").padStart(15, "0");
|
|
1850
1893
|
}
|
|
1851
1894
|
arquivo.add("756");
|
|
@@ -2029,6 +2072,7 @@ function formatNossoNumero(parcela, nossoNumero) {
|
|
|
2029
2072
|
}
|
|
2030
2073
|
|
|
2031
2074
|
// src/banks/sicoob/gerarRetorno.ts
|
|
2075
|
+
import { parse as parse3 } from "date-fns";
|
|
2032
2076
|
function gerarRetorno4({ dados }) {
|
|
2033
2077
|
try {
|
|
2034
2078
|
const { arquivo } = dados;
|
|
@@ -2057,6 +2101,14 @@ function gerarRetorno4({ dados }) {
|
|
|
2057
2101
|
linha = arquivo[++i];
|
|
2058
2102
|
segmento = linha.substring(13, 14);
|
|
2059
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
|
+
}
|
|
2060
2112
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2061
2113
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2062
2114
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2075,13 +2127,15 @@ function gerarRetorno4({ dados }) {
|
|
|
2075
2127
|
valor_multa: valorMulta,
|
|
2076
2128
|
valor_juros: valorJuros,
|
|
2077
2129
|
valor_desconto: valorDesconto,
|
|
2078
|
-
valor_total: valorTotal
|
|
2130
|
+
valor_total: valorTotal,
|
|
2131
|
+
data: dataCredito
|
|
2079
2132
|
};
|
|
2080
2133
|
documentos.push(documento);
|
|
2081
2134
|
}
|
|
2082
2135
|
}
|
|
2083
2136
|
}
|
|
2084
|
-
|
|
2137
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2138
|
+
return documentoAgrupado;
|
|
2085
2139
|
} catch (error) {
|
|
2086
2140
|
console.log(error);
|
|
2087
2141
|
return null;
|
|
@@ -2282,7 +2336,7 @@ function gerarPDF5(_0) {
|
|
|
2282
2336
|
if (jurosDia > 0) {
|
|
2283
2337
|
dadosPDF.boleto.instrucao1 = `COBRAR JUROS DE R$${jurosDia} AO DIA, AP\xD3S O VENCIMENTO`;
|
|
2284
2338
|
}
|
|
2285
|
-
const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto
|
|
2339
|
+
const descontoVencimento = dadosPDF.boleto.desconto > 0 ? dadosPDF.boleto.desconto : dadosPDF.beneficiario.dadosBancario.desconto > 0 ? dadosPDF.beneficiario.dadosBancario.desconto : 0;
|
|
2286
2340
|
if (descontoVencimento > 0) {
|
|
2287
2341
|
dadosPDF.boleto.instrucao2 = `AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`;
|
|
2288
2342
|
}
|
|
@@ -2331,7 +2385,7 @@ function gerarPDF5(_0) {
|
|
|
2331
2385
|
}
|
|
2332
2386
|
|
|
2333
2387
|
// src/banks/banco-brasil/gerarRemessa.ts
|
|
2334
|
-
import { format as
|
|
2388
|
+
import { format as format6 } from "date-fns";
|
|
2335
2389
|
function gerarRemessa5({ dados }) {
|
|
2336
2390
|
try {
|
|
2337
2391
|
const {
|
|
@@ -2341,8 +2395,8 @@ function gerarRemessa5({ dados }) {
|
|
|
2341
2395
|
} = dados.remessa;
|
|
2342
2396
|
const arquivo = new Arquivo();
|
|
2343
2397
|
const dataAtual = /* @__PURE__ */ new Date();
|
|
2344
|
-
const data =
|
|
2345
|
-
const hora =
|
|
2398
|
+
const data = format6(dataAtual, "ddMMyyyy");
|
|
2399
|
+
const hora = format6(dataAtual, "HHmmss");
|
|
2346
2400
|
const remessa2 = `REM${dadosBancario.numeroRemessa.padStart(5, "0")}.CNAB`;
|
|
2347
2401
|
arquivo.add("001");
|
|
2348
2402
|
arquivo.add("0000");
|
|
@@ -2442,8 +2496,10 @@ function gerarRemessa5({ dados }) {
|
|
|
2442
2496
|
const valorJurosDia = dadosBancario.jurosMes > 0 ? Number(boleto.valor) * dadosBancario.jurosMes / 100 / 30 : 0;
|
|
2443
2497
|
const { pagador } = boleto;
|
|
2444
2498
|
const tipoInscricao = pagador.pessoa === "F" ? "1" : "2";
|
|
2445
|
-
const vencimento =
|
|
2499
|
+
const vencimento = format6(new Date(boleto.vencimento), "ddMMyyyy");
|
|
2446
2500
|
total += Number(boleto.valor);
|
|
2501
|
+
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
2502
|
+
const desconto = boleto.desconto > 0 ? boleto.desconto.toFixed(2) : dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
2447
2503
|
let protesto = "3";
|
|
2448
2504
|
let diasProtesto = "00";
|
|
2449
2505
|
let baixarDevolver = "1";
|
|
@@ -2501,9 +2557,9 @@ function gerarRemessa5({ dados }) {
|
|
|
2501
2557
|
arquivo.add("1");
|
|
2502
2558
|
arquivo.add("00000000");
|
|
2503
2559
|
arquivo.add(valorJurosDia.toFixed(2).replace(".", "").padStart(15, "0"));
|
|
2504
|
-
arquivo.add(
|
|
2505
|
-
arquivo.add(
|
|
2506
|
-
arquivo.add("
|
|
2560
|
+
arquivo.add(codigoDesconto);
|
|
2561
|
+
arquivo.add(vencimento);
|
|
2562
|
+
arquivo.add(desconto.replace(".", "").padStart(15, "0"));
|
|
2507
2563
|
arquivo.add("000000000000000");
|
|
2508
2564
|
arquivo.add("000000000000000");
|
|
2509
2565
|
arquivo.add(boleto.identificacaoTitulo.padEnd(25, " "));
|
|
@@ -2603,6 +2659,7 @@ function gerarRemessa5({ dados }) {
|
|
|
2603
2659
|
}
|
|
2604
2660
|
|
|
2605
2661
|
// src/banks/banco-brasil/gerarRetorno.ts
|
|
2662
|
+
import { parse as parse4 } from "date-fns";
|
|
2606
2663
|
function gerarRetorno5({ dados }) {
|
|
2607
2664
|
try {
|
|
2608
2665
|
const { arquivo } = dados;
|
|
@@ -2631,6 +2688,14 @@ function gerarRetorno5({ dados }) {
|
|
|
2631
2688
|
linha = arquivo[++i];
|
|
2632
2689
|
segmento = linha.substring(13, 14);
|
|
2633
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
|
+
}
|
|
2634
2699
|
const valorAbatimentoString = linha.substring(47, 62);
|
|
2635
2700
|
const valorAbatimento = Number(valorAbatimentoString) / 100;
|
|
2636
2701
|
const valorDescontoString = linha.substring(32, 47);
|
|
@@ -2649,13 +2714,15 @@ function gerarRetorno5({ dados }) {
|
|
|
2649
2714
|
valor_multa: valorMulta,
|
|
2650
2715
|
valor_juros: valorJuros,
|
|
2651
2716
|
valor_desconto: valorDesconto,
|
|
2652
|
-
valor_total: valorTotal
|
|
2717
|
+
valor_total: valorTotal,
|
|
2718
|
+
data: dataCredito
|
|
2653
2719
|
};
|
|
2654
2720
|
documentos.push(documento);
|
|
2655
2721
|
}
|
|
2656
2722
|
}
|
|
2657
2723
|
}
|
|
2658
|
-
|
|
2724
|
+
const documentoAgrupado = agruparRetorno(documentos);
|
|
2725
|
+
return documentoAgrupado;
|
|
2659
2726
|
} catch (error) {
|
|
2660
2727
|
console.log(error);
|
|
2661
2728
|
return null;
|