@plasoft/boletos 1.0.26 → 1.0.28

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.js CHANGED
@@ -1407,7 +1407,9 @@ function gerarRemessa3({ dados }) {
1407
1407
  arquivo.add(multaAtraso.padStart(4, "0"));
1408
1408
  arquivo.add(" ".padEnd(12, " "));
1409
1409
  arquivo.add("01");
1410
- arquivo.add((boleto.numeroDocumento + "/" + boleto.parcela).padEnd(10, " "));
1410
+ const tipo_documento = boleto.identificacaoTitulo.substring(0, 1);
1411
+ const especie = tipo_documento === "F" ? "0" /* FATURA */ : tipo_documento === "N" ? "1" /* NOTA */ : "2" /* LANCAMENTO */;
1412
+ arquivo.add((especie + boleto.numeroDocumento + "/" + boleto.parcela).padEnd(10, " "));
1411
1413
  arquivo.add((0, import_date_fns4.format)(new Date(boleto.vencimento), "ddMMyy"));
1412
1414
  arquivo.add(Number(boleto.valor).toFixed(2).replace(".", "").padStart(13, "0"));
1413
1415
  arquivo.add(" ".padEnd(9, " "));
@@ -1462,11 +1464,62 @@ function retornaMes(data) {
1462
1464
  }
1463
1465
  }
1464
1466
 
1467
+ // src/banks/sicredi/gerarRetorno.ts
1468
+ function gerarRetorno3({ dados }) {
1469
+ try {
1470
+ const { arquivo } = dados;
1471
+ const documentos = [];
1472
+ for (const linha of arquivo) {
1473
+ const id_registro = linha.substring(0, 1);
1474
+ if (id_registro !== "1" /* DETALHE */) {
1475
+ continue;
1476
+ }
1477
+ const ocorrencia = linha.substring(108, 110);
1478
+ if (ocorrencia !== "06" && ocorrencia !== "15" && ocorrencia !== "17") {
1479
+ continue;
1480
+ }
1481
+ const meu_numero = linha.substring(116, 126).trim();
1482
+ const [financeiro, _parcela] = meu_numero.split("/");
1483
+ const numero_especie = financeiro[0];
1484
+ const especie = numero_especie === "0" /* FATURA */ ? "FAT" : numero_especie === "1" /* NOTA */ ? "NFE" : numero_especie === "2" /* LANCAMENTO */ ? "LAN" : "INDEFINIDO";
1485
+ const id_financeiro = financeiro.substring(1);
1486
+ const valor_titulo = Number(linha.substring(152, 165)) / 100;
1487
+ const abatimento = Number(linha.substring(227, 240)) / 100;
1488
+ let valor_desconto = Number(linha.substring(240, 253)) / 100;
1489
+ const valor_pago = Number(linha.substring(253, 266)) / 100;
1490
+ let valor_juros = Number(linha.substring(266, 279)) / 100;
1491
+ const valor_multa = Number(linha.substring(279, 292)) / 100;
1492
+ if (valor_titulo > valor_pago && valor_desconto === 0) {
1493
+ valor_desconto = valor_titulo - valor_pago;
1494
+ }
1495
+ if (valor_titulo < valor_pago && valor_juros === 0) {
1496
+ valor_juros = valor_pago - valor_titulo;
1497
+ }
1498
+ const descontos = abatimento + valor_desconto;
1499
+ const valor_total = valor_titulo + valor_multa + valor_juros - descontos;
1500
+ documentos.push({
1501
+ id_documento: id_financeiro,
1502
+ especie,
1503
+ valor: valor_pago,
1504
+ valor_multa,
1505
+ valor_juros,
1506
+ valor_desconto,
1507
+ valor_total
1508
+ });
1509
+ }
1510
+ return documentos;
1511
+ } catch (error) {
1512
+ console.log(error);
1513
+ return null;
1514
+ }
1515
+ }
1516
+
1465
1517
  // src/banks/sicredi/index.ts
1466
1518
  var sicredi = {
1467
1519
  gerarDadosBoleto: gerarDadosBoleto3,
1468
1520
  gerarPDF: gerarPDF3,
1469
- gerarRemessa: gerarRemessa3
1521
+ gerarRemessa: gerarRemessa3,
1522
+ gerarRetorno: gerarRetorno3
1470
1523
  };
1471
1524
 
1472
1525
  // src/banks/sicoob/gerarDadosBoleto.ts
@@ -1989,6 +2042,9 @@ function retorno({ banco, dados }) {
1989
2042
  if (banco === "005" /* BRADESCO */) {
1990
2043
  return bradesco.gerarRetorno({ banco, dados });
1991
2044
  }
2045
+ if (banco === "748" /* SICREDI */) {
2046
+ return sicredi.gerarRetorno({ banco, dados });
2047
+ }
1992
2048
  }
1993
2049
 
1994
2050
  // src/config/index.ts
