@plasoft/boletos 1.0.47 → 1.0.49

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
@@ -24,11 +24,11 @@ interface IParcela$4 {
24
24
  interface IGerarPDFAilos {
25
25
  banco: Banco.AILOS;
26
26
  dados: {
27
- dadosPDF: IDadosPDF$4;
27
+ dadosPDF: IDadosPDF$5;
28
28
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
29
29
  };
30
30
  }
31
- interface IDadosPDF$4 {
31
+ interface IDadosPDF$5 {
32
32
  pagador: {
33
33
  nome: string;
34
34
  cnpj: string;
@@ -191,11 +191,11 @@ interface IParcela$3 {
191
191
  interface IGerarPDFBradesco {
192
192
  banco: Banco.BRADESCO;
193
193
  dados: {
194
- dadosPDF: IDadosPDF$3;
194
+ dadosPDF: IDadosPDF$4;
195
195
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
196
196
  };
197
197
  }
198
- interface IDadosPDF$3 {
198
+ interface IDadosPDF$4 {
199
199
  pagador: {
200
200
  nome: string;
201
201
  endereco: {
@@ -341,11 +341,11 @@ interface IParcela$2 {
341
341
  interface IGerarPDFSicredi {
342
342
  banco: Banco.SICREDI;
343
343
  dados: {
344
- dadosPDF: IDadosPDF$2;
344
+ dadosPDF: IDadosPDF$3;
345
345
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
346
346
  };
347
347
  }
348
- interface IDadosPDF$2 {
348
+ interface IDadosPDF$3 {
349
349
  pagador: {
350
350
  nome: string;
351
351
  cnpj: string;
@@ -495,11 +495,11 @@ interface IParcela$1 {
495
495
  interface IGerarPDFSicoob {
496
496
  banco: Banco.SICOOB;
497
497
  dados: {
498
- dadosPDF: IDadosPDF$1;
498
+ dadosPDF: IDadosPDF$2;
499
499
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
500
500
  };
501
501
  }
502
- interface IDadosPDF$1 {
502
+ interface IDadosPDF$2 {
503
503
  beneficiario: {
504
504
  nome: string;
505
505
  dadosBancario: {
@@ -630,10 +630,10 @@ interface IParcela {
630
630
  interface IGerarPDFBancoBrasil {
631
631
  banco: Banco.BANCO_BRASIL;
632
632
  dados: {
633
- dadosPDF: IDadosPDF;
633
+ dadosPDF: IDadosPDF$1;
634
634
  };
635
635
  }
636
- interface IDadosPDF {
636
+ interface IDadosPDF$1 {
637
637
  pagador: {
638
638
  nome: string;
639
639
  cnpj: string;
@@ -766,8 +766,65 @@ interface IGerarRetornoBancoBrasil {
766
766
  };
767
767
  }
768
768
 
769
+ interface IGerarPDFItau {
770
+ banco: Banco.ITAU;
771
+ dados: {
772
+ dadosPDF: IDadosPDF;
773
+ };
774
+ }
775
+ interface IDadosPDF {
776
+ pagador: {
777
+ nome: string;
778
+ cnpj: string;
779
+ endereco: {
780
+ logradouro: string;
781
+ numero: string;
782
+ bairro: string;
783
+ cep: string;
784
+ municipio: string;
785
+ uf: string;
786
+ };
787
+ };
788
+ beneficiario: {
789
+ nome: string;
790
+ cnpj: string;
791
+ dadosBancario: {
792
+ agencia: string;
793
+ conta: string;
794
+ contaDigito: string;
795
+ juros: number;
796
+ multa: number;
797
+ desconto: number;
798
+ protesto: number;
799
+ codigoCarteira: string;
800
+ };
801
+ endereco: {
802
+ logradouro: string;
803
+ numero: string;
804
+ bairro: string;
805
+ cep: string;
806
+ municipio: string;
807
+ uf: string;
808
+ };
809
+ };
810
+ boleto: {
811
+ dataVencimento: string;
812
+ dataDocumento: string;
813
+ dataProcessamento: string;
814
+ valorDocumento: number | string;
815
+ nossoNumero: string;
816
+ especieDocumento: string;
817
+ aceite: string;
818
+ codigoBarra: string;
819
+ linhaDigitavel: string;
820
+ qrCode: string;
821
+ pixCopiaCola: string;
822
+ instrucoes: string[];
823
+ };
824
+ }
825
+
769
826
  type IGerarBoleto = IGerarBoletoAilos | IGerarBoletoBradesco | IGerarBoletoSicredi | IGerarBoletoSicoob | IGerarBoletoBancoBrasil;
770
- type IGerarPDF = IGerarPDFAilos | IGerarPDFBradesco | IGerarPDFSicredi | IGerarPDFSicoob | IGerarPDFBancoBrasil;
827
+ type IGerarPDF = IGerarPDFAilos | IGerarPDFBradesco | IGerarPDFSicredi | IGerarPDFSicoob | IGerarPDFBancoBrasil | IGerarPDFItau;
771
828
  type IGerarRemessa = IGerarRemessaAilos | IGerarRemessaBradesco | IGerarRemessaSicredi | IGerarRemessaSicoob | IGerarRemessaBancoBrasil;
772
829
  type IGerarRetorno = IGerarRetornoAilos | IGerarRetornoBradesco | IGerarRetornoSicredi | IGerarRetornoSicoob | IGerarRetornoBancoBrasil;
773
830
  declare enum Banco {
@@ -775,7 +832,8 @@ declare enum Banco {
775
832
  BRADESCO = "005",
776
833
  SICREDI = "748",
777
834
  SICOOB = "756",
778
- BANCO_BRASIL = "001"
835
+ BANCO_BRASIL = "001",
836
+ ITAU = "341"
779
837
  }
780
838
 
781
839
  declare function gerar({ banco, dados }: IGerarBoleto): {
package/build/index.d.ts CHANGED
@@ -24,11 +24,11 @@ interface IParcela$4 {
24
24
  interface IGerarPDFAilos {
25
25
  banco: Banco.AILOS;
26
26
  dados: {
27
- dadosPDF: IDadosPDF$4;
27
+ dadosPDF: IDadosPDF$5;
28
28
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
29
29
  };
30
30
  }
31
- interface IDadosPDF$4 {
31
+ interface IDadosPDF$5 {
32
32
  pagador: {
33
33
  nome: string;
34
34
  cnpj: string;
@@ -191,11 +191,11 @@ interface IParcela$3 {
191
191
  interface IGerarPDFBradesco {
192
192
  banco: Banco.BRADESCO;
193
193
  dados: {
194
- dadosPDF: IDadosPDF$3;
194
+ dadosPDF: IDadosPDF$4;
195
195
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
196
196
  };
197
197
  }
198
- interface IDadosPDF$3 {
198
+ interface IDadosPDF$4 {
199
199
  pagador: {
200
200
  nome: string;
201
201
  endereco: {
@@ -341,11 +341,11 @@ interface IParcela$2 {
341
341
  interface IGerarPDFSicredi {
342
342
  banco: Banco.SICREDI;
343
343
  dados: {
344
- dadosPDF: IDadosPDF$2;
344
+ dadosPDF: IDadosPDF$3;
345
345
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
346
346
  };
347
347
  }
348
- interface IDadosPDF$2 {
348
+ interface IDadosPDF$3 {
349
349
  pagador: {
350
350
  nome: string;
351
351
  cnpj: string;
@@ -495,11 +495,11 @@ interface IParcela$1 {
495
495
  interface IGerarPDFSicoob {
496
496
  banco: Banco.SICOOB;
497
497
  dados: {
498
- dadosPDF: IDadosPDF$1;
498
+ dadosPDF: IDadosPDF$2;
499
499
  generatePDF?: (content: string, config: PDFOptions) => Promise<string>;
500
500
  };
501
501
  }
502
- interface IDadosPDF$1 {
502
+ interface IDadosPDF$2 {
503
503
  beneficiario: {
504
504
  nome: string;
505
505
  dadosBancario: {
@@ -630,10 +630,10 @@ interface IParcela {
630
630
  interface IGerarPDFBancoBrasil {
631
631
  banco: Banco.BANCO_BRASIL;
632
632
  dados: {
633
- dadosPDF: IDadosPDF;
633
+ dadosPDF: IDadosPDF$1;
634
634
  };
635
635
  }
636
- interface IDadosPDF {
636
+ interface IDadosPDF$1 {
637
637
  pagador: {
638
638
  nome: string;
639
639
  cnpj: string;
@@ -766,8 +766,65 @@ interface IGerarRetornoBancoBrasil {
766
766
  };
767
767
  }
768
768
 
769
+ interface IGerarPDFItau {
770
+ banco: Banco.ITAU;
771
+ dados: {
772
+ dadosPDF: IDadosPDF;
773
+ };
774
+ }
775
+ interface IDadosPDF {
776
+ pagador: {
777
+ nome: string;
778
+ cnpj: string;
779
+ endereco: {
780
+ logradouro: string;
781
+ numero: string;
782
+ bairro: string;
783
+ cep: string;
784
+ municipio: string;
785
+ uf: string;
786
+ };
787
+ };
788
+ beneficiario: {
789
+ nome: string;
790
+ cnpj: string;
791
+ dadosBancario: {
792
+ agencia: string;
793
+ conta: string;
794
+ contaDigito: string;
795
+ juros: number;
796
+ multa: number;
797
+ desconto: number;
798
+ protesto: number;
799
+ codigoCarteira: string;
800
+ };
801
+ endereco: {
802
+ logradouro: string;
803
+ numero: string;
804
+ bairro: string;
805
+ cep: string;
806
+ municipio: string;
807
+ uf: string;
808
+ };
809
+ };
810
+ boleto: {
811
+ dataVencimento: string;
812
+ dataDocumento: string;
813
+ dataProcessamento: string;
814
+ valorDocumento: number | string;
815
+ nossoNumero: string;
816
+ especieDocumento: string;
817
+ aceite: string;
818
+ codigoBarra: string;
819
+ linhaDigitavel: string;
820
+ qrCode: string;
821
+ pixCopiaCola: string;
822
+ instrucoes: string[];
823
+ };
824
+ }
825
+
769
826
  type IGerarBoleto = IGerarBoletoAilos | IGerarBoletoBradesco | IGerarBoletoSicredi | IGerarBoletoSicoob | IGerarBoletoBancoBrasil;
770
- type IGerarPDF = IGerarPDFAilos | IGerarPDFBradesco | IGerarPDFSicredi | IGerarPDFSicoob | IGerarPDFBancoBrasil;
827
+ type IGerarPDF = IGerarPDFAilos | IGerarPDFBradesco | IGerarPDFSicredi | IGerarPDFSicoob | IGerarPDFBancoBrasil | IGerarPDFItau;
771
828
  type IGerarRemessa = IGerarRemessaAilos | IGerarRemessaBradesco | IGerarRemessaSicredi | IGerarRemessaSicoob | IGerarRemessaBancoBrasil;
772
829
  type IGerarRetorno = IGerarRetornoAilos | IGerarRetornoBradesco | IGerarRetornoSicredi | IGerarRetornoSicoob | IGerarRetornoBancoBrasil;
773
830
  declare enum Banco {
@@ -775,7 +832,8 @@ declare enum Banco {
775
832
  BRADESCO = "005",
776
833
  SICREDI = "748",
777
834
  SICOOB = "756",
778
- BANCO_BRASIL = "001"
835
+ BANCO_BRASIL = "001",
836
+ ITAU = "341"
779
837
  }
780
838
 
781
839
  declare function gerar({ banco, dados }: IGerarBoleto): {
package/build/index.js CHANGED
@@ -1,10 +1,27 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
9
  var __getProtoOf = Object.getPrototypeOf;
7
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8
25
  var __export = (target, all) => {
9
26
  for (var name in all)
10
27
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -237,7 +254,7 @@ function getPathTemplates(template) {
237
254
  var import_config = require("dotenv/config");
238
255
  var import_axios = __toESM(require("axios"));
239
256
  var api = import_axios.default.create({
240
- baseURL: process.env.API_URL
257
+ baseURL: process.env.API_URL || "https://23136fv876.execute-api.sa-east-1.amazonaws.com/dev/create-report"
241
258
  });
242
259
 
243
260
  // src/utils/zip.ts
@@ -679,6 +696,7 @@ var Banco = /* @__PURE__ */ ((Banco2) => {
679
696
  Banco2["SICREDI"] = "748";
680
697
  Banco2["SICOOB"] = "756";
681
698
  Banco2["BANCO_BRASIL"] = "001";
699
+ Banco2["ITAU"] = "341";
682
700
  return Banco2;
683
701
  })(Banco || {});
684
702
 
@@ -2605,6 +2623,111 @@ function gerar({ banco, dados }) {
2605
2623
  }
2606
2624
  }
2607
2625
 
2626
+ // src/banks/itau/gerarPDF.ts
2627
+ var import_bwip_js6 = __toESM(require("bwip-js"));
2628
+ function gerarPDF6(_0) {
2629
+ return __async(this, arguments, function* ({ dados }) {
2630
+ try {
2631
+ const { dadosPDF } = dados;
2632
+ if (!dadosPDF.pagador.cnpj) {
2633
+ throw new Error("CPF/CNPJ do pagador na\u0303o informado!");
2634
+ }
2635
+ const codigoBarra2 = yield import_bwip_js6.default.toBuffer({
2636
+ bcid: "interleaved2of5",
2637
+ text: dadosPDF.boleto.codigoBarra,
2638
+ height: 20
2639
+ });
2640
+ dadosPDF.beneficiario.dadosBancario.agencia = dadosPDF.beneficiario.dadosBancario.agencia.padStart(4, "0");
2641
+ dadosPDF.boleto.linhaDigitavel = maskFormat_default.codigoBarra(dadosPDF.boleto.linhaDigitavel);
2642
+ dadosPDF.beneficiario.cnpj = maskFormat_default.retornaCpfCnpjFormatado(
2643
+ dadosPDF.beneficiario.cnpj
2644
+ );
2645
+ dadosPDF.beneficiario.endereco.cep = maskFormat_default.retornaCEPFormatado(
2646
+ dadosPDF.beneficiario.endereco.cep
2647
+ );
2648
+ dadosPDF.pagador.endereco.cep = maskFormat_default.retornaCEPFormatado(
2649
+ dadosPDF.pagador.endereco.cep
2650
+ );
2651
+ dadosPDF.pagador.cnpj = maskFormat_default.retornaCpfCnpjFormatado(dadosPDF.pagador.cnpj);
2652
+ const valorDocumento = Number(dadosPDF.boleto.valorDocumento);
2653
+ dadosPDF.boleto.valorDocumento = maskFormat_default.numberToReal(
2654
+ dadosPDF.boleto.valorDocumento
2655
+ );
2656
+ const jurosMes = dadosPDF.beneficiario.dadosBancario.juros;
2657
+ const jurosDia = jurosMes / 100 / 30 * valorDocumento;
2658
+ if (jurosDia > 0) {
2659
+ dadosPDF.boleto.instrucoes = [`AP\xD3S O VENCIMENTO, COBRAR JUROS DE R$${maskFormat_default.numberToReal(jurosDia)} AO DIA`, ...dadosPDF.boleto.instrucoes];
2660
+ }
2661
+ const descontoVencimento = dadosPDF.beneficiario.dadosBancario.desconto || 0;
2662
+ if (descontoVencimento > 0) {
2663
+ dadosPDF.boleto.instrucoes = [`AT\xC9 O VENCIMENTO, CONCEDER DESCONTO DE ${descontoVencimento}%`, ...dadosPDF.boleto.instrucoes];
2664
+ }
2665
+ const multaAtraso = dadosPDF.beneficiario.dadosBancario.multa || 0;
2666
+ if (multaAtraso > 0) {
2667
+ dadosPDF.boleto.instrucoes = [`MULTA DE ${multaAtraso}%`, ...dadosPDF.boleto.instrucoes];
2668
+ }
2669
+ const protestoDias = dadosPDF.beneficiario.dadosBancario.protesto || 0;
2670
+ if (protestoDias > 0) {
2671
+ dadosPDF.boleto.instrucoes = [`PROTESTAR AP\xD3S ${protestoDias} DIAS CORRIDOS DO VENCIMENTO`, ...dadosPDF.boleto.instrucoes];
2672
+ }
2673
+ const content = compileHbs(getPathTemplates("itau-boleto.hbs"), __spreadProps(__spreadValues({}, dadosPDF), {
2674
+ boleto: __spreadProps(__spreadValues({}, dadosPDF.boleto), {
2675
+ codigoBarraImage: codigoBarra2.toString("base64"),
2676
+ nossoNumeroDigito: getDigito6(`${dadosPDF.beneficiario.dadosBancario.agencia}${dadosPDF.beneficiario.dadosBancario.conta}${dadosPDF.beneficiario.dadosBancario.codigoCarteira}${dadosPDF.boleto.nossoNumero}`)
2677
+ })
2678
+ }));
2679
+ const config = {
2680
+ displayHeaderFooter: false,
2681
+ path: "./boleto.pdf",
2682
+ format: "a4",
2683
+ printBackground: true
2684
+ };
2685
+ const response = yield api.post("/", { content, config });
2686
+ const buffer = Buffer.from(response.data.pdf);
2687
+ const pdfBase64 = yield decompress(buffer);
2688
+ return {
2689
+ erro: false,
2690
+ dados: pdfBase64
2691
+ };
2692
+ } catch (error) {
2693
+ console.log(error);
2694
+ return {
2695
+ erro: true,
2696
+ dados: "Falha ao gerar impress\xE3o do boleto"
2697
+ };
2698
+ }
2699
+ });
2700
+ }
2701
+ function getDigito6(texto) {
2702
+ let i = texto.length;
2703
+ let j = 1;
2704
+ let total = 0;
2705
+ let soma = 0;
2706
+ let digito = 0;
2707
+ while (i >= 1) {
2708
+ j = j === 1 ? 2 : 1;
2709
+ let valor = Number(copy(texto, i, i));
2710
+ total = valor * j;
2711
+ if (total >= 10) {
2712
+ valor = Number(copy(total, 1, 1)) + Number(copy(total, 2, 2));
2713
+ } else {
2714
+ valor = total;
2715
+ }
2716
+ soma += valor;
2717
+ i--;
2718
+ }
2719
+ const uni = Number(copy(soma, String(soma).length, String(soma).length));
2720
+ digito = 10 - uni;
2721
+ if (digito === 10)
2722
+ digito = 0;
2723
+ return String(digito);
2724
+ }
2725
+
2726
+ // src/banks/itau/index.ts
2727
+ var itau = {
2728
+ gerarPDF: gerarPDF6
2729
+ };
2730
+
2608
2731
  // src/pdf.ts
2609
2732
  function pdf({ banco, dados }) {
2610
2733
  if (banco === "085" /* AILOS */) {
@@ -2622,6 +2745,9 @@ function pdf({ banco, dados }) {
2622
2745
  if (banco === "001" /* BANCO_BRASIL */) {
2623
2746
  return bancoBrasil.gerarPDF({ banco, dados });
2624
2747
  }
2748
+ if (banco === "341" /* ITAU */) {
2749
+ return itau.gerarPDF({ banco, dados });
2750
+ }
2625
2751
  }
2626
2752
 
2627
2753
  // src/remessa.ts
@@ -2685,3 +2811,4 @@ var src_default = {
2685
2811
  Banco,
2686
2812
  defineConfig
2687
2813
  });
2814
+ //# sourceMappingURL=index.js.map