@plasoft/boletos 1.0.1 → 1.0.3
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 +164 -0
- package/build/index.d.ts +164 -0
- package/build/index.js +488 -2
- package/build/index.mjs +503 -0
- package/package.json +2 -2
- package/src/ailos/index.ts +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
interface IParcelaGerarBoleto {
|
|
2
|
+
id_boleto: number;
|
|
3
|
+
parcela: number;
|
|
4
|
+
vencimento: string | Date;
|
|
5
|
+
valor: number | string;
|
|
6
|
+
pago: number | string;
|
|
7
|
+
data_emissao: string | Date;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type IParcela = IParcelaGerarBoleto;
|
|
11
|
+
interface ICedente {
|
|
12
|
+
numero: string;
|
|
13
|
+
numero_dv: string;
|
|
14
|
+
convenio: string;
|
|
15
|
+
msg_local: string;
|
|
16
|
+
msg_1: string;
|
|
17
|
+
msg_2: string;
|
|
18
|
+
msg_3: string;
|
|
19
|
+
nome: string;
|
|
20
|
+
cnpj: string;
|
|
21
|
+
carteira: string;
|
|
22
|
+
}
|
|
23
|
+
declare function gerarDadosBoleto(cedente: ICedente, parcela: IParcela): Promise<{
|
|
24
|
+
fatorVencimento: string;
|
|
25
|
+
valor: string;
|
|
26
|
+
convenio: string;
|
|
27
|
+
nossoNumero: string;
|
|
28
|
+
campoLivre: string;
|
|
29
|
+
digitoGeral: string;
|
|
30
|
+
codigoBarra: string;
|
|
31
|
+
numeroDocumento: string;
|
|
32
|
+
campo1: string;
|
|
33
|
+
campo2: string;
|
|
34
|
+
campo3: string;
|
|
35
|
+
campo4: string;
|
|
36
|
+
campo5: string;
|
|
37
|
+
digito1: string;
|
|
38
|
+
digito2: string;
|
|
39
|
+
digito3: string;
|
|
40
|
+
digito4: string;
|
|
41
|
+
} | null>;
|
|
42
|
+
|
|
43
|
+
interface IDadosBoleto {
|
|
44
|
+
pagador: {
|
|
45
|
+
nome: string;
|
|
46
|
+
endereco: {
|
|
47
|
+
logradouro: string;
|
|
48
|
+
numero: string;
|
|
49
|
+
bairro: string;
|
|
50
|
+
cep: string;
|
|
51
|
+
municipio: string;
|
|
52
|
+
uf: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
beneficiario: {
|
|
56
|
+
nome: string;
|
|
57
|
+
cnpj: string;
|
|
58
|
+
dadosBancarios: {
|
|
59
|
+
carteira: string;
|
|
60
|
+
convenio: string;
|
|
61
|
+
agencia: string;
|
|
62
|
+
agenciaDigito: string;
|
|
63
|
+
conta: string;
|
|
64
|
+
contaDigito: string;
|
|
65
|
+
};
|
|
66
|
+
endereco: {
|
|
67
|
+
logradouro: string;
|
|
68
|
+
numero: string;
|
|
69
|
+
bairro: string;
|
|
70
|
+
cep: string;
|
|
71
|
+
municipio: string;
|
|
72
|
+
uf: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
boleto: {
|
|
76
|
+
dataVencimento: string;
|
|
77
|
+
dataProcessamento: string;
|
|
78
|
+
dataDocumento: string;
|
|
79
|
+
valorCobrado: number | string;
|
|
80
|
+
valorDocumento: number | string;
|
|
81
|
+
valorDescontoAbatimento: number | string;
|
|
82
|
+
valorOutrasDeducoes: number | string;
|
|
83
|
+
valorMulta: number | string;
|
|
84
|
+
valorAcrescimo: number | string;
|
|
85
|
+
quantidade?: number | string;
|
|
86
|
+
valor?: number | string;
|
|
87
|
+
numeroDocumento: string;
|
|
88
|
+
nossoNumero: string;
|
|
89
|
+
especieDocumento: string;
|
|
90
|
+
aceite: 'S' | 'N';
|
|
91
|
+
moeda: string;
|
|
92
|
+
usoDoBanco?: string;
|
|
93
|
+
cip?: string;
|
|
94
|
+
codigoBarra: string;
|
|
95
|
+
codigoBarraImage?: string;
|
|
96
|
+
instrucao1?: string;
|
|
97
|
+
instrucao2?: string;
|
|
98
|
+
instrucao3?: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
declare function gerarPDF(dados: IDadosBoleto): Promise<{
|
|
102
|
+
erro: boolean;
|
|
103
|
+
dados?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
erro: boolean;
|
|
106
|
+
dados: null;
|
|
107
|
+
}>;
|
|
108
|
+
|
|
109
|
+
interface IDadosRemessa {
|
|
110
|
+
pagador: {
|
|
111
|
+
nome: string;
|
|
112
|
+
pessoa: 'F' | 'J';
|
|
113
|
+
cpfCnpj: string;
|
|
114
|
+
endereco: {
|
|
115
|
+
logradouro: string;
|
|
116
|
+
numero: string;
|
|
117
|
+
bairro: string;
|
|
118
|
+
cep: string;
|
|
119
|
+
municipio: string;
|
|
120
|
+
uf: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
beneficiario: {
|
|
124
|
+
nome: string;
|
|
125
|
+
cnpj: string;
|
|
126
|
+
endereco: {
|
|
127
|
+
logradouro: string;
|
|
128
|
+
numero: string;
|
|
129
|
+
bairro: string;
|
|
130
|
+
cep: string;
|
|
131
|
+
municipio: string;
|
|
132
|
+
uf: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
dadosBancario: {
|
|
136
|
+
carteira: string;
|
|
137
|
+
convenio: string;
|
|
138
|
+
agencia: string;
|
|
139
|
+
agenciaDigito: string;
|
|
140
|
+
conta: string;
|
|
141
|
+
contaDigito: string;
|
|
142
|
+
numeroRemessa: string;
|
|
143
|
+
jurosMes: number;
|
|
144
|
+
multaAtraso: number;
|
|
145
|
+
descontoPagamento: number;
|
|
146
|
+
diasProtesto: number;
|
|
147
|
+
};
|
|
148
|
+
boletos: {
|
|
149
|
+
identificacaoTitulo: string;
|
|
150
|
+
vencimento: string | Date;
|
|
151
|
+
valor: number | string;
|
|
152
|
+
nossoNumero: string;
|
|
153
|
+
numeroDocumento: string;
|
|
154
|
+
parcela: number | string;
|
|
155
|
+
}[];
|
|
156
|
+
}
|
|
157
|
+
declare function gerarRemessa(dados: IDadosRemessa): Promise<{
|
|
158
|
+
download: string;
|
|
159
|
+
arquivo: string;
|
|
160
|
+
} | null>;
|
|
161
|
+
|
|
162
|
+
declare function bradesco(): void;
|
|
163
|
+
|
|
164
|
+
export { bradesco, gerarDadosBoleto, gerarPDF, gerarRemessa };
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
interface IParcelaGerarBoleto {
|
|
2
|
+
id_boleto: number;
|
|
3
|
+
parcela: number;
|
|
4
|
+
vencimento: string | Date;
|
|
5
|
+
valor: number | string;
|
|
6
|
+
pago: number | string;
|
|
7
|
+
data_emissao: string | Date;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type IParcela = IParcelaGerarBoleto;
|
|
11
|
+
interface ICedente {
|
|
12
|
+
numero: string;
|
|
13
|
+
numero_dv: string;
|
|
14
|
+
convenio: string;
|
|
15
|
+
msg_local: string;
|
|
16
|
+
msg_1: string;
|
|
17
|
+
msg_2: string;
|
|
18
|
+
msg_3: string;
|
|
19
|
+
nome: string;
|
|
20
|
+
cnpj: string;
|
|
21
|
+
carteira: string;
|
|
22
|
+
}
|
|
23
|
+
declare function gerarDadosBoleto(cedente: ICedente, parcela: IParcela): Promise<{
|
|
24
|
+
fatorVencimento: string;
|
|
25
|
+
valor: string;
|
|
26
|
+
convenio: string;
|
|
27
|
+
nossoNumero: string;
|
|
28
|
+
campoLivre: string;
|
|
29
|
+
digitoGeral: string;
|
|
30
|
+
codigoBarra: string;
|
|
31
|
+
numeroDocumento: string;
|
|
32
|
+
campo1: string;
|
|
33
|
+
campo2: string;
|
|
34
|
+
campo3: string;
|
|
35
|
+
campo4: string;
|
|
36
|
+
campo5: string;
|
|
37
|
+
digito1: string;
|
|
38
|
+
digito2: string;
|
|
39
|
+
digito3: string;
|
|
40
|
+
digito4: string;
|
|
41
|
+
} | null>;
|
|
42
|
+
|
|
43
|
+
interface IDadosBoleto {
|
|
44
|
+
pagador: {
|
|
45
|
+
nome: string;
|
|
46
|
+
endereco: {
|
|
47
|
+
logradouro: string;
|
|
48
|
+
numero: string;
|
|
49
|
+
bairro: string;
|
|
50
|
+
cep: string;
|
|
51
|
+
municipio: string;
|
|
52
|
+
uf: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
beneficiario: {
|
|
56
|
+
nome: string;
|
|
57
|
+
cnpj: string;
|
|
58
|
+
dadosBancarios: {
|
|
59
|
+
carteira: string;
|
|
60
|
+
convenio: string;
|
|
61
|
+
agencia: string;
|
|
62
|
+
agenciaDigito: string;
|
|
63
|
+
conta: string;
|
|
64
|
+
contaDigito: string;
|
|
65
|
+
};
|
|
66
|
+
endereco: {
|
|
67
|
+
logradouro: string;
|
|
68
|
+
numero: string;
|
|
69
|
+
bairro: string;
|
|
70
|
+
cep: string;
|
|
71
|
+
municipio: string;
|
|
72
|
+
uf: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
boleto: {
|
|
76
|
+
dataVencimento: string;
|
|
77
|
+
dataProcessamento: string;
|
|
78
|
+
dataDocumento: string;
|
|
79
|
+
valorCobrado: number | string;
|
|
80
|
+
valorDocumento: number | string;
|
|
81
|
+
valorDescontoAbatimento: number | string;
|
|
82
|
+
valorOutrasDeducoes: number | string;
|
|
83
|
+
valorMulta: number | string;
|
|
84
|
+
valorAcrescimo: number | string;
|
|
85
|
+
quantidade?: number | string;
|
|
86
|
+
valor?: number | string;
|
|
87
|
+
numeroDocumento: string;
|
|
88
|
+
nossoNumero: string;
|
|
89
|
+
especieDocumento: string;
|
|
90
|
+
aceite: 'S' | 'N';
|
|
91
|
+
moeda: string;
|
|
92
|
+
usoDoBanco?: string;
|
|
93
|
+
cip?: string;
|
|
94
|
+
codigoBarra: string;
|
|
95
|
+
codigoBarraImage?: string;
|
|
96
|
+
instrucao1?: string;
|
|
97
|
+
instrucao2?: string;
|
|
98
|
+
instrucao3?: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
declare function gerarPDF(dados: IDadosBoleto): Promise<{
|
|
102
|
+
erro: boolean;
|
|
103
|
+
dados?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
erro: boolean;
|
|
106
|
+
dados: null;
|
|
107
|
+
}>;
|
|
108
|
+
|
|
109
|
+
interface IDadosRemessa {
|
|
110
|
+
pagador: {
|
|
111
|
+
nome: string;
|
|
112
|
+
pessoa: 'F' | 'J';
|
|
113
|
+
cpfCnpj: string;
|
|
114
|
+
endereco: {
|
|
115
|
+
logradouro: string;
|
|
116
|
+
numero: string;
|
|
117
|
+
bairro: string;
|
|
118
|
+
cep: string;
|
|
119
|
+
municipio: string;
|
|
120
|
+
uf: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
beneficiario: {
|
|
124
|
+
nome: string;
|
|
125
|
+
cnpj: string;
|
|
126
|
+
endereco: {
|
|
127
|
+
logradouro: string;
|
|
128
|
+
numero: string;
|
|
129
|
+
bairro: string;
|
|
130
|
+
cep: string;
|
|
131
|
+
municipio: string;
|
|
132
|
+
uf: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
dadosBancario: {
|
|
136
|
+
carteira: string;
|
|
137
|
+
convenio: string;
|
|
138
|
+
agencia: string;
|
|
139
|
+
agenciaDigito: string;
|
|
140
|
+
conta: string;
|
|
141
|
+
contaDigito: string;
|
|
142
|
+
numeroRemessa: string;
|
|
143
|
+
jurosMes: number;
|
|
144
|
+
multaAtraso: number;
|
|
145
|
+
descontoPagamento: number;
|
|
146
|
+
diasProtesto: number;
|
|
147
|
+
};
|
|
148
|
+
boletos: {
|
|
149
|
+
identificacaoTitulo: string;
|
|
150
|
+
vencimento: string | Date;
|
|
151
|
+
valor: number | string;
|
|
152
|
+
nossoNumero: string;
|
|
153
|
+
numeroDocumento: string;
|
|
154
|
+
parcela: number | string;
|
|
155
|
+
}[];
|
|
156
|
+
}
|
|
157
|
+
declare function gerarRemessa(dados: IDadosRemessa): Promise<{
|
|
158
|
+
download: string;
|
|
159
|
+
arquivo: string;
|
|
160
|
+
} | null>;
|
|
161
|
+
|
|
162
|
+
declare function bradesco(): void;
|
|
163
|
+
|
|
164
|
+
export { bradesco, gerarDadosBoleto, gerarPDF, gerarRemessa };
|
package/build/index.js
CHANGED
|
@@ -26,31 +26,517 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
29
49
|
|
|
30
50
|
// src/index.ts
|
|
31
51
|
var src_exports = {};
|
|
32
52
|
__export(src_exports, {
|
|
33
|
-
bradesco: () => bradesco
|
|
53
|
+
bradesco: () => bradesco,
|
|
54
|
+
gerarDadosBoleto: () => gerarDadosBoleto,
|
|
55
|
+
gerarPDF: () => gerarPDF,
|
|
56
|
+
gerarRemessa: () => gerarRemessa
|
|
34
57
|
});
|
|
35
58
|
module.exports = __toCommonJS(src_exports);
|
|
36
59
|
|
|
37
60
|
// src/ailos/gerarDadosBoleto.ts
|
|
38
61
|
var import_date_fns = require("date-fns");
|
|
39
62
|
|
|
63
|
+
// src/utils/copy.ts
|
|
64
|
+
function copy(texto, startPosition, endPosition) {
|
|
65
|
+
let retorno = "";
|
|
66
|
+
if (typeof texto === "number")
|
|
67
|
+
texto = String(texto);
|
|
68
|
+
if (!endPosition)
|
|
69
|
+
endPosition = texto.length;
|
|
70
|
+
for (let i = 0; i < texto.length; i++) {
|
|
71
|
+
const index = i + 1;
|
|
72
|
+
if (index >= startPosition && index <= endPosition) {
|
|
73
|
+
const letra = texto[i];
|
|
74
|
+
retorno += letra;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return retorno;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/utils/pafLeft.ts
|
|
81
|
+
function padLeft(numero, size) {
|
|
82
|
+
let numeroPadLeft = `${numero}`;
|
|
83
|
+
while (numeroPadLeft.length < size)
|
|
84
|
+
numeroPadLeft = `0${numeroPadLeft}`;
|
|
85
|
+
return numeroPadLeft;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/ailos/gerarDadosBoleto.ts
|
|
89
|
+
function gerarDadosBoleto(cedente, parcela) {
|
|
90
|
+
return __async(this, null, function* () {
|
|
91
|
+
try {
|
|
92
|
+
parcela.valor = Number(parcela.valor);
|
|
93
|
+
const fatorVencimento = getFatorVencimento(parcela.vencimento);
|
|
94
|
+
const valor = getValor(parcela.valor);
|
|
95
|
+
const convenio = padLeft(cedente.convenio, 6);
|
|
96
|
+
const numeroDocumento = padLeft(`${parcela.id_boleto}`, 9);
|
|
97
|
+
const nossoNumero = padLeft(cedente.numero + cedente.numero_dv, 8) + numeroDocumento;
|
|
98
|
+
const campoLivre = convenio + nossoNumero + padLeft(cedente.carteira, 2);
|
|
99
|
+
const digitoGeral = getDigitoGeral(`0859${fatorVencimento}${valor}${campoLivre}`);
|
|
100
|
+
const codigoBarra2 = `0859${digitoGeral}${fatorVencimento}${valor}${campoLivre}`;
|
|
101
|
+
const campo1 = copy(codigoBarra2, 1, 3) + copy(codigoBarra2, 4, 4) + copy(codigoBarra2, 20, 24);
|
|
102
|
+
const campo2 = copy(codigoBarra2, 25, 34);
|
|
103
|
+
const campo3 = copy(codigoBarra2, 35, 44);
|
|
104
|
+
const campo4 = copy(codigoBarra2, 5, 5);
|
|
105
|
+
const campo5 = copy(codigoBarra2, 6, 9) + copy(codigoBarra2, 10, 19);
|
|
106
|
+
const digito1 = getDigito(campo1);
|
|
107
|
+
const digito2 = getDigito(campo2);
|
|
108
|
+
const digito3 = getDigito(campo3);
|
|
109
|
+
const digito4 = getDigito(campo4);
|
|
110
|
+
const dados = {
|
|
111
|
+
fatorVencimento,
|
|
112
|
+
valor,
|
|
113
|
+
convenio,
|
|
114
|
+
nossoNumero,
|
|
115
|
+
campoLivre,
|
|
116
|
+
digitoGeral,
|
|
117
|
+
codigoBarra: codigoBarra2,
|
|
118
|
+
numeroDocumento,
|
|
119
|
+
campo1,
|
|
120
|
+
campo2,
|
|
121
|
+
campo3,
|
|
122
|
+
campo4,
|
|
123
|
+
campo5,
|
|
124
|
+
digito1,
|
|
125
|
+
digito2,
|
|
126
|
+
digito3,
|
|
127
|
+
digito4
|
|
128
|
+
};
|
|
129
|
+
return dados;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.log("Falha ao gerar dados do boleto", error);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function getFatorVencimento(vencimento) {
|
|
137
|
+
const data = new Date(1997, 9, 7);
|
|
138
|
+
return (0, import_date_fns.differenceInDays)(new Date(vencimento), data).toString();
|
|
139
|
+
}
|
|
140
|
+
function getValor(valor) {
|
|
141
|
+
const valorFormatado = valor.toFixed(2).replace(/\D/g, "");
|
|
142
|
+
return padLeft(valorFormatado, 10);
|
|
143
|
+
}
|
|
144
|
+
function getDigitoGeral(texto) {
|
|
145
|
+
let i = 43;
|
|
146
|
+
let j = 1;
|
|
147
|
+
let soma = 0;
|
|
148
|
+
let digito = 0;
|
|
149
|
+
while (i >= 1) {
|
|
150
|
+
j++;
|
|
151
|
+
if (j === 10)
|
|
152
|
+
j = 2;
|
|
153
|
+
const valor = Number(copy(texto, i, i));
|
|
154
|
+
soma += j * valor;
|
|
155
|
+
i--;
|
|
156
|
+
}
|
|
157
|
+
const restoDivisao = soma % 11;
|
|
158
|
+
digito = 11 - restoDivisao;
|
|
159
|
+
if (digito === 0 || digito === 1 || digito > 9)
|
|
160
|
+
digito = 1;
|
|
161
|
+
return String(digito);
|
|
162
|
+
}
|
|
163
|
+
function getDigito(texto) {
|
|
164
|
+
let i = texto.length;
|
|
165
|
+
let j = 1;
|
|
166
|
+
let total = 0;
|
|
167
|
+
let soma = 0;
|
|
168
|
+
let digito = 0;
|
|
169
|
+
while (i >= 1) {
|
|
170
|
+
j = j === 1 ? 2 : 1;
|
|
171
|
+
let valor = Number(copy(texto, i, i));
|
|
172
|
+
total = valor * j;
|
|
173
|
+
if (total >= 10) {
|
|
174
|
+
valor = Number(copy(total, 1, 1)) + Number(copy(total, 2, 2));
|
|
175
|
+
} else {
|
|
176
|
+
valor = total;
|
|
177
|
+
}
|
|
178
|
+
soma += valor;
|
|
179
|
+
i--;
|
|
180
|
+
}
|
|
181
|
+
const uni = Number(copy(soma, String(soma).length, String(soma).length));
|
|
182
|
+
digito = 10 - uni;
|
|
183
|
+
if (digito === 10)
|
|
184
|
+
digito = 0;
|
|
185
|
+
return String(digito);
|
|
186
|
+
}
|
|
187
|
+
|
|
40
188
|
// src/ailos/gerarPDF.ts
|
|
189
|
+
var import_path = __toESM(require("path"));
|
|
41
190
|
var import_bwip_js = __toESM(require("bwip-js"));
|
|
42
191
|
|
|
43
192
|
// src/utils/compileHbs.ts
|
|
44
193
|
var import_handlebars = __toESM(require("handlebars"));
|
|
194
|
+
var import_fs = __toESM(require("fs"));
|
|
195
|
+
function compileHbs(templatePath, data) {
|
|
196
|
+
const html = import_fs.default.readFileSync(templatePath, "utf-8");
|
|
197
|
+
const content = import_handlebars.default.compile(html)(data);
|
|
198
|
+
return content;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/utils/maskFormat.ts
|
|
202
|
+
function retornaCpfCnpjFormatado(cpfCnpj) {
|
|
203
|
+
return cpfCnpj;
|
|
204
|
+
}
|
|
205
|
+
function retornaCEPFormatado(cep) {
|
|
206
|
+
return cep;
|
|
207
|
+
}
|
|
208
|
+
function numberToReal(numero) {
|
|
209
|
+
numero = typeof numero === "string" ? parseFloat(numero) : numero;
|
|
210
|
+
numero = numero.toFixed(2).split(".");
|
|
211
|
+
numero[0] = numero[0].split(/(?=(?:...)*$)/).join(".");
|
|
212
|
+
return numero.join(",");
|
|
213
|
+
}
|
|
214
|
+
function codigoBarra(codigo) {
|
|
215
|
+
return codigo;
|
|
216
|
+
}
|
|
217
|
+
var maskFormat_default = {
|
|
218
|
+
numberToReal,
|
|
219
|
+
retornaCEPFormatado,
|
|
220
|
+
retornaCpfCnpjFormatado,
|
|
221
|
+
codigoBarra
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/ailos/gerarPDF.ts
|
|
225
|
+
function gerarPDF(dados) {
|
|
226
|
+
return __async(this, null, function* () {
|
|
227
|
+
try {
|
|
228
|
+
const codigoBarra2 = yield import_bwip_js.default.toBuffer({
|
|
229
|
+
bcid: "interleaved2of5",
|
|
230
|
+
text: dados.boleto.codigoBarra,
|
|
231
|
+
height: 20
|
|
232
|
+
});
|
|
233
|
+
dados.beneficiario.dadosBancarios.agencia = dados.beneficiario.dadosBancarios.agencia.padStart(4, "0");
|
|
234
|
+
dados.beneficiario.dadosBancarios.conta = dados.beneficiario.dadosBancarios.conta.padStart(7, "0");
|
|
235
|
+
dados.boleto.codigoBarra = maskFormat_default.codigoBarra(dados.boleto.codigoBarra);
|
|
236
|
+
dados.boleto.codigoBarraImage = codigoBarra2.toString("base64");
|
|
237
|
+
dados.beneficiario.cnpj = maskFormat_default.retornaCpfCnpjFormatado(
|
|
238
|
+
dados.beneficiario.cnpj
|
|
239
|
+
);
|
|
240
|
+
dados.beneficiario.endereco.cep = maskFormat_default.retornaCEPFormatado(
|
|
241
|
+
dados.beneficiario.endereco.cep
|
|
242
|
+
);
|
|
243
|
+
dados.pagador.endereco.cep = maskFormat_default.retornaCEPFormatado(
|
|
244
|
+
dados.pagador.endereco.cep
|
|
245
|
+
);
|
|
246
|
+
dados.boleto.valorAcrescimo = maskFormat_default.numberToReal(
|
|
247
|
+
dados.boleto.valorAcrescimo
|
|
248
|
+
);
|
|
249
|
+
dados.boleto.valorCobrado = maskFormat_default.numberToReal(
|
|
250
|
+
dados.boleto.valorCobrado
|
|
251
|
+
);
|
|
252
|
+
dados.boleto.valorDescontoAbatimento = maskFormat_default.numberToReal(
|
|
253
|
+
dados.boleto.valorDescontoAbatimento
|
|
254
|
+
);
|
|
255
|
+
dados.boleto.valorDocumento = maskFormat_default.numberToReal(
|
|
256
|
+
dados.boleto.valorDocumento
|
|
257
|
+
);
|
|
258
|
+
dados.boleto.valorMulta = maskFormat_default.numberToReal(dados.boleto.valorMulta);
|
|
259
|
+
dados.boleto.valorOutrasDeducoes = maskFormat_default.numberToReal(
|
|
260
|
+
dados.boleto.valorOutrasDeducoes
|
|
261
|
+
);
|
|
262
|
+
if (dados.boleto.quantidade) {
|
|
263
|
+
dados.boleto.quantidade = maskFormat_default.numberToReal(dados.boleto.quantidade);
|
|
264
|
+
}
|
|
265
|
+
dados.boleto.valor = maskFormat_default.numberToReal(dados.boleto.valor);
|
|
266
|
+
const filePath = import_path.default.join(__dirname, "views", "boleto.hbs");
|
|
267
|
+
const content = compileHbs(filePath, dados);
|
|
268
|
+
const config = {
|
|
269
|
+
displayHeaderFooter: false,
|
|
270
|
+
path: "./boleto.pdf",
|
|
271
|
+
format: "a4",
|
|
272
|
+
printBackground: true
|
|
273
|
+
};
|
|
274
|
+
return {
|
|
275
|
+
erro: false
|
|
276
|
+
// dados: response.data,
|
|
277
|
+
};
|
|
278
|
+
} catch (error) {
|
|
279
|
+
return {
|
|
280
|
+
erro: true,
|
|
281
|
+
dados: null
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
45
286
|
|
|
46
287
|
// src/ailos/gerarRemessa.ts
|
|
47
288
|
var import_date_fns2 = require("date-fns");
|
|
48
289
|
|
|
290
|
+
// src/lib/Arquivo.ts
|
|
291
|
+
var Arquivo = class {
|
|
292
|
+
constructor() {
|
|
293
|
+
this.arquivo = "";
|
|
294
|
+
this.arquivo = "";
|
|
295
|
+
}
|
|
296
|
+
add(texto) {
|
|
297
|
+
this.arquivo += texto;
|
|
298
|
+
}
|
|
299
|
+
addLine() {
|
|
300
|
+
this.arquivo += "\n";
|
|
301
|
+
}
|
|
302
|
+
getArquivo() {
|
|
303
|
+
return this.arquivo;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/ailos/gerarRemessa.ts
|
|
308
|
+
function gerarRemessa(dados) {
|
|
309
|
+
return __async(this, null, function* () {
|
|
310
|
+
try {
|
|
311
|
+
const { dadosBancario, beneficiario, boletos, pagador } = dados;
|
|
312
|
+
const arquivo = new Arquivo();
|
|
313
|
+
const dataAtual = /* @__PURE__ */ new Date();
|
|
314
|
+
const data = (0, import_date_fns2.format)(dataAtual, "ddMMyyyy");
|
|
315
|
+
const hora = (0, import_date_fns2.format)(dataAtual, "HHmmss");
|
|
316
|
+
const convenio = dadosBancario.convenio.padStart(7, "0");
|
|
317
|
+
const numero = dadosBancario.conta.padStart(7, "0") + dadosBancario.contaDigito;
|
|
318
|
+
const remessa = `REM${convenio}-${numero}-${data}.REM`;
|
|
319
|
+
arquivo.add("085");
|
|
320
|
+
arquivo.add("0000");
|
|
321
|
+
arquivo.add("0");
|
|
322
|
+
arquivo.add(" ");
|
|
323
|
+
arquivo.add("2");
|
|
324
|
+
arquivo.add(beneficiario.cnpj);
|
|
325
|
+
arquivo.add(dadosBancario.convenio.padEnd(20, " "));
|
|
326
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
327
|
+
arquivo.add(dadosBancario.agencia);
|
|
328
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
329
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
330
|
+
arquivo.add(" ");
|
|
331
|
+
arquivo.add(beneficiario.nome.substring(0, 30).padEnd(30, " "));
|
|
332
|
+
arquivo.add("AILOS".padEnd(30, " "));
|
|
333
|
+
arquivo.add(" ");
|
|
334
|
+
arquivo.add("1");
|
|
335
|
+
arquivo.add(data);
|
|
336
|
+
arquivo.add(hora);
|
|
337
|
+
arquivo.add(dadosBancario.numeroRemessa.padStart(6, "0"));
|
|
338
|
+
arquivo.add("087");
|
|
339
|
+
arquivo.add("00000");
|
|
340
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
341
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
342
|
+
arquivo.add(" ".padEnd(29, " "));
|
|
343
|
+
arquivo.addLine();
|
|
344
|
+
arquivo.add("085");
|
|
345
|
+
arquivo.add("0001");
|
|
346
|
+
arquivo.add("1");
|
|
347
|
+
arquivo.add("R");
|
|
348
|
+
arquivo.add("01");
|
|
349
|
+
arquivo.add(" ");
|
|
350
|
+
arquivo.add("045");
|
|
351
|
+
arquivo.add(" ");
|
|
352
|
+
arquivo.add("2");
|
|
353
|
+
arquivo.add(beneficiario.cnpj.padStart(15, "0"));
|
|
354
|
+
arquivo.add(dadosBancario.convenio.padEnd(20, " "));
|
|
355
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
356
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
357
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
358
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
359
|
+
arquivo.add(" ");
|
|
360
|
+
arquivo.add(pagador.nome.substring(0, 30).padEnd(30, " "));
|
|
361
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
362
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
363
|
+
arquivo.add(dadosBancario.numeroRemessa.padStart(8, "0"));
|
|
364
|
+
arquivo.add(data);
|
|
365
|
+
arquivo.add("00000000");
|
|
366
|
+
arquivo.add(" ".padEnd(33, " "));
|
|
367
|
+
arquivo.addLine();
|
|
368
|
+
let sequencia = 1;
|
|
369
|
+
let quantidadeRegistro = 1;
|
|
370
|
+
let total = 0;
|
|
371
|
+
for (const boleto of boletos) {
|
|
372
|
+
const vencimento = (0, import_date_fns2.format)(new Date(boleto.vencimento), "ddMMyyyy");
|
|
373
|
+
total += Number(boleto.valor);
|
|
374
|
+
const codigoJuro = dadosBancario.jurosMes > 0 ? "2" : "3";
|
|
375
|
+
const juros = dadosBancario.jurosMes > 0 ? dadosBancario.jurosMes.toFixed(2) : "000000000000000";
|
|
376
|
+
const jurosVencimento = (0, import_date_fns2.format)(
|
|
377
|
+
(0, import_date_fns2.addDays)(new Date(boleto.vencimento), 1),
|
|
378
|
+
"ddMMyyyy"
|
|
379
|
+
);
|
|
380
|
+
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
381
|
+
const desconto = dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
382
|
+
const protesto = dadosBancario.diasProtesto > 0 ? "1" : "3";
|
|
383
|
+
const diasProtesto = protesto === "1" ? dadosBancario.diasProtesto.toString() : "00";
|
|
384
|
+
arquivo.add("085");
|
|
385
|
+
arquivo.add("0001");
|
|
386
|
+
arquivo.add("3");
|
|
387
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
388
|
+
arquivo.add("P");
|
|
389
|
+
arquivo.add(" ");
|
|
390
|
+
arquivo.add("01");
|
|
391
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
392
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
393
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
394
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
395
|
+
arquivo.add(" ");
|
|
396
|
+
arquivo.add(boleto.nossoNumero.padEnd(20, " "));
|
|
397
|
+
arquivo.add("1");
|
|
398
|
+
arquivo.add("1");
|
|
399
|
+
arquivo.add("1");
|
|
400
|
+
arquivo.add("2");
|
|
401
|
+
arquivo.add("2");
|
|
402
|
+
arquivo.add(`${boleto.numeroDocumento}/${boleto.parcela}`.padEnd(15, " "));
|
|
403
|
+
arquivo.add(vencimento);
|
|
404
|
+
arquivo.add(
|
|
405
|
+
Number(boleto.valor).toFixed(2).replace(".", "").padStart(15, "0")
|
|
406
|
+
);
|
|
407
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
408
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
409
|
+
arquivo.add("02");
|
|
410
|
+
arquivo.add("A");
|
|
411
|
+
arquivo.add(data);
|
|
412
|
+
arquivo.add(codigoJuro);
|
|
413
|
+
arquivo.add(jurosVencimento);
|
|
414
|
+
arquivo.add(juros.replace(".", "").padStart(15, "0"));
|
|
415
|
+
arquivo.add(codigoDesconto);
|
|
416
|
+
arquivo.add(vencimento);
|
|
417
|
+
arquivo.add(desconto.replace(".", "").padStart(15, "0"));
|
|
418
|
+
arquivo.add("000000000000000");
|
|
419
|
+
arquivo.add("000000000000000");
|
|
420
|
+
arquivo.add(boleto.identificacaoTitulo.padEnd(25, " "));
|
|
421
|
+
arquivo.add(protesto);
|
|
422
|
+
arquivo.add(diasProtesto.padStart(1, "0"));
|
|
423
|
+
arquivo.add("2");
|
|
424
|
+
arquivo.add(" ");
|
|
425
|
+
arquivo.add("09");
|
|
426
|
+
arquivo.add("0000000000");
|
|
427
|
+
arquivo.add(" ");
|
|
428
|
+
sequencia++;
|
|
429
|
+
arquivo.addLine();
|
|
430
|
+
let tipoInscricao = "1";
|
|
431
|
+
if (pagador.pessoa === "F") {
|
|
432
|
+
tipoInscricao = "1";
|
|
433
|
+
} else {
|
|
434
|
+
tipoInscricao = "2";
|
|
435
|
+
}
|
|
436
|
+
pagador.endereco.logradouro = `${pagador.endereco.logradouro.substring(0, 32).padEnd(32, " ")}${pagador.endereco.numero.padEnd(8, " ")}`;
|
|
437
|
+
arquivo.add("085");
|
|
438
|
+
arquivo.add("0001");
|
|
439
|
+
arquivo.add("3");
|
|
440
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
441
|
+
arquivo.add("Q");
|
|
442
|
+
arquivo.add(" ");
|
|
443
|
+
arquivo.add("01");
|
|
444
|
+
arquivo.add(tipoInscricao);
|
|
445
|
+
arquivo.add(pagador.cpfCnpj.padStart(15, "0"));
|
|
446
|
+
arquivo.add(pagador.nome.substring(0, 40).padEnd(40, " "));
|
|
447
|
+
arquivo.add(pagador.endereco.logradouro.substring(0, 40).padEnd(40, " "));
|
|
448
|
+
arquivo.add(pagador.endereco.bairro.substring(0, 15).padEnd(15, " "));
|
|
449
|
+
arquivo.add(pagador.endereco.cep.substring(0, 5).padStart(5, "0"));
|
|
450
|
+
arquivo.add(pagador.endereco.cep.substring(5, 7).padStart(3, "0"));
|
|
451
|
+
arquivo.add(pagador.endereco.municipio.substring(0, 15).padEnd(15, " "));
|
|
452
|
+
arquivo.add(pagador.endereco.uf.padEnd(2, " "));
|
|
453
|
+
arquivo.add("0");
|
|
454
|
+
arquivo.add("000000000000000");
|
|
455
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
456
|
+
arquivo.add("000");
|
|
457
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
458
|
+
arquivo.add(" ".padEnd(8, " "));
|
|
459
|
+
dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
|
|
460
|
+
if (dadosBancario.multaAtraso > 0) {
|
|
461
|
+
arquivo.addLine();
|
|
462
|
+
const multa = dadosBancario.multaAtraso.toFixed(2);
|
|
463
|
+
sequencia++;
|
|
464
|
+
arquivo.add("085");
|
|
465
|
+
arquivo.add("0001");
|
|
466
|
+
arquivo.add("3");
|
|
467
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
468
|
+
arquivo.add("R");
|
|
469
|
+
arquivo.add(" ");
|
|
470
|
+
arquivo.add("01");
|
|
471
|
+
arquivo.add("0");
|
|
472
|
+
arquivo.add("00000000");
|
|
473
|
+
arquivo.add("000000000000000");
|
|
474
|
+
arquivo.add("0");
|
|
475
|
+
arquivo.add("00000000");
|
|
476
|
+
arquivo.add("000000000000000");
|
|
477
|
+
arquivo.add("2");
|
|
478
|
+
arquivo.add(vencimento);
|
|
479
|
+
arquivo.add(multa.replace(".", "").padStart(15, "0"));
|
|
480
|
+
arquivo.add(" ".padEnd(10, " "));
|
|
481
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
482
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
483
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
484
|
+
arquivo.add("00000000");
|
|
485
|
+
arquivo.add("000");
|
|
486
|
+
arquivo.add("00000");
|
|
487
|
+
arquivo.add(" ");
|
|
488
|
+
arquivo.add("000000000000");
|
|
489
|
+
arquivo.add(" ");
|
|
490
|
+
arquivo.add(" ");
|
|
491
|
+
arquivo.add("0");
|
|
492
|
+
arquivo.add("000000000");
|
|
493
|
+
}
|
|
494
|
+
arquivo.addLine();
|
|
495
|
+
quantidadeRegistro++;
|
|
496
|
+
}
|
|
497
|
+
arquivo.add("085");
|
|
498
|
+
arquivo.add("0001");
|
|
499
|
+
arquivo.add("5");
|
|
500
|
+
arquivo.add(" ".padEnd(9, " "));
|
|
501
|
+
arquivo.add((sequencia + 3).toString().padStart(6, "0"));
|
|
502
|
+
arquivo.add(quantidadeRegistro.toString().padStart(6, "0"));
|
|
503
|
+
arquivo.add(total.toFixed(2).replace(".", "").padStart(17, "0"));
|
|
504
|
+
arquivo.add("0".padStart(6, "0"));
|
|
505
|
+
arquivo.add("0".padStart(17, "0"));
|
|
506
|
+
arquivo.add("0".padStart(6, "0"));
|
|
507
|
+
arquivo.add("0".padStart(17, "0"));
|
|
508
|
+
arquivo.add("0".padStart(6, "0"));
|
|
509
|
+
arquivo.add("0".padStart(17, "0"));
|
|
510
|
+
arquivo.add(" ".padStart(8, " "));
|
|
511
|
+
arquivo.add(" ".padStart(117, " "));
|
|
512
|
+
arquivo.addLine();
|
|
513
|
+
arquivo.add("085");
|
|
514
|
+
arquivo.add("9999");
|
|
515
|
+
arquivo.add("9");
|
|
516
|
+
arquivo.add(" ".padEnd(9, " "));
|
|
517
|
+
arquivo.add("000001");
|
|
518
|
+
arquivo.add((sequencia + 4).toString().padStart(6, "0"));
|
|
519
|
+
arquivo.add("000000");
|
|
520
|
+
arquivo.add(" ".padEnd(205, " "));
|
|
521
|
+
return {
|
|
522
|
+
download: remessa,
|
|
523
|
+
arquivo: arquivo.getArquivo()
|
|
524
|
+
};
|
|
525
|
+
} catch (error) {
|
|
526
|
+
console.log(error);
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
49
532
|
// src/bradesco/index.ts
|
|
50
533
|
function bradesco() {
|
|
51
534
|
console.log("bradesco");
|
|
52
535
|
}
|
|
53
536
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
537
|
0 && (module.exports = {
|
|
55
|
-
bradesco
|
|
538
|
+
bradesco,
|
|
539
|
+
gerarDadosBoleto,
|
|
540
|
+
gerarPDF,
|
|
541
|
+
gerarRemessa
|
|
56
542
|
});
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/ailos/gerarDadosBoleto.ts
|
|
23
|
+
import { differenceInDays } from "date-fns";
|
|
24
|
+
|
|
25
|
+
// src/utils/copy.ts
|
|
26
|
+
function copy(texto, startPosition, endPosition) {
|
|
27
|
+
let retorno = "";
|
|
28
|
+
if (typeof texto === "number")
|
|
29
|
+
texto = String(texto);
|
|
30
|
+
if (!endPosition)
|
|
31
|
+
endPosition = texto.length;
|
|
32
|
+
for (let i = 0; i < texto.length; i++) {
|
|
33
|
+
const index = i + 1;
|
|
34
|
+
if (index >= startPosition && index <= endPosition) {
|
|
35
|
+
const letra = texto[i];
|
|
36
|
+
retorno += letra;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return retorno;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/utils/pafLeft.ts
|
|
43
|
+
function padLeft(numero, size) {
|
|
44
|
+
let numeroPadLeft = `${numero}`;
|
|
45
|
+
while (numeroPadLeft.length < size)
|
|
46
|
+
numeroPadLeft = `0${numeroPadLeft}`;
|
|
47
|
+
return numeroPadLeft;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/ailos/gerarDadosBoleto.ts
|
|
51
|
+
function gerarDadosBoleto(cedente, parcela) {
|
|
52
|
+
return __async(this, null, function* () {
|
|
53
|
+
try {
|
|
54
|
+
parcela.valor = Number(parcela.valor);
|
|
55
|
+
const fatorVencimento = getFatorVencimento(parcela.vencimento);
|
|
56
|
+
const valor = getValor(parcela.valor);
|
|
57
|
+
const convenio = padLeft(cedente.convenio, 6);
|
|
58
|
+
const numeroDocumento = padLeft(`${parcela.id_boleto}`, 9);
|
|
59
|
+
const nossoNumero = padLeft(cedente.numero + cedente.numero_dv, 8) + numeroDocumento;
|
|
60
|
+
const campoLivre = convenio + nossoNumero + padLeft(cedente.carteira, 2);
|
|
61
|
+
const digitoGeral = getDigitoGeral(`0859${fatorVencimento}${valor}${campoLivre}`);
|
|
62
|
+
const codigoBarra2 = `0859${digitoGeral}${fatorVencimento}${valor}${campoLivre}`;
|
|
63
|
+
const campo1 = copy(codigoBarra2, 1, 3) + copy(codigoBarra2, 4, 4) + copy(codigoBarra2, 20, 24);
|
|
64
|
+
const campo2 = copy(codigoBarra2, 25, 34);
|
|
65
|
+
const campo3 = copy(codigoBarra2, 35, 44);
|
|
66
|
+
const campo4 = copy(codigoBarra2, 5, 5);
|
|
67
|
+
const campo5 = copy(codigoBarra2, 6, 9) + copy(codigoBarra2, 10, 19);
|
|
68
|
+
const digito1 = getDigito(campo1);
|
|
69
|
+
const digito2 = getDigito(campo2);
|
|
70
|
+
const digito3 = getDigito(campo3);
|
|
71
|
+
const digito4 = getDigito(campo4);
|
|
72
|
+
const dados = {
|
|
73
|
+
fatorVencimento,
|
|
74
|
+
valor,
|
|
75
|
+
convenio,
|
|
76
|
+
nossoNumero,
|
|
77
|
+
campoLivre,
|
|
78
|
+
digitoGeral,
|
|
79
|
+
codigoBarra: codigoBarra2,
|
|
80
|
+
numeroDocumento,
|
|
81
|
+
campo1,
|
|
82
|
+
campo2,
|
|
83
|
+
campo3,
|
|
84
|
+
campo4,
|
|
85
|
+
campo5,
|
|
86
|
+
digito1,
|
|
87
|
+
digito2,
|
|
88
|
+
digito3,
|
|
89
|
+
digito4
|
|
90
|
+
};
|
|
91
|
+
return dados;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.log("Falha ao gerar dados do boleto", error);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function getFatorVencimento(vencimento) {
|
|
99
|
+
const data = new Date(1997, 9, 7);
|
|
100
|
+
return differenceInDays(new Date(vencimento), data).toString();
|
|
101
|
+
}
|
|
102
|
+
function getValor(valor) {
|
|
103
|
+
const valorFormatado = valor.toFixed(2).replace(/\D/g, "");
|
|
104
|
+
return padLeft(valorFormatado, 10);
|
|
105
|
+
}
|
|
106
|
+
function getDigitoGeral(texto) {
|
|
107
|
+
let i = 43;
|
|
108
|
+
let j = 1;
|
|
109
|
+
let soma = 0;
|
|
110
|
+
let digito = 0;
|
|
111
|
+
while (i >= 1) {
|
|
112
|
+
j++;
|
|
113
|
+
if (j === 10)
|
|
114
|
+
j = 2;
|
|
115
|
+
const valor = Number(copy(texto, i, i));
|
|
116
|
+
soma += j * valor;
|
|
117
|
+
i--;
|
|
118
|
+
}
|
|
119
|
+
const restoDivisao = soma % 11;
|
|
120
|
+
digito = 11 - restoDivisao;
|
|
121
|
+
if (digito === 0 || digito === 1 || digito > 9)
|
|
122
|
+
digito = 1;
|
|
123
|
+
return String(digito);
|
|
124
|
+
}
|
|
125
|
+
function getDigito(texto) {
|
|
126
|
+
let i = texto.length;
|
|
127
|
+
let j = 1;
|
|
128
|
+
let total = 0;
|
|
129
|
+
let soma = 0;
|
|
130
|
+
let digito = 0;
|
|
131
|
+
while (i >= 1) {
|
|
132
|
+
j = j === 1 ? 2 : 1;
|
|
133
|
+
let valor = Number(copy(texto, i, i));
|
|
134
|
+
total = valor * j;
|
|
135
|
+
if (total >= 10) {
|
|
136
|
+
valor = Number(copy(total, 1, 1)) + Number(copy(total, 2, 2));
|
|
137
|
+
} else {
|
|
138
|
+
valor = total;
|
|
139
|
+
}
|
|
140
|
+
soma += valor;
|
|
141
|
+
i--;
|
|
142
|
+
}
|
|
143
|
+
const uni = Number(copy(soma, String(soma).length, String(soma).length));
|
|
144
|
+
digito = 10 - uni;
|
|
145
|
+
if (digito === 10)
|
|
146
|
+
digito = 0;
|
|
147
|
+
return String(digito);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/ailos/gerarPDF.ts
|
|
151
|
+
import path from "path";
|
|
152
|
+
import BwipJs from "bwip-js";
|
|
153
|
+
|
|
154
|
+
// src/utils/compileHbs.ts
|
|
155
|
+
import hbs from "handlebars";
|
|
156
|
+
import fs from "fs";
|
|
157
|
+
function compileHbs(templatePath, data) {
|
|
158
|
+
const html = fs.readFileSync(templatePath, "utf-8");
|
|
159
|
+
const content = hbs.compile(html)(data);
|
|
160
|
+
return content;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/utils/maskFormat.ts
|
|
164
|
+
function retornaCpfCnpjFormatado(cpfCnpj) {
|
|
165
|
+
return cpfCnpj;
|
|
166
|
+
}
|
|
167
|
+
function retornaCEPFormatado(cep) {
|
|
168
|
+
return cep;
|
|
169
|
+
}
|
|
170
|
+
function numberToReal(numero) {
|
|
171
|
+
numero = typeof numero === "string" ? parseFloat(numero) : numero;
|
|
172
|
+
numero = numero.toFixed(2).split(".");
|
|
173
|
+
numero[0] = numero[0].split(/(?=(?:...)*$)/).join(".");
|
|
174
|
+
return numero.join(",");
|
|
175
|
+
}
|
|
176
|
+
function codigoBarra(codigo) {
|
|
177
|
+
return codigo;
|
|
178
|
+
}
|
|
179
|
+
var maskFormat_default = {
|
|
180
|
+
numberToReal,
|
|
181
|
+
retornaCEPFormatado,
|
|
182
|
+
retornaCpfCnpjFormatado,
|
|
183
|
+
codigoBarra
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/ailos/gerarPDF.ts
|
|
187
|
+
function gerarPDF(dados) {
|
|
188
|
+
return __async(this, null, function* () {
|
|
189
|
+
try {
|
|
190
|
+
const codigoBarra2 = yield BwipJs.toBuffer({
|
|
191
|
+
bcid: "interleaved2of5",
|
|
192
|
+
text: dados.boleto.codigoBarra,
|
|
193
|
+
height: 20
|
|
194
|
+
});
|
|
195
|
+
dados.beneficiario.dadosBancarios.agencia = dados.beneficiario.dadosBancarios.agencia.padStart(4, "0");
|
|
196
|
+
dados.beneficiario.dadosBancarios.conta = dados.beneficiario.dadosBancarios.conta.padStart(7, "0");
|
|
197
|
+
dados.boleto.codigoBarra = maskFormat_default.codigoBarra(dados.boleto.codigoBarra);
|
|
198
|
+
dados.boleto.codigoBarraImage = codigoBarra2.toString("base64");
|
|
199
|
+
dados.beneficiario.cnpj = maskFormat_default.retornaCpfCnpjFormatado(
|
|
200
|
+
dados.beneficiario.cnpj
|
|
201
|
+
);
|
|
202
|
+
dados.beneficiario.endereco.cep = maskFormat_default.retornaCEPFormatado(
|
|
203
|
+
dados.beneficiario.endereco.cep
|
|
204
|
+
);
|
|
205
|
+
dados.pagador.endereco.cep = maskFormat_default.retornaCEPFormatado(
|
|
206
|
+
dados.pagador.endereco.cep
|
|
207
|
+
);
|
|
208
|
+
dados.boleto.valorAcrescimo = maskFormat_default.numberToReal(
|
|
209
|
+
dados.boleto.valorAcrescimo
|
|
210
|
+
);
|
|
211
|
+
dados.boleto.valorCobrado = maskFormat_default.numberToReal(
|
|
212
|
+
dados.boleto.valorCobrado
|
|
213
|
+
);
|
|
214
|
+
dados.boleto.valorDescontoAbatimento = maskFormat_default.numberToReal(
|
|
215
|
+
dados.boleto.valorDescontoAbatimento
|
|
216
|
+
);
|
|
217
|
+
dados.boleto.valorDocumento = maskFormat_default.numberToReal(
|
|
218
|
+
dados.boleto.valorDocumento
|
|
219
|
+
);
|
|
220
|
+
dados.boleto.valorMulta = maskFormat_default.numberToReal(dados.boleto.valorMulta);
|
|
221
|
+
dados.boleto.valorOutrasDeducoes = maskFormat_default.numberToReal(
|
|
222
|
+
dados.boleto.valorOutrasDeducoes
|
|
223
|
+
);
|
|
224
|
+
if (dados.boleto.quantidade) {
|
|
225
|
+
dados.boleto.quantidade = maskFormat_default.numberToReal(dados.boleto.quantidade);
|
|
226
|
+
}
|
|
227
|
+
dados.boleto.valor = maskFormat_default.numberToReal(dados.boleto.valor);
|
|
228
|
+
const filePath = path.join(__dirname, "views", "boleto.hbs");
|
|
229
|
+
const content = compileHbs(filePath, dados);
|
|
230
|
+
const config = {
|
|
231
|
+
displayHeaderFooter: false,
|
|
232
|
+
path: "./boleto.pdf",
|
|
233
|
+
format: "a4",
|
|
234
|
+
printBackground: true
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
erro: false
|
|
238
|
+
// dados: response.data,
|
|
239
|
+
};
|
|
240
|
+
} catch (error) {
|
|
241
|
+
return {
|
|
242
|
+
erro: true,
|
|
243
|
+
dados: null
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/ailos/gerarRemessa.ts
|
|
250
|
+
import { addDays, format } from "date-fns";
|
|
251
|
+
|
|
252
|
+
// src/lib/Arquivo.ts
|
|
253
|
+
var Arquivo = class {
|
|
254
|
+
constructor() {
|
|
255
|
+
this.arquivo = "";
|
|
256
|
+
this.arquivo = "";
|
|
257
|
+
}
|
|
258
|
+
add(texto) {
|
|
259
|
+
this.arquivo += texto;
|
|
260
|
+
}
|
|
261
|
+
addLine() {
|
|
262
|
+
this.arquivo += "\n";
|
|
263
|
+
}
|
|
264
|
+
getArquivo() {
|
|
265
|
+
return this.arquivo;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/ailos/gerarRemessa.ts
|
|
270
|
+
function gerarRemessa(dados) {
|
|
271
|
+
return __async(this, null, function* () {
|
|
272
|
+
try {
|
|
273
|
+
const { dadosBancario, beneficiario, boletos, pagador } = dados;
|
|
274
|
+
const arquivo = new Arquivo();
|
|
275
|
+
const dataAtual = /* @__PURE__ */ new Date();
|
|
276
|
+
const data = format(dataAtual, "ddMMyyyy");
|
|
277
|
+
const hora = format(dataAtual, "HHmmss");
|
|
278
|
+
const convenio = dadosBancario.convenio.padStart(7, "0");
|
|
279
|
+
const numero = dadosBancario.conta.padStart(7, "0") + dadosBancario.contaDigito;
|
|
280
|
+
const remessa = `REM${convenio}-${numero}-${data}.REM`;
|
|
281
|
+
arquivo.add("085");
|
|
282
|
+
arquivo.add("0000");
|
|
283
|
+
arquivo.add("0");
|
|
284
|
+
arquivo.add(" ");
|
|
285
|
+
arquivo.add("2");
|
|
286
|
+
arquivo.add(beneficiario.cnpj);
|
|
287
|
+
arquivo.add(dadosBancario.convenio.padEnd(20, " "));
|
|
288
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
289
|
+
arquivo.add(dadosBancario.agencia);
|
|
290
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
291
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
292
|
+
arquivo.add(" ");
|
|
293
|
+
arquivo.add(beneficiario.nome.substring(0, 30).padEnd(30, " "));
|
|
294
|
+
arquivo.add("AILOS".padEnd(30, " "));
|
|
295
|
+
arquivo.add(" ");
|
|
296
|
+
arquivo.add("1");
|
|
297
|
+
arquivo.add(data);
|
|
298
|
+
arquivo.add(hora);
|
|
299
|
+
arquivo.add(dadosBancario.numeroRemessa.padStart(6, "0"));
|
|
300
|
+
arquivo.add("087");
|
|
301
|
+
arquivo.add("00000");
|
|
302
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
303
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
304
|
+
arquivo.add(" ".padEnd(29, " "));
|
|
305
|
+
arquivo.addLine();
|
|
306
|
+
arquivo.add("085");
|
|
307
|
+
arquivo.add("0001");
|
|
308
|
+
arquivo.add("1");
|
|
309
|
+
arquivo.add("R");
|
|
310
|
+
arquivo.add("01");
|
|
311
|
+
arquivo.add(" ");
|
|
312
|
+
arquivo.add("045");
|
|
313
|
+
arquivo.add(" ");
|
|
314
|
+
arquivo.add("2");
|
|
315
|
+
arquivo.add(beneficiario.cnpj.padStart(15, "0"));
|
|
316
|
+
arquivo.add(dadosBancario.convenio.padEnd(20, " "));
|
|
317
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
318
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
319
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
320
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
321
|
+
arquivo.add(" ");
|
|
322
|
+
arquivo.add(pagador.nome.substring(0, 30).padEnd(30, " "));
|
|
323
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
324
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
325
|
+
arquivo.add(dadosBancario.numeroRemessa.padStart(8, "0"));
|
|
326
|
+
arquivo.add(data);
|
|
327
|
+
arquivo.add("00000000");
|
|
328
|
+
arquivo.add(" ".padEnd(33, " "));
|
|
329
|
+
arquivo.addLine();
|
|
330
|
+
let sequencia = 1;
|
|
331
|
+
let quantidadeRegistro = 1;
|
|
332
|
+
let total = 0;
|
|
333
|
+
for (const boleto of boletos) {
|
|
334
|
+
const vencimento = format(new Date(boleto.vencimento), "ddMMyyyy");
|
|
335
|
+
total += Number(boleto.valor);
|
|
336
|
+
const codigoJuro = dadosBancario.jurosMes > 0 ? "2" : "3";
|
|
337
|
+
const juros = dadosBancario.jurosMes > 0 ? dadosBancario.jurosMes.toFixed(2) : "000000000000000";
|
|
338
|
+
const jurosVencimento = format(
|
|
339
|
+
addDays(new Date(boleto.vencimento), 1),
|
|
340
|
+
"ddMMyyyy"
|
|
341
|
+
);
|
|
342
|
+
const codigoDesconto = dadosBancario.descontoPagamento > 0 ? "2" : "0";
|
|
343
|
+
const desconto = dadosBancario.descontoPagamento > 0 ? dadosBancario.descontoPagamento.toFixed(2) : "000000000000000";
|
|
344
|
+
const protesto = dadosBancario.diasProtesto > 0 ? "1" : "3";
|
|
345
|
+
const diasProtesto = protesto === "1" ? dadosBancario.diasProtesto.toString() : "00";
|
|
346
|
+
arquivo.add("085");
|
|
347
|
+
arquivo.add("0001");
|
|
348
|
+
arquivo.add("3");
|
|
349
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
350
|
+
arquivo.add("P");
|
|
351
|
+
arquivo.add(" ");
|
|
352
|
+
arquivo.add("01");
|
|
353
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
354
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
355
|
+
arquivo.add(dadosBancario.conta.padStart(12, "0"));
|
|
356
|
+
arquivo.add(dadosBancario.contaDigito);
|
|
357
|
+
arquivo.add(" ");
|
|
358
|
+
arquivo.add(boleto.nossoNumero.padEnd(20, " "));
|
|
359
|
+
arquivo.add("1");
|
|
360
|
+
arquivo.add("1");
|
|
361
|
+
arquivo.add("1");
|
|
362
|
+
arquivo.add("2");
|
|
363
|
+
arquivo.add("2");
|
|
364
|
+
arquivo.add(`${boleto.numeroDocumento}/${boleto.parcela}`.padEnd(15, " "));
|
|
365
|
+
arquivo.add(vencimento);
|
|
366
|
+
arquivo.add(
|
|
367
|
+
Number(boleto.valor).toFixed(2).replace(".", "").padStart(15, "0")
|
|
368
|
+
);
|
|
369
|
+
arquivo.add(dadosBancario.agencia.padStart(5, "0"));
|
|
370
|
+
arquivo.add(dadosBancario.agenciaDigito);
|
|
371
|
+
arquivo.add("02");
|
|
372
|
+
arquivo.add("A");
|
|
373
|
+
arquivo.add(data);
|
|
374
|
+
arquivo.add(codigoJuro);
|
|
375
|
+
arquivo.add(jurosVencimento);
|
|
376
|
+
arquivo.add(juros.replace(".", "").padStart(15, "0"));
|
|
377
|
+
arquivo.add(codigoDesconto);
|
|
378
|
+
arquivo.add(vencimento);
|
|
379
|
+
arquivo.add(desconto.replace(".", "").padStart(15, "0"));
|
|
380
|
+
arquivo.add("000000000000000");
|
|
381
|
+
arquivo.add("000000000000000");
|
|
382
|
+
arquivo.add(boleto.identificacaoTitulo.padEnd(25, " "));
|
|
383
|
+
arquivo.add(protesto);
|
|
384
|
+
arquivo.add(diasProtesto.padStart(1, "0"));
|
|
385
|
+
arquivo.add("2");
|
|
386
|
+
arquivo.add(" ");
|
|
387
|
+
arquivo.add("09");
|
|
388
|
+
arquivo.add("0000000000");
|
|
389
|
+
arquivo.add(" ");
|
|
390
|
+
sequencia++;
|
|
391
|
+
arquivo.addLine();
|
|
392
|
+
let tipoInscricao = "1";
|
|
393
|
+
if (pagador.pessoa === "F") {
|
|
394
|
+
tipoInscricao = "1";
|
|
395
|
+
} else {
|
|
396
|
+
tipoInscricao = "2";
|
|
397
|
+
}
|
|
398
|
+
pagador.endereco.logradouro = `${pagador.endereco.logradouro.substring(0, 32).padEnd(32, " ")}${pagador.endereco.numero.padEnd(8, " ")}`;
|
|
399
|
+
arquivo.add("085");
|
|
400
|
+
arquivo.add("0001");
|
|
401
|
+
arquivo.add("3");
|
|
402
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
403
|
+
arquivo.add("Q");
|
|
404
|
+
arquivo.add(" ");
|
|
405
|
+
arquivo.add("01");
|
|
406
|
+
arquivo.add(tipoInscricao);
|
|
407
|
+
arquivo.add(pagador.cpfCnpj.padStart(15, "0"));
|
|
408
|
+
arquivo.add(pagador.nome.substring(0, 40).padEnd(40, " "));
|
|
409
|
+
arquivo.add(pagador.endereco.logradouro.substring(0, 40).padEnd(40, " "));
|
|
410
|
+
arquivo.add(pagador.endereco.bairro.substring(0, 15).padEnd(15, " "));
|
|
411
|
+
arquivo.add(pagador.endereco.cep.substring(0, 5).padStart(5, "0"));
|
|
412
|
+
arquivo.add(pagador.endereco.cep.substring(5, 7).padStart(3, "0"));
|
|
413
|
+
arquivo.add(pagador.endereco.municipio.substring(0, 15).padEnd(15, " "));
|
|
414
|
+
arquivo.add(pagador.endereco.uf.padEnd(2, " "));
|
|
415
|
+
arquivo.add("0");
|
|
416
|
+
arquivo.add("000000000000000");
|
|
417
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
418
|
+
arquivo.add("000");
|
|
419
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
420
|
+
arquivo.add(" ".padEnd(8, " "));
|
|
421
|
+
dadosBancario.multaAtraso = Number(dadosBancario.multaAtraso || 0);
|
|
422
|
+
if (dadosBancario.multaAtraso > 0) {
|
|
423
|
+
arquivo.addLine();
|
|
424
|
+
const multa = dadosBancario.multaAtraso.toFixed(2);
|
|
425
|
+
sequencia++;
|
|
426
|
+
arquivo.add("085");
|
|
427
|
+
arquivo.add("0001");
|
|
428
|
+
arquivo.add("3");
|
|
429
|
+
arquivo.add(sequencia.toString().padStart(5, "0"));
|
|
430
|
+
arquivo.add("R");
|
|
431
|
+
arquivo.add(" ");
|
|
432
|
+
arquivo.add("01");
|
|
433
|
+
arquivo.add("0");
|
|
434
|
+
arquivo.add("00000000");
|
|
435
|
+
arquivo.add("000000000000000");
|
|
436
|
+
arquivo.add("0");
|
|
437
|
+
arquivo.add("00000000");
|
|
438
|
+
arquivo.add("000000000000000");
|
|
439
|
+
arquivo.add("2");
|
|
440
|
+
arquivo.add(vencimento);
|
|
441
|
+
arquivo.add(multa.replace(".", "").padStart(15, "0"));
|
|
442
|
+
arquivo.add(" ".padEnd(10, " "));
|
|
443
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
444
|
+
arquivo.add(" ".padEnd(40, " "));
|
|
445
|
+
arquivo.add(" ".padEnd(20, " "));
|
|
446
|
+
arquivo.add("00000000");
|
|
447
|
+
arquivo.add("000");
|
|
448
|
+
arquivo.add("00000");
|
|
449
|
+
arquivo.add(" ");
|
|
450
|
+
arquivo.add("000000000000");
|
|
451
|
+
arquivo.add(" ");
|
|
452
|
+
arquivo.add(" ");
|
|
453
|
+
arquivo.add("0");
|
|
454
|
+
arquivo.add("000000000");
|
|
455
|
+
}
|
|
456
|
+
arquivo.addLine();
|
|
457
|
+
quantidadeRegistro++;
|
|
458
|
+
}
|
|
459
|
+
arquivo.add("085");
|
|
460
|
+
arquivo.add("0001");
|
|
461
|
+
arquivo.add("5");
|
|
462
|
+
arquivo.add(" ".padEnd(9, " "));
|
|
463
|
+
arquivo.add((sequencia + 3).toString().padStart(6, "0"));
|
|
464
|
+
arquivo.add(quantidadeRegistro.toString().padStart(6, "0"));
|
|
465
|
+
arquivo.add(total.toFixed(2).replace(".", "").padStart(17, "0"));
|
|
466
|
+
arquivo.add("0".padStart(6, "0"));
|
|
467
|
+
arquivo.add("0".padStart(17, "0"));
|
|
468
|
+
arquivo.add("0".padStart(6, "0"));
|
|
469
|
+
arquivo.add("0".padStart(17, "0"));
|
|
470
|
+
arquivo.add("0".padStart(6, "0"));
|
|
471
|
+
arquivo.add("0".padStart(17, "0"));
|
|
472
|
+
arquivo.add(" ".padStart(8, " "));
|
|
473
|
+
arquivo.add(" ".padStart(117, " "));
|
|
474
|
+
arquivo.addLine();
|
|
475
|
+
arquivo.add("085");
|
|
476
|
+
arquivo.add("9999");
|
|
477
|
+
arquivo.add("9");
|
|
478
|
+
arquivo.add(" ".padEnd(9, " "));
|
|
479
|
+
arquivo.add("000001");
|
|
480
|
+
arquivo.add((sequencia + 4).toString().padStart(6, "0"));
|
|
481
|
+
arquivo.add("000000");
|
|
482
|
+
arquivo.add(" ".padEnd(205, " "));
|
|
483
|
+
return {
|
|
484
|
+
download: remessa,
|
|
485
|
+
arquivo: arquivo.getArquivo()
|
|
486
|
+
};
|
|
487
|
+
} catch (error) {
|
|
488
|
+
console.log(error);
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// src/bradesco/index.ts
|
|
495
|
+
function bradesco() {
|
|
496
|
+
console.log("bradesco");
|
|
497
|
+
}
|
|
498
|
+
export {
|
|
499
|
+
bradesco,
|
|
500
|
+
gerarDadosBoleto,
|
|
501
|
+
gerarPDF,
|
|
502
|
+
gerarRemessa
|
|
503
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasoft/boletos",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsup src/index.ts --format esm, cjs --dts --out-dir build",
|
|
8
8
|
"dev": "tsup src/index.ts --format esm, cjs --dts --out-dir build --watch",
|
|
9
|
-
"
|
|
9
|
+
"deploy": "npm run build && npm publish --access=public"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bwip-js": "^3.2.0",
|