package/build/index.mjs CHANGED
@@ -1370,7 +1370,9 @@ function gerarRemessa3({ dados }) {
1370
1370
  arquivo.add(multaAtraso.padStart(4, "0"));
1371
1371
  arquivo.add(" ".padEnd(12, " "));
1372
1372
  arquivo.add("01");
1373
- arquivo.add((boleto.numeroDocumento + "/" + boleto.parcela).padEnd(10, " "));
1373
+ const tipo_documento = boleto.identificacaoTitulo.substring(0, 1);
1374
+ const especie = tipo_documento === "F" ? "0" /* FATURA */ : tipo_documento === "N" ? "1" /* NOTA */ : "2" /* LANCAMENTO */;
1375
+ arquivo.add((especie + boleto.numeroDocumento + "/" + boleto.parcela).padEnd(10, " "));
1374
1376
  arquivo.add(format3(new Date(boleto.vencimento), "ddMMyy"));
1375
1377
  arquivo.add(Number(boleto.valor).toFixed(2).replace(".", "").padStart(13, "0"));
1376
1378
  arquivo.add(" ".padEnd(9, " "));
@@ -1425,11 +1427,62 @@ function retornaMes(data) {
1425
1427
  }
1426
1428
  }
1427
1429
 
1430
+ // src/banks/sicredi/gerarRetorno.ts
1431
+ function gerarRetorno3({ dados }) {
1432
+ try {
1433
+ const { arquivo } = dados;
1434
+ const documentos = [];
1435
+ for (const linha of arquivo) {
1436
+ const id_registro = linha.substring(0, 1);
1437
+ if (id_registro !== "1" /* DETALHE */) {
1438
+ continue;
1439
+ }
1440
+ const ocorrencia = linha.substring(108, 110);
1441
+ if (ocorrencia !== "06" && ocorrencia !== "15" && ocorrencia !== "17") {
1442
+ continue;
1443
+ }
1444
+ const meu_numero = linha.substring(116, 126).trim();
1445
+ const [financeiro, _parcela] = meu_numero.split("/");
1446
+ const numero_especie = financeiro[0];
1447
+ const especie = numero_especie === "0" /* FATURA */ ? "FAT" : numero_especie === "1" /* NOTA */ ? "NFE" : numero_especie === "2" /* LANCAMENTO */ ? "LAN" : "INDEFINIDO";
1448
+ const id_financeiro = financeiro.substring(1);
1449
+ const valor_titulo = Number(linha.substring(152, 165)) / 100;
1450
+ const abatimento = Number(linha.substring(227, 240)) / 100;
1451
+ let valor_desconto = Number(linha.substring(240, 253)) / 100;
1452
+ const valor_pago = Number(linha.substring(253, 266)) / 100;
1453
+ let valor_juros = Number(linha.substring(266, 279)) / 100;
1454
+ const valor_multa = Number(linha.substring(279, 292)) / 100;
1455
+ if (valor_titulo > valor_pago && valor_desconto === 0) {
1456
+ valor_desconto = valor_titulo - valor_pago;
1457
+ }
1458
+ if (valor_titulo < valor_pago && valor_juros === 0) {
1459
+ valor_juros = valor_pago - valor_titulo;
1460
+ }
1461
+ const descontos = abatimento + valor_desconto;
1462
+ const valor_total = valor_titulo + valor_multa + valor_juros - descontos;
1463
+ documentos.push({
1464
+ id_documento: id_financeiro,
1465
+ especie,
1466
+ valor: valor_pago,
1467
+ valor_multa,
1468
+ valor_juros,
1469
+ valor_desconto,
1470
+ valor_total
1471
+ });
1472
+ }
1473
+ return documentos;
1474
+ } catch (error) {
1475
+ console.log(error);
1476
+ return null;
1477
+ }
1478
+ }
1479
+
1428
1480
  // src/banks/sicredi/index.ts
1429
1481
  var sicredi = {
1430
1482
  gerarDadosBoleto: gerarDadosBoleto3,
1431
1483
  gerarPDF: gerarPDF3,
1432
- gerarRemessa: gerarRemessa3
1484
+ gerarRemessa: gerarRemessa3,
1485
+ gerarRetorno: gerarRetorno3
1433
1486
  };
1434
1487
 
1435
1488
  // src/banks/sicoob/gerarDadosBoleto.ts
@@ -1952,6 +2005,9 @@ function retorno({ banco, dados }) {
1952
2005
  if (banco === "005" /* BRADESCO */) {
1953
2006
  return bradesco.gerarRetorno({ banco, dados });
1954
2007
  }
2008
+ if (banco === "748" /* SICREDI */) {
2009
+ return sicredi.gerarRetorno({ banco, dados });
2010
+ }
1955
2011
  }
1956
2012
 
1957
2013
  // src/config/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasoft/boletos",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "main": "build",
5
5
  "license": "ISC",
6
6
  "scripts": {