br_boleto 2.2.9 → 2.2.10
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/br_boleto/boleto/unicred.rb +30 -0
- data/lib/br_boleto/conta/unicred.rb +4 -0
- data/lib/br_boleto/remessa/cnab400/unicred.rb +8 -14
- data/lib/br_boleto/version.rb +1 -1
- data/test/br_boleto/boleto/unicred_test.rb +10 -12
- data/test/br_boleto/conta/unicred_test.rb +1 -1
- data/test/br_boleto/remessa/cnab240/unicred_test.rb +4 -3
- data/test/fixtures/remessa/cnab400/unicred.rem +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb7694369c0a7b82d733d1aa9bd6c3e6481c3fc973eef04df419bce6391e367a
|
4
|
+
data.tar.gz: b5254261c18236a95090fab1df656d49e901b6d67c389b6345bfe6ed17877ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f55d030b4857e56533e998ff8732fdbec411cffc223afac07f826b982a237654c0ab3036eee1ce38322dec768b6b0c52a6ac4c201949788f5939edd1ff05dc3
|
7
|
+
data.tar.gz: 3a559a9b16e9103a48f510bb8178f5eabba59c11ef9159d4c669352e63a251d0897ffdd245cb9479a7512bc79793535968889091da5c3d702d45cb45cef5ff68
|
data/Gemfile.lock
CHANGED
@@ -16,6 +16,36 @@ module BrBoleto
|
|
16
16
|
|
17
17
|
def valid_avalista_required; true end
|
18
18
|
|
19
|
+
def digito_verificador_nosso_numero
|
20
|
+
BrBoleto::Calculos::Modulo11FatorDe2a9.new("#{numero_documento}")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Nosso Número descrito na documentação (Pag. 36).
|
24
|
+
# Carteira com 2 (dois) caracteres / N.Número com 11 (onze) caracteres + digito.
|
25
|
+
# Exemplo: 99 / 99999999999-D
|
26
|
+
def nosso_numero
|
27
|
+
"#{numero_documento}-#{digito_verificador_nosso_numero}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def nosso_numero_retorno
|
31
|
+
"#{nosso_numero}".gsub(/[^\w\d]/i, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
# === Código de barras do banco
|
35
|
+
#
|
36
|
+
# ___________________________________________________________________________________________________
|
37
|
+
# | Posição | Tamanho | Descrição |
|
38
|
+
# |----------|---------|-----------------------------------------------------------------------------|
|
39
|
+
# | 20-23 | 04 | Agência (Sem o digito, completar com zeros a esquerda se necessário) |
|
40
|
+
# | 24-33 | 10 | Conta do BENEFICIÁRIO (Com o dígito verificador) |
|
41
|
+
# | 34-44 | 11 | NNosso Número (Com o dígito verificador) |
|
42
|
+
# ----------------------------------------------------------------------------------------------------
|
43
|
+
#
|
44
|
+
def codigo_de_barras_do_banco
|
45
|
+
conta_corrente = "#{conta.conta_corrente}#{conta.conta_corrente_dv}".adjust_size_to(10, '0', :right)
|
46
|
+
"#{conta.agencia}#{conta_corrente}#{nosso_numero_retorno.adjust_size_to(11, '0', :right)}"
|
47
|
+
end
|
48
|
+
|
19
49
|
end
|
20
50
|
end
|
21
51
|
end
|
@@ -27,6 +27,10 @@ module BrBoleto
|
|
27
27
|
'041'
|
28
28
|
end
|
29
29
|
|
30
|
+
def conta_corrente_dv
|
31
|
+
@conta_corrente_dv ||= BrBoleto::Calculos::Modulo11FatorDe2a9.new(conta_corrente).to_s
|
32
|
+
end
|
33
|
+
|
30
34
|
|
31
35
|
##################################### DEFAULT CODES ###############################################
|
32
36
|
|
@@ -152,13 +152,12 @@ module BrBoleto
|
|
152
152
|
# POSIÇÂO TAM. Descrição
|
153
153
|
# 121 a 126 006 Data do Vencimento do Título
|
154
154
|
# 127 a 139 013 Valor do Título
|
155
|
-
# 140 a 142 003
|
156
|
-
# 143 a 147 005
|
157
|
-
# 148 a 149 002
|
158
|
-
# 150 a 150 001
|
155
|
+
# 140 a 142 003 Filler
|
156
|
+
# 143 a 147 005 Filler Zeros
|
157
|
+
# 148 a 149 002 Filler Zeros
|
158
|
+
# 150 a 150 001 Código do desconto
|
159
159
|
# 151 a 156 006 Data da emissão do Título
|
160
|
-
# 157 a
|
161
|
-
# 159 a 160 002 2a instrução
|
160
|
+
# 157 a 160 004 Filler Zeros
|
162
161
|
# Tamanho: 40
|
163
162
|
def informacoes_do_pagamento(pagamento, sequencial)
|
164
163
|
dados = ''
|
@@ -187,18 +186,13 @@ module BrBoleto
|
|
187
186
|
# Tamanho: 58
|
188
187
|
def detalhe_posicao_161_218(pagamento, sequencial)
|
189
188
|
info = ''
|
190
|
-
|
191
|
-
if "#{pagamento.codigo_juros}".in?(%w[1 2])
|
192
|
-
info << pagamento.valor_juros_monetario_formatado(13)
|
193
|
-
else
|
194
|
-
info << '5'
|
195
|
-
end
|
196
|
-
|
189
|
+
info << pagamento.valor_juros_monetario_formatado(13)
|
197
190
|
info << pagamento.data_desconto_formatado
|
198
191
|
info << pagamento.valor_desconto_formatado(13)
|
199
|
-
info << "#{pagamento.nosso_numero}".adjust_size_to(11, '0', :right)
|
192
|
+
info << "#{pagamento.nosso_numero.to_i}".adjust_size_to(11, '0', :right)
|
200
193
|
info << '00'
|
201
194
|
info << pagamento.valor_abatimento_formatado(13)
|
195
|
+
info.adjust_size_to(58, '5', :right)
|
202
196
|
end
|
203
197
|
|
204
198
|
|
data/lib/br_boleto/version.rb
CHANGED
@@ -2,7 +2,7 @@ module BrBoleto
|
|
2
2
|
module Version
|
3
3
|
MAJOR = 2 #inclui alterações de API e pode quebrar compatibilidade com versões anteriores
|
4
4
|
MINOR = 2 #inclui novas funcionalidades, sem quebrar APIs existentes
|
5
|
-
PATCH =
|
5
|
+
PATCH = 10 #corrige bugs ou traz melhorias em implementações já existentes
|
6
6
|
CURRENT = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
7
7
|
end
|
8
8
|
end
|
@@ -55,7 +55,7 @@ describe BrBoleto::Boleto::Unicred do
|
|
55
55
|
it "deve calcular pelo Modulo11Fator3197" do
|
56
56
|
# subject.carteira = 09
|
57
57
|
subject.numero_documento = 111
|
58
|
-
BrBoleto::Calculos::
|
58
|
+
BrBoleto::Calculos::Modulo11FatorDe2a9.expects(:new).with('00000000111').returns("meu_resultado")
|
59
59
|
subject.digito_verificador_nosso_numero.must_equal "meu_resultado"
|
60
60
|
end
|
61
61
|
end
|
@@ -66,7 +66,7 @@ describe BrBoleto::Boleto::Unicred do
|
|
66
66
|
it "deve retornar o numero do documento com o digito_verificador_nosso_numero" do
|
67
67
|
subject.stubs(:digito_verificador_nosso_numero).returns('9')
|
68
68
|
subject.numero_documento = '3646'
|
69
|
-
subject.nosso_numero.must_equal "
|
69
|
+
subject.nosso_numero.must_equal "00000003646-9"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -81,18 +81,16 @@ describe BrBoleto::Boleto::Unicred do
|
|
81
81
|
)
|
82
82
|
end
|
83
83
|
it "deve montar o codigo corretamente com as informações" do
|
84
|
-
subject.stubs(:nosso_numero).returns('
|
84
|
+
subject.stubs(:nosso_numero).returns('0000003646-9')
|
85
85
|
|
86
86
|
result = subject.codigo_de_barras_do_banco
|
87
87
|
result.size.must_equal 25
|
88
88
|
|
89
89
|
result[0..3].must_equal '0078' # Agencia
|
90
|
-
result[4..
|
91
|
-
result[
|
92
|
-
result[17..23].must_equal '0000668' # Conta Corrente
|
93
|
-
result[24].must_equal '0' # Zero
|
90
|
+
result[4..13].must_equal '0000006688' # Conta Corrente
|
91
|
+
result[14..24].must_equal '00000036469' # Numero documento
|
94
92
|
|
95
|
-
subject.codigo_de_barras_do_banco.must_equal '
|
93
|
+
subject.codigo_de_barras_do_banco.must_equal '0078000000668800000036469'
|
96
94
|
end
|
97
95
|
end
|
98
96
|
|
@@ -109,8 +107,8 @@ describe BrBoleto::Boleto::Unicred do
|
|
109
107
|
end
|
110
108
|
end
|
111
109
|
|
112
|
-
it { subject.codigo_de_barras.must_equal '
|
113
|
-
it { subject.linha_digitavel.must_equal '13693.06905
|
110
|
+
it { subject.codigo_de_barras.must_equal '13691816800093015783069000089755800000010010' }
|
111
|
+
it { subject.linha_digitavel.must_equal '13693.06905 00089.755805 00000.100107 1 81680009301578' }
|
114
112
|
|
115
113
|
it "codigo de barras de um boleto de exemplo" do
|
116
114
|
subject.conta.agencia = 3069
|
@@ -121,8 +119,8 @@ describe BrBoleto::Boleto::Unicred do
|
|
121
119
|
subject.valor_documento = 408.50
|
122
120
|
subject.data_vencimento = Date.parse('2016-09-01')
|
123
121
|
|
124
|
-
subject.linha_digitavel.must_equal '13693.06905
|
125
|
-
subject.codigo_de_barras.must_equal '
|
122
|
+
subject.linha_digitavel.must_equal '13693.06905 00089.755805 00000.156794 9 69040000040850'
|
123
|
+
subject.codigo_de_barras.must_equal '13699690400000408503069000089755800000015679'
|
126
124
|
end
|
127
125
|
end
|
128
126
|
end
|
@@ -111,7 +111,7 @@ describe BrBoleto::Conta::Unicred do
|
|
111
111
|
it "se não passar valor deve calcular automatico" do
|
112
112
|
subject.conta_corrente_dv = nil
|
113
113
|
subject.conta_corrente = '6688'
|
114
|
-
BrBoleto::Calculos::
|
114
|
+
BrBoleto::Calculos::Modulo11FatorDe2a9.expects(:new).with('0006688').returns(stub(to_s: 5))
|
115
115
|
|
116
116
|
subject.conta_corrente_dv.must_equal 5
|
117
117
|
end
|
@@ -238,13 +238,14 @@ describe BrBoleto::Remessa::Cnab240::Unicred do
|
|
238
238
|
}
|
239
239
|
let(:lote) { BrBoleto::Remessa::Lote.new(pagamentos: pagamento) }
|
240
240
|
it "deve gerar o arquivo de remessa corretamente com as informações passadas" do
|
241
|
-
remessa = BrBoleto::Remessa::
|
241
|
+
remessa = BrBoleto::Remessa::Cnab400::Unicred.new({
|
242
242
|
data_hora_arquivo: Time.parse('10/11/2016 09:27:45'),
|
243
243
|
sequencial_remessa: 1,
|
244
244
|
conta: conta,
|
245
|
-
|
245
|
+
pagamentos: [pagamento],
|
246
246
|
})
|
247
|
-
|
247
|
+
|
248
|
+
remessa.dados_do_arquivo.must_equal read_fixture('remessa/cnab400/unicred.rem')
|
248
249
|
end
|
249
250
|
end
|
250
251
|
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
01REMESSA01COBRANCA 00000000000000082819EMPRESA EMITENTE 136UNICRED 101116 0000000001 000001
|
2
|
+
107506000000135484330021000000000000000000000001 13600 03 50 0100000000001312160000000005000 00000000101116000000000000000000000000000000000000009000000000000000000000000100078793321112BENJAMIN FRANCISCO MARCOS VINICIUS FERNARUA PRINCIPAL S/N 881 CENTRO 79210972ANASTACIO MS 000002
|
3
|
+
9 000003
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_boleto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno M. Mergen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -320,6 +320,7 @@ files:
|
|
320
320
|
- test/fixtures/remessa/cnab240/cecred.rem
|
321
321
|
- test/fixtures/remessa/cnab240/sicoob.rem
|
322
322
|
- test/fixtures/remessa/cnab240/unicred.rem
|
323
|
+
- test/fixtures/remessa/cnab400/unicred.rem
|
323
324
|
- test/fixtures/retorno/cnab240/banco_brasil.ret
|
324
325
|
- test/fixtures/retorno/cnab240/caixa.ret
|
325
326
|
- test/fixtures/retorno/cnab240/cecred.ret
|
@@ -493,6 +494,7 @@ test_files:
|
|
493
494
|
- test/fixtures/remessa/cnab240/cecred.rem
|
494
495
|
- test/fixtures/remessa/cnab240/sicoob.rem
|
495
496
|
- test/fixtures/remessa/cnab240/unicred.rem
|
497
|
+
- test/fixtures/remessa/cnab400/unicred.rem
|
496
498
|
- test/fixtures/retorno/cnab240/banco_brasil.ret
|
497
499
|
- test/fixtures/retorno/cnab240/caixa.ret
|
498
500
|
- test/fixtures/retorno/cnab240/cecred.ret
|