boletos-ademitech 1.0.0
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/.eslintrc.json +25 -0
- package/LICENSE +661 -0
- package/README.md +50 -0
- package/examples/gerar-boleto-BancoDoBrasil.js +72 -0
- package/examples/gerar-boleto-bradesco.js +58 -0
- package/examples/gerar-boleto-cecred.js +59 -0
- package/index.d.ts +372 -0
- package/lib/boleto/bancos/banco-do-brasil.js +125 -0
- package/lib/boleto/bancos/bradesco.js +115 -0
- package/lib/boleto/bancos/caixa.js +140 -0
- package/lib/boleto/bancos/cecred.js +117 -0
- package/lib/boleto/bancos/itau.js +124 -0
- package/lib/boleto/bancos/logotipos/ailos.png +0 -0
- package/lib/boleto/bancos/logotipos/banco-do-brasil.png +0 -0
- package/lib/boleto/bancos/logotipos/bradesco.png +0 -0
- package/lib/boleto/bancos/logotipos/caixa-economica-federal.png +0 -0
- package/lib/boleto/bancos/logotipos/itau.png +0 -0
- package/lib/boleto/bancos/logotipos/santander.png +0 -0
- package/lib/boleto/bancos/logotipos/sicoob.png +0 -0
- package/lib/boleto/bancos/logotipos/sicredi.png +0 -0
- package/lib/boleto/bancos/santander.js +118 -0
- package/lib/boleto/bancos/sicoob.js +118 -0
- package/lib/boleto/bancos/sicredi.js +143 -0
- package/lib/boleto/codigo-de-barras-builder.js +38 -0
- package/lib/boleto/fontes/Code25I.ttf +0 -0
- package/lib/boleto/fontes/Times New Roman Bold Italic.ttf +0 -0
- package/lib/boleto/fontes/Times New Roman Bold.ttf +0 -0
- package/lib/boleto/fontes/Times New Roman Italic.ttf +0 -0
- package/lib/boleto/fontes/Times New Roman.ttf +0 -0
- package/lib/boleto/gerador-de-boleto.js +1198 -0
- package/lib/boleto/gerador-de-digito-padrao.js +42 -0
- package/lib/boleto/gerador-de-linha-digitavel.js +26 -0
- package/lib/boleto/imagens/tesoura128.png +0 -0
- package/lib/boleto/valida-codigo-barras.js +12 -0
- package/lib/index.js +14 -0
- package/lib/metodosPublicos/boletoMetodos.js +50 -0
- package/lib/pdf-gerador.js +26 -0
- package/lib/stringify/boletoStringify.js +49 -0
- package/lib/utils/array-utils.js +13 -0
- package/lib/utils/date-utils.js +8 -0
- package/lib/utils/functions/bancosUtils.js +104 -0
- package/lib/utils/functions/boletoUtils.js +895 -0
- package/lib/utils/functions/formatacoesUtils.js +287 -0
- package/lib/utils/functions/validacoesUtils.js +233 -0
- package/lib/utils/math-utils.js +53 -0
- package/lib/utils/object-utils.js +8 -0
- package/lib/utils/stream-utils.js +6 -0
- package/lib/utils/string-utils.js +60 -0
- package/package.json +60 -0
- package/tests/bancos-test.js +116 -0
- package/tests/boleto/bancos/bradesco-test.js +145 -0
- package/tests/boleto/bancos/caixa-test.js +428 -0
- package/tests/boleto/bancos/itau-test.js +342 -0
- package/tests/boleto/bancos/sicoob-test.js +341 -0
- package/tests/boleto/gerador-de-digito-padrao-test.js +22 -0
- package/tests/boleto-test.js +349 -0
- package/tests/brasil-test.js +66 -0
- package/tests/formatacoes-test.js +349 -0
- package/tests/validacoes-test.js +309 -0
- package/tmp/boletos/.gitkeep +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const StringUtils = require('../../utils/string-utils');
|
|
3
|
+
const pad = StringUtils.pad;
|
|
4
|
+
|
|
5
|
+
const CodigoDeBarrasBuilder = require('../codigo-de-barras-builder');
|
|
6
|
+
|
|
7
|
+
var BancoBrasil = (function () {
|
|
8
|
+
var NUMERO_BANCO_BRASIL = '001',
|
|
9
|
+
DIGITO_BANCO_BRASIL = '9';
|
|
10
|
+
|
|
11
|
+
function BancoBrasil() {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
BancoBrasil.prototype.getTitulos = function () {
|
|
16
|
+
return {
|
|
17
|
+
instrucoes: 'Informações de responsabilidade do beneficiário',
|
|
18
|
+
nomeDoPagador: 'Nome do Pagador',
|
|
19
|
+
especie: 'Moeda',
|
|
20
|
+
quantidade: 'Quantidade',
|
|
21
|
+
valor: 'Valor',
|
|
22
|
+
moraMulta: '(+) Juros / Multa'
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
BancoBrasil.prototype.exibirReciboDoPagadorCompleto = function () {
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
BancoBrasil.prototype.exibirCampoCip = function () {
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
BancoBrasil.prototype.geraCodigoDeBarrasPara = function (boleto) {
|
|
35
|
+
const beneficiario = boleto.getBeneficiario();
|
|
36
|
+
|
|
37
|
+
const campoLivre = [];
|
|
38
|
+
|
|
39
|
+
if (beneficiario.getNossoNumero().length == 11) {
|
|
40
|
+
campoLivre.push(beneficiario.getNossoNumero());
|
|
41
|
+
campoLivre.push(beneficiario.getAgenciaFormatada());
|
|
42
|
+
campoLivre.push(beneficiario.getCodigoBeneficiario());
|
|
43
|
+
campoLivre.push(beneficiario.getCarteira().substring(0, 2));
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (beneficiario.getNossoNumero().length == 17) {
|
|
49
|
+
campoLivre.push('000000');
|
|
50
|
+
campoLivre.push(beneficiario.getNossoNumero());
|
|
51
|
+
campoLivre.push(beneficiario.getCarteira().substring(0, 2));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return new CodigoDeBarrasBuilder(boleto).comCampoLivre(campoLivre);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
BancoBrasil.prototype.getNumeroFormatadoComDigito = function () {
|
|
59
|
+
return [
|
|
60
|
+
NUMERO_BANCO_BRASIL,
|
|
61
|
+
DIGITO_BANCO_BRASIL
|
|
62
|
+
].join('-');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
BancoBrasil.prototype.getNumeroFormatado = function () {
|
|
66
|
+
return NUMERO_BANCO_BRASIL;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
BancoBrasil.prototype.getCarteiraFormatado = function (beneficiario) {
|
|
70
|
+
return pad(beneficiario.getCarteira(), 2, '0');
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
BancoBrasil.prototype.getCarteiraTexto = function (beneficiario) {
|
|
74
|
+
return pad(beneficiario.getCarteira(), 2, '0');
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
BancoBrasil.prototype.getCodigoFormatado = function (beneficiario) {
|
|
78
|
+
return pad(beneficiario.getCodigoBeneficiario(), 7, '0');
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
BancoBrasil.prototype.getImagem = function () {
|
|
82
|
+
return path.join(__dirname, 'logotipos/banco-do-brasil.png');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
BancoBrasil.prototype.getNossoNumeroFormatado = function (beneficiario) {
|
|
86
|
+
return pad(beneficiario.getNossoNumero(), 17, '0');
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
BancoBrasil.prototype.getNossoNumeroECodigoDocumento = function (boleto) {
|
|
90
|
+
var beneficiario = boleto.getBeneficiario();
|
|
91
|
+
|
|
92
|
+
return [
|
|
93
|
+
this.getNossoNumeroFormatado(beneficiario)
|
|
94
|
+
].join('-');
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
BancoBrasil.prototype.getNome = function () {
|
|
98
|
+
return 'Banco do Brasil S.A.';
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
BancoBrasil.prototype.getImprimirNome = function () {
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
BancoBrasil.prototype.getAgenciaECodigoBeneficiario = function (boleto) {
|
|
106
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
107
|
+
|
|
108
|
+
codigo = this.getCodigoFormatado(beneficiario),
|
|
109
|
+
digitoCodigo = beneficiario.getDigitoCodigoBeneficiario();
|
|
110
|
+
|
|
111
|
+
if (digitoCodigo) {
|
|
112
|
+
codigo += '-' + digitoCodigo;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return beneficiario.getAgenciaFormatada() + '/' + codigo;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
BancoBrasil.novoBancoBrasil = function () {
|
|
119
|
+
return new BancoBrasil();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return BancoBrasil;
|
|
123
|
+
})();
|
|
124
|
+
|
|
125
|
+
module.exports = BancoBrasil;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const StringUtils = require('../../utils/string-utils');
|
|
3
|
+
const pad = StringUtils.pad;
|
|
4
|
+
|
|
5
|
+
const CodigoDeBarrasBuilder = require('../codigo-de-barras-builder');
|
|
6
|
+
|
|
7
|
+
var Bradesco = (function () {
|
|
8
|
+
var NUMERO_BRADESCO = '237',
|
|
9
|
+
DIGITO_BRADESCO = '2';
|
|
10
|
+
|
|
11
|
+
function Bradesco() {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Bradesco.prototype.getTitulos = function () {
|
|
16
|
+
return {
|
|
17
|
+
instrucoes: 'Informações de responsabilidade do beneficiário',
|
|
18
|
+
nomeDoPagador: 'Nome do Pagador',
|
|
19
|
+
especie: 'Moeda',
|
|
20
|
+
quantidade: 'Quantidade',
|
|
21
|
+
valor: 'Valor',
|
|
22
|
+
moraMulta: '(+) Juros / Multa'
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Bradesco.prototype.exibirReciboDoPagadorCompleto = function () {
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Bradesco.prototype.exibirCampoCip = function () {
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Bradesco.prototype.geraCodigoDeBarrasPara = function (boleto) {
|
|
35
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
36
|
+
campoLivre = [];
|
|
37
|
+
|
|
38
|
+
campoLivre.push(beneficiario.getAgenciaFormatada());
|
|
39
|
+
campoLivre.push(this.getCarteiraFormatado(beneficiario));
|
|
40
|
+
campoLivre.push(this.getNossoNumeroFormatado(beneficiario));
|
|
41
|
+
campoLivre.push(this.getCodigoFormatado(beneficiario));
|
|
42
|
+
campoLivre.push('0');
|
|
43
|
+
|
|
44
|
+
return new CodigoDeBarrasBuilder(boleto).comCampoLivre(campoLivre);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Bradesco.prototype.getNumeroFormatadoComDigito = function () {
|
|
48
|
+
return [
|
|
49
|
+
NUMERO_BRADESCO,
|
|
50
|
+
DIGITO_BRADESCO
|
|
51
|
+
].join('-');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
Bradesco.prototype.getNumeroFormatado = function () {
|
|
55
|
+
return NUMERO_BRADESCO;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Bradesco.prototype.getCarteiraFormatado = function (beneficiario) {
|
|
59
|
+
return pad(beneficiario.getCarteira(), 2, '0');
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Bradesco.prototype.getCarteiraTexto = function (beneficiario) {
|
|
63
|
+
return pad(beneficiario.getCarteira(), 2, '0');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Bradesco.prototype.getCodigoFormatado = function (beneficiario) {
|
|
67
|
+
return pad(beneficiario.getCodigoBeneficiario(), 7, '0');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
Bradesco.prototype.getImagem = function () {
|
|
71
|
+
return path.join(__dirname, 'logotipos/bradesco.png');
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Bradesco.prototype.getNossoNumeroFormatado = function (beneficiario) {
|
|
75
|
+
return pad(beneficiario.getNossoNumero(), 11, '0');
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
Bradesco.prototype.getNossoNumeroECodigoDocumento = function (boleto) {
|
|
79
|
+
var beneficiario = boleto.getBeneficiario();
|
|
80
|
+
|
|
81
|
+
return this.getCarteiraFormatado(beneficiario) + '/' + [
|
|
82
|
+
this.getNossoNumeroFormatado(beneficiario),
|
|
83
|
+
beneficiario.getDigitoNossoNumero()
|
|
84
|
+
].join('-');
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Bradesco.prototype.getNome = function () {
|
|
88
|
+
return 'Banco Bradesco S.A.';
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
Bradesco.prototype.getImprimirNome = function () {
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Bradesco.prototype.getAgenciaECodigoBeneficiario = function (boleto) {
|
|
96
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
97
|
+
|
|
98
|
+
codigo = this.getCodigoFormatado(beneficiario),
|
|
99
|
+
digitoCodigo = beneficiario.getDigitoCodigoBeneficiario();
|
|
100
|
+
|
|
101
|
+
if (digitoCodigo) {
|
|
102
|
+
codigo += '-' + digitoCodigo;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return beneficiario.getAgenciaFormatada() + '/' + codigo;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Bradesco.novoBradesco = function () {
|
|
109
|
+
return new Bradesco();
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return Bradesco;
|
|
113
|
+
})();
|
|
114
|
+
|
|
115
|
+
module.exports = Bradesco;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const StringUtils = require('../../utils/string-utils');
|
|
3
|
+
const pad = StringUtils.pad;
|
|
4
|
+
|
|
5
|
+
const CodigoDeBarrasBuilder = require('../codigo-de-barras-builder');
|
|
6
|
+
const GeradorDeDigitoPadrao = require('../gerador-de-digito-padrao');
|
|
7
|
+
|
|
8
|
+
var Caixa = (function () {
|
|
9
|
+
var NUMERO_CAIXA = '104',
|
|
10
|
+
DIGITO_CAIXA = '0';
|
|
11
|
+
|
|
12
|
+
function Caixa() {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Caixa.prototype.getTitulos = function () {
|
|
17
|
+
return {
|
|
18
|
+
instrucoes: 'Instruções (texto de responsabilidade do beneficiário)',
|
|
19
|
+
nomeDoPagador: 'Nome do Pagador',
|
|
20
|
+
especie: 'Espécie Moeda',
|
|
21
|
+
quantidade: 'Quantidade Moeda',
|
|
22
|
+
valor: 'xValor'
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Caixa.prototype.exibirReciboDoPagadorCompleto = function () {
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Caixa.prototype.exibirCampoCip = function () {
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Caixa.prototype.geraCodigoDeBarrasPara = function (boleto) {
|
|
35
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
36
|
+
carteira = beneficiario.getCarteira(),
|
|
37
|
+
contaCorrente = pad(beneficiario.getCodigoBeneficiario(), 6, '0'),
|
|
38
|
+
// digitoContaCorrente = pad(beneficiario.getDigitoCodigoBeneficiario(), 1, '0'),
|
|
39
|
+
nossoNumeroFormatado = this.getNossoNumeroFormatado(beneficiario),
|
|
40
|
+
campoLivre = [];
|
|
41
|
+
|
|
42
|
+
if (carteira == '14' || carteira == '24') {
|
|
43
|
+
// Carteira 24 é sem registro e carteira 14 é com registro
|
|
44
|
+
// O número 1 significa com registro e o número 2 sem registro
|
|
45
|
+
|
|
46
|
+
campoLivre.push(contaCorrente);
|
|
47
|
+
campoLivre.push(beneficiario.getDigitoCodigoBeneficiario());
|
|
48
|
+
campoLivre.push(nossoNumeroFormatado.substring(2, 5));
|
|
49
|
+
campoLivre.push(nossoNumeroFormatado.substring(0, 1));
|
|
50
|
+
campoLivre.push(nossoNumeroFormatado.substring(5, 8));
|
|
51
|
+
campoLivre.push(nossoNumeroFormatado.substring(1, 2));
|
|
52
|
+
campoLivre.push(nossoNumeroFormatado.substring(8));
|
|
53
|
+
|
|
54
|
+
var digito = GeradorDeDigitoPadrao.mod11(campoLivre.join(''), {
|
|
55
|
+
de: [0, 10, 11],
|
|
56
|
+
para: 0
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
campoLivre.push(digito);
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error('Carteira "', carteira, '" não implementada para o banco Caixa');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return new CodigoDeBarrasBuilder(boleto).comCampoLivre(campoLivre);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Caixa.prototype.getNumeroFormatadoComDigito = function () {
|
|
68
|
+
return [NUMERO_CAIXA, DIGITO_CAIXA].join('-');
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Caixa.prototype.getCarteiraFormatado = function (beneficiario) {
|
|
72
|
+
return pad(beneficiario.getCarteira(), 2, '0');
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Caixa.prototype.getCarteiraTexto = function (beneficiario) {
|
|
76
|
+
return {
|
|
77
|
+
1: 'RG',
|
|
78
|
+
14: 'RG',
|
|
79
|
+
2: 'SR',
|
|
80
|
+
24: 'SR'
|
|
81
|
+
}[beneficiario.getCarteira()];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
Caixa.prototype.getCodigoFormatado = function (beneficiario) {
|
|
85
|
+
return pad(beneficiario.getCodigoBeneficiario(), 5, '0');
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
Caixa.prototype.getImagem = function () {
|
|
89
|
+
return path.join(__dirname, 'logotipos/caixa-economica-federal.png');
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Caixa.prototype.getNossoNumeroFormatado = function (beneficiario) {
|
|
93
|
+
return [
|
|
94
|
+
pad(beneficiario.getCarteira(), 2, '0'),
|
|
95
|
+
pad(beneficiario.getNossoNumero(), 15, '0')
|
|
96
|
+
].join('');
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
Caixa.prototype.getNossoNumeroECodigoDocumento = function (boleto) {
|
|
100
|
+
var beneficiario = boleto.getBeneficiario();
|
|
101
|
+
|
|
102
|
+
return [
|
|
103
|
+
this.getNossoNumeroFormatado(beneficiario),
|
|
104
|
+
beneficiario.getDigitoNossoNumero()
|
|
105
|
+
].join('-');
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Caixa.prototype.getNumeroFormatado = function () {
|
|
109
|
+
return NUMERO_CAIXA;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Caixa.prototype.getNome = function () {
|
|
113
|
+
return 'Caixa Econômica Federal S/A';
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Caixa.prototype.getImprimirNome = function () {
|
|
117
|
+
return false;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
Caixa.prototype.getAgenciaECodigoBeneficiario = function (boleto) {
|
|
121
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
122
|
+
|
|
123
|
+
codigo = this.getCodigoFormatado(beneficiario),
|
|
124
|
+
digitoCodigo = beneficiario.getDigitoCodigoBeneficiario();
|
|
125
|
+
|
|
126
|
+
if (digitoCodigo) {
|
|
127
|
+
codigo += '-' + digitoCodigo;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return beneficiario.getAgenciaFormatada() + '/' + codigo;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
Caixa.novoCaixa = function () {
|
|
134
|
+
return new Caixa();
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return Caixa;
|
|
138
|
+
})();
|
|
139
|
+
|
|
140
|
+
module.exports = Caixa;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const StringUtils = require('../../utils/string-utils');
|
|
3
|
+
const CodigoDeBarrasBuilder = require('../codigo-de-barras-builder');
|
|
4
|
+
|
|
5
|
+
const Cecred = (function () {
|
|
6
|
+
const NUMERO_CECRED = '085';
|
|
7
|
+
const DIGITO_CECRED = '1';
|
|
8
|
+
|
|
9
|
+
function Cecred() {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Cecred.prototype.getTitulos = function () {
|
|
13
|
+
return {
|
|
14
|
+
instrucoes: 'Instruções (texto de responsabilidade do beneficiário)',
|
|
15
|
+
nomeDoPagador: 'Pagador',
|
|
16
|
+
especie: 'Moeda',
|
|
17
|
+
quantidade: 'Quantidade',
|
|
18
|
+
valor: 'x Valor',
|
|
19
|
+
moraMulta: '(+) Moras / Multa'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
Cecred.prototype.exibirReciboDoPagadorCompleto = function () {
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Cecred.prototype.exibirCampoCip = function () {
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Cecred.prototype.geraCodigoDeBarrasPara = boleto => {
|
|
32
|
+
const beneficiario = boleto.getBeneficiario();
|
|
33
|
+
const errorMsg = 'Erro ao gerar código de barras,';
|
|
34
|
+
|
|
35
|
+
if (!beneficiario.getNumeroConvenio() || beneficiario.getNumeroConvenio().length !== 6)
|
|
36
|
+
throw new Error(`${errorMsg} número convênio da cooperativa não possui 6 dígitos: ${beneficiario.getNumeroConvenio()}`);
|
|
37
|
+
if (!beneficiario.getNossoNumero() || beneficiario.getNossoNumero().length !== 17)
|
|
38
|
+
throw new Error(`${errorMsg} nosso número não possui 17 dígitos: ${beneficiario.getNossoNumero()}`);
|
|
39
|
+
if (!beneficiario.getCarteira() || beneficiario.getCarteira().length !== 2)
|
|
40
|
+
throw new Error(`${errorMsg} código carteira não possui 2 dígitos: ${beneficiario.getCarteira()}`);
|
|
41
|
+
|
|
42
|
+
const campoLivre = [];
|
|
43
|
+
campoLivre.push(beneficiario.getNumeroConvenio());
|
|
44
|
+
campoLivre.push(beneficiario.getNossoNumero());
|
|
45
|
+
campoLivre.push(beneficiario.getCarteira().substring(0, 2));
|
|
46
|
+
return new CodigoDeBarrasBuilder(boleto).comCampoLivre(campoLivre);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Cecred.prototype.getNumeroFormatadoComDigito = function () {
|
|
50
|
+
return [NUMERO_CECRED, DIGITO_CECRED].join('-');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Cecred.prototype.getNumeroFormatado = function () {
|
|
54
|
+
return NUMERO_CECRED;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
Cecred.prototype.getCarteiraFormatado = function (beneficiario) {
|
|
58
|
+
return StringUtils.pad(beneficiario.getCarteira(), 2, '0');
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Cecred.prototype.getCarteiraTexto = function (beneficiario) {
|
|
62
|
+
return StringUtils.pad(beneficiario.getCarteira(), 2, '0');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Cecred.prototype.getCodigoFormatado = function (beneficiario) {
|
|
66
|
+
return StringUtils.pad(beneficiario.getCodigoBeneficiario(), 7, '0');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Cecred.prototype.getImagem = function () {
|
|
70
|
+
return path.join(__dirname, 'logotipos/ailos.png');
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Cecred.prototype.getNossoNumeroFormatado = function (beneficiario) {
|
|
74
|
+
return StringUtils.pad(beneficiario.getNossoNumero(), 11, '0');
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Cecred.prototype.getNossoNumeroECodigoDocumento = function (boleto) {
|
|
78
|
+
const beneficiario = boleto.getBeneficiario();
|
|
79
|
+
|
|
80
|
+
let nossoNumero = this.getNossoNumeroFormatado(beneficiario);
|
|
81
|
+
if (beneficiario.getDigitoNossoNumero()) nossoNumero += `-${beneficiario.getDigitoNossoNumero()}`;
|
|
82
|
+
|
|
83
|
+
return nossoNumero;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
Cecred.prototype.getNome = function () {
|
|
87
|
+
return 'Ailos';
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
Cecred.prototype.getImprimirNome = function () {
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
Cecred.prototype.getLocaisDePagamentoPadrao = function () {
|
|
95
|
+
return ['PAGAVEL PREFERENCIALMENTE NAS COOPERATIVAS DO SISTEMA AILOS.', 'APOS VENCIMENTO PAGAR SOMENTE NA COOPERATIVA '];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
Cecred.prototype.getAgenciaECodigoBeneficiario = function (boleto) {
|
|
99
|
+
const beneficiario = boleto.getBeneficiario();
|
|
100
|
+
const digitoCodigo = beneficiario.getDigitoCodigoBeneficiario();
|
|
101
|
+
let codigo = this.getCodigoFormatado(beneficiario);
|
|
102
|
+
|
|
103
|
+
if (digitoCodigo) codigo += '-' + digitoCodigo;
|
|
104
|
+
|
|
105
|
+
const agenciaComDigito = beneficiario.getAgenciaFormatada() + '-' + beneficiario.getDigitoAgencia();
|
|
106
|
+
|
|
107
|
+
return agenciaComDigito + '/' + codigo;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
Cecred.novoCecred = function () {
|
|
111
|
+
return new Cecred();
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return Cecred;
|
|
115
|
+
})();
|
|
116
|
+
|
|
117
|
+
module.exports = Cecred;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const StringUtils = require('../../utils/string-utils');
|
|
3
|
+
const pad = StringUtils.pad;
|
|
4
|
+
const insert = StringUtils.insert;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const GeradorDeDigitoPadrao = require('../gerador-de-digito-padrao');
|
|
8
|
+
const CodigoDeBarrasBuilder = require('../codigo-de-barras-builder');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
//Varias coisas implementadas inclusive arquivos de retorno
|
|
12
|
+
//https://github.com/kivanio/brcobranca
|
|
13
|
+
//https://github.com/pagarme/node-boleto
|
|
14
|
+
|
|
15
|
+
//Várias validações
|
|
16
|
+
//http://ghiorzi.org/DVnew.htm
|
|
17
|
+
|
|
18
|
+
var Itau = (function () {
|
|
19
|
+
var NUMERO_ITAU = '341',
|
|
20
|
+
DIGITO_ITAU = '7';
|
|
21
|
+
|
|
22
|
+
function Itau() {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Itau.prototype.getTitulos = function () {
|
|
27
|
+
return {};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Itau.prototype.exibirReciboDoPagadorCompleto = function () {
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Itau.prototype.exibirCampoCip = function () {
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Itau.prototype.geraCodigoDeBarrasPara = function (boleto) {
|
|
39
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
40
|
+
campoLivre = [];
|
|
41
|
+
|
|
42
|
+
campoLivre.push(this.getCarteiraFormatado(beneficiario));
|
|
43
|
+
campoLivre.push(this.getNossoNumeroFormatado(beneficiario));
|
|
44
|
+
campoLivre.push(beneficiario.getAgenciaFormatada());
|
|
45
|
+
campoLivre.push(this.getCodigoFormatado(beneficiario));
|
|
46
|
+
campoLivre.push('000');
|
|
47
|
+
|
|
48
|
+
campoLivre = campoLivre.join('');
|
|
49
|
+
|
|
50
|
+
var digito1 = GeradorDeDigitoPadrao.mod10(campoLivre.substring(11, 20));
|
|
51
|
+
campoLivre = insert(campoLivre, 20, digito1);
|
|
52
|
+
|
|
53
|
+
var digito2 = GeradorDeDigitoPadrao.mod10(campoLivre.substring(11, 20) + campoLivre.substring(0, 11));
|
|
54
|
+
campoLivre = insert(campoLivre, 11, digito2);
|
|
55
|
+
|
|
56
|
+
return new CodigoDeBarrasBuilder(boleto).comCampoLivre(campoLivre);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Itau.prototype.getNumeroFormatadoComDigito = function () {
|
|
60
|
+
return [NUMERO_ITAU, DIGITO_ITAU].join('-');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Itau.prototype.getCarteiraFormatado = function (beneficiario) {
|
|
64
|
+
return pad(beneficiario.getCarteira(), 3, '0');
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Itau.prototype.getCarteiraTexto = function (beneficiario) {
|
|
68
|
+
return this.getCarteiraFormatado(beneficiario);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Itau.prototype.getCodigoFormatado = function (beneficiario) {
|
|
72
|
+
return pad(beneficiario.getCodigoBeneficiario(), 5, '0');
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Itau.prototype.getImagem = function () {
|
|
76
|
+
return path.join(__dirname, 'logotipos/itau.png');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
Itau.prototype.getNossoNumeroFormatado = function (beneficiario) {
|
|
80
|
+
return pad(beneficiario.getNossoNumero(), 8, '0');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
Itau.prototype.getNossoNumeroECodigoDocumento = function (boleto) {
|
|
84
|
+
var beneficiario = boleto.getBeneficiario();
|
|
85
|
+
|
|
86
|
+
return [
|
|
87
|
+
beneficiario.getCarteira(),
|
|
88
|
+
this.getNossoNumeroFormatado(beneficiario),
|
|
89
|
+
].join('/') + '-' + beneficiario.getDigitoNossoNumero();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Itau.prototype.getNumeroFormatado = function () {
|
|
93
|
+
return NUMERO_ITAU;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Itau.prototype.getNome = function () {
|
|
97
|
+
return 'Banco Itaú S/A';
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
Itau.prototype.getImprimirNome = function () {
|
|
101
|
+
return true;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
Itau.prototype.getAgenciaECodigoBeneficiario = function (boleto) {
|
|
105
|
+
var beneficiario = boleto.getBeneficiario(),
|
|
106
|
+
|
|
107
|
+
codigo = this.getCodigoFormatado(beneficiario),
|
|
108
|
+
digitoCodigo = beneficiario.getDigitoCodigoBeneficiario();
|
|
109
|
+
|
|
110
|
+
if (digitoCodigo) {
|
|
111
|
+
codigo += '-' + digitoCodigo;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return beneficiario.getAgenciaFormatada() + '/' + codigo;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
Itau.novoItau = function () {
|
|
118
|
+
return new Itau();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return Itau;
|
|
122
|
+
})();
|
|
123
|
+
|
|
124
|
+
module.exports = Itau;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|