boleto_bancario 0.0.2 → 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.
- checksums.yaml +5 -5
- data/Changelog.markdown +54 -2
- data/README.markdown +660 -189
- data/lib/boleto_bancario/calculos/documento.rb +191 -0
- data/lib/boleto_bancario/calculos/fator_vencimento.rb +78 -31
- data/lib/boleto_bancario/core/boleto.rb +30 -1
- data/lib/boleto_bancario/core/c6_bank.rb +155 -0
- data/lib/boleto_bancario/core/inter.rb +155 -0
- data/lib/boleto_bancario/core/nubank.rb +156 -0
- data/lib/boleto_bancario/locales/pt-BR.yml +55 -0
- data/lib/boleto_bancario/renderers/base.rb +154 -0
- data/lib/boleto_bancario/renderers/html_renderer.rb +92 -0
- data/lib/boleto_bancario/renderers/pdf_renderer.rb +130 -0
- data/lib/boleto_bancario/renderers/png_renderer.rb +66 -0
- data/lib/boleto_bancario/templates/_barcode.html.erb +3 -0
- data/lib/boleto_bancario/templates/_cedente.html.erb +14 -0
- data/lib/boleto_bancario/templates/_header.html.erb +4 -0
- data/lib/boleto_bancario/templates/_instructions.html.erb +10 -0
- data/lib/boleto_bancario/templates/_payment.html.erb +36 -0
- data/lib/boleto_bancario/templates/_sacado.html.erb +10 -0
- data/lib/boleto_bancario/templates/boleto.html.erb +22 -0
- data/lib/boleto_bancario/templates/boleto_styles.css +18 -0
- data/lib/boleto_bancario/version.rb +3 -1
- data/lib/boleto_bancario.rb +23 -6
- data/lib/generators/boleto_bancario/views_generator.rb +47 -0
- metadata +91 -129
- data/.gitignore +0 -19
- data/.rspec +0 -1
- data/.travis.yml +0 -10
- data/Gemfile +0 -3
- data/Planning.markdown +0 -63
- data/Rakefile +0 -15
- data/TODO.markdown +0 -19
- data/boleto_bancario.gemspec +0 -29
- data/documentacoes_dos_boletos/Bradesco/Manual_BRADESCO.PDF +0 -0
- data/lib/boleto_bancario/core/hsbc.rb +0 -170
- data/lib/boleto_bancario/core/real.rb +0 -177
- data/spec/boleto_bancario/calculos/digitos_spec.rb +0 -19
- data/spec/boleto_bancario/calculos/fator_vencimento_spec.rb +0 -59
- data/spec/boleto_bancario/calculos/fatores_de_multiplicacao_spec.rb +0 -69
- data/spec/boleto_bancario/calculos/linha_digitavel_spec.rb +0 -57
- data/spec/boleto_bancario/calculos/modulo10_spec.rb +0 -53
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a7_spec.rb +0 -43
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_resto_zero_spec.rb +0 -39
- data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_spec.rb +0 -67
- data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x_spec.rb +0 -37
- data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_spec.rb +0 -31
- data/spec/boleto_bancario/calculos/modulo11_spec.rb +0 -19
- data/spec/boleto_bancario/calculos/modulo_numero_de_controle_spec.rb +0 -37
- data/spec/boleto_bancario/core/banco_brasil_spec.rb +0 -377
- data/spec/boleto_bancario/core/banrisul_spec.rb +0 -129
- data/spec/boleto_bancario/core/boleto_spec.rb +0 -218
- data/spec/boleto_bancario/core/bradesco_spec.rb +0 -163
- data/spec/boleto_bancario/core/caixa_spec.rb +0 -111
- data/spec/boleto_bancario/core/hsbc_spec.rb +0 -72
- data/spec/boleto_bancario/core/itau_spec.rb +0 -333
- data/spec/boleto_bancario/core/real_spec.rb +0 -104
- data/spec/boleto_bancario/core/santander_spec.rb +0 -137
- data/spec/boleto_bancario/core/sicoob_spec.rb +0 -111
- data/spec/boleto_bancario/core/sicredi_spec.rb +0 -149
- data/spec/inheritance/banco_brasil_spec.rb +0 -22
- data/spec/inheritance/banrisul_spec.rb +0 -22
- data/spec/inheritance/boleto_spec.rb +0 -15
- data/spec/inheritance/bradesco_spec.rb +0 -22
- data/spec/inheritance/caixa_spec.rb +0 -22
- data/spec/inheritance/hsbc_spec.rb +0 -22
- data/spec/inheritance/itau_spec.rb +0 -22
- data/spec/inheritance/real_spec.rb +0 -22
- data/spec/inheritance/santander_spec.rb +0 -22
- data/spec/inheritance/sicoob_spec.rb +0 -22
- data/spec/inheritance/sicredi_spec.rb +0 -22
- data/spec/shared_examples/boleto_bancario_shared_example.rb +0 -151
- data/spec/spec_helper.rb +0 -14
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
module BoletoBancario
|
|
5
|
-
module Core
|
|
6
|
-
describe BancoBrasil do
|
|
7
|
-
it_should_behave_like 'boleto bancario'
|
|
8
|
-
|
|
9
|
-
describe "on validations" do
|
|
10
|
-
context "#agencia" do
|
|
11
|
-
it { should have_valid(:agencia).when('123', '1234') }
|
|
12
|
-
it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context "#conta_corrente" do
|
|
16
|
-
it { should have_valid(:conta_corrente).when('12345678', '12345', '1234') }
|
|
17
|
-
it { should_not have_valid(:conta_corrente).when('123456789', nil, '') }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "#codigo_cedente" do
|
|
21
|
-
it { should have_valid(:codigo_cedente).when('1234', '123456', '1234567', '12345678') }
|
|
22
|
-
it { should_not have_valid(:codigo_cedente).when('123', '1', '12', nil, '') }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context "#carteira" do
|
|
26
|
-
it { should have_valid(:carteira).when('12', '16', '17', '18', 12, 18) }
|
|
27
|
-
it { should_not have_valid(:carteira).when(nil, '', '5', '20', '100', 14, 19) }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "#valor_documento" do
|
|
31
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
32
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "when 'carteira' is 16 and 'codigo_cedente' 6 digits" do
|
|
36
|
-
subject { BancoBrasil.new(carteira: 16, codigo_cedente: 123456) }
|
|
37
|
-
|
|
38
|
-
it { should have_valid(:numero_documento).when('1234', '12345', '12345', '12345678911234567') }
|
|
39
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '123456', '123456789112345678') }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "when 'carteira' is 18 and 'codigo_cedente' 6 digits" do
|
|
43
|
-
subject { BancoBrasil.new(carteira: 18, codigo_cedente: 123456) }
|
|
44
|
-
|
|
45
|
-
it { should have_valid(:numero_documento).when('1234', '12345', '12345678911234567') }
|
|
46
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '123456', '1234567', '123456789112345678') }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "when 'carteira' is 12 and 'codigo_cedente' 6 digits" do
|
|
50
|
-
subject { BancoBrasil.new(carteira: 12, codigo_cedente: 123456) }
|
|
51
|
-
|
|
52
|
-
it { should have_valid(:numero_documento).when('12345', '1234') }
|
|
53
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '123456', '12345678911234567') }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when 'codigo_cedente' 4 digits" do
|
|
57
|
-
subject { BancoBrasil.new(codigo_cedente: 1234) }
|
|
58
|
-
|
|
59
|
-
it { should have_valid(:numero_documento).when('123', '1235', '1234567') }
|
|
60
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '12345678', '12345678911234567') }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "when 'codigo_cedente' 7 digits" do
|
|
64
|
-
subject { BancoBrasil.new(codigo_cedente: 1234567) }
|
|
65
|
-
|
|
66
|
-
it { should have_valid(:numero_documento).when('1234567890', '1235', '1234567') }
|
|
67
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '12345678901', '12345678911234567') }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "when 'codigo_cedente' 8 digits" do
|
|
71
|
-
subject { BancoBrasil.new(codigo_cedente: 12345678) }
|
|
72
|
-
|
|
73
|
-
it { should have_valid(:numero_documento).when('123456789', '1235', '1234567') }
|
|
74
|
-
it { should_not have_valid(:numero_documento).when(nil, '', '1234567890', '12345678911234567') }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context "when 'codigo_cedente' unsupported" do
|
|
78
|
-
subject { BancoBrasil.new(codigo_cedente: 12345) }
|
|
79
|
-
|
|
80
|
-
it { should have_valid(:numero_documento).when('123456789', '1235', '1234567', '1234567890', '12345678911234567') }
|
|
81
|
-
it { should_not have_valid(:numero_documento).when(nil, '') }
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe "#agencia" do
|
|
86
|
-
context "when have a value" do
|
|
87
|
-
subject { BancoBrasil.new(:agencia => '001') }
|
|
88
|
-
|
|
89
|
-
it { expect(subject.agencia).to eq '0001' }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context "when is nil" do
|
|
93
|
-
subject { BancoBrasil.new(:agencia => nil) }
|
|
94
|
-
|
|
95
|
-
it { expect(subject.agencia).to be nil }
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
describe "#conta_corrente" do
|
|
100
|
-
context "when have a value" do
|
|
101
|
-
subject { BancoBrasil.new(:conta_corrente => 913) }
|
|
102
|
-
|
|
103
|
-
it { expect(subject.conta_corrente).to eq '00000913' }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context "when is nil" do
|
|
107
|
-
subject { BancoBrasil.new(:conta_corrente => nil) }
|
|
108
|
-
|
|
109
|
-
it { expect(subject.codigo_cedente).to be nil }
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
describe "#numero_documento" do
|
|
114
|
-
context "when have 'codigo_cedente' 4 digits" do
|
|
115
|
-
subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 1234) }
|
|
116
|
-
|
|
117
|
-
it { expect(subject.numero_documento).to eq '0000913' }
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "when have 'codigo_cedente' 6 digits" do
|
|
121
|
-
subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 123456) }
|
|
122
|
-
|
|
123
|
-
it { expect(subject.numero_documento).to eq '00913' }
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
context "when have 'codigo_cedente' 7 digits" do
|
|
127
|
-
subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 1234567) }
|
|
128
|
-
|
|
129
|
-
it { expect(subject.numero_documento).to eq '0000000913' }
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context "when have 'codigo_cedente' 8 digits" do
|
|
133
|
-
subject { BancoBrasil.new(:numero_documento => 913, :codigo_cedente => 12345678) }
|
|
134
|
-
|
|
135
|
-
it { expect(subject.numero_documento).to eq '000000913' }
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
context "when is nil" do
|
|
139
|
-
subject { BancoBrasil.new(:numero_documento => nil) }
|
|
140
|
-
|
|
141
|
-
it { expect(subject.numero_documento).to be nil }
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
context "when 'codigo_cedente' is nil" do
|
|
145
|
-
subject { BancoBrasil.new(:numero_documento => '12') }
|
|
146
|
-
|
|
147
|
-
it { expect(subject.numero_documento).to eq '12' }
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
describe "#codigo_banco" do
|
|
152
|
-
it { expect(subject.codigo_banco).to eq '001' }
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
describe "#digito_codigo_banco" do
|
|
156
|
-
it { expect(subject.digito_codigo_banco).to eq '9' }
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
describe "#agencia_codigo_cedente" do
|
|
160
|
-
subject { BancoBrasil.new(agencia: 9999, conta_corrente: 99999) }
|
|
161
|
-
|
|
162
|
-
it { expect(subject.agencia_codigo_cedente).to eq '9999-6 / 00099999-7' }
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
describe "#nosso_numero" do
|
|
166
|
-
context "when 'codigo_cedente 4 digits" do
|
|
167
|
-
subject { BancoBrasil.new(codigo_cedente: 1234, numero_documento: 1984) }
|
|
168
|
-
|
|
169
|
-
it { expect(subject.nosso_numero).to eq '12340001984-7' }
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
context "when 'codigo_cedente 6 digits" do
|
|
173
|
-
subject { BancoBrasil.new(codigo_cedente: 123456, numero_documento: 1984) }
|
|
174
|
-
|
|
175
|
-
it { expect(subject.nosso_numero).to eq '12345601984-2' }
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
context "when 'codigo_cedente 7 digits" do
|
|
179
|
-
subject { BancoBrasil.new(codigo_cedente: 1234567, numero_documento: 1984) }
|
|
180
|
-
|
|
181
|
-
it { expect(subject.nosso_numero).to eq '12345670000001984' }
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "when 'codigo_cedente 8 digits" do
|
|
185
|
-
subject { BancoBrasil.new(codigo_cedente: 12345678, numero_documento: 1984) }
|
|
186
|
-
|
|
187
|
-
it { expect(subject.nosso_numero).to eq '12345678000001984' }
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
describe "#codigo_cedente_quatro_digitos?" do
|
|
192
|
-
context "when is true" do
|
|
193
|
-
subject { BancoBrasil.new(codigo_cedente: 1234) }
|
|
194
|
-
|
|
195
|
-
it { expect(subject.codigo_cedente_quatro_digitos?).to be true }
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
context "when is false" do
|
|
199
|
-
subject { BancoBrasil.new(codigo_cedente: 12345) }
|
|
200
|
-
|
|
201
|
-
it { expect(subject.codigo_cedente_quatro_digitos?).to be false }
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
describe "#codigo_cedente_seis_digitos?" do
|
|
206
|
-
context "when is true" do
|
|
207
|
-
subject { BancoBrasil.new(codigo_cedente: 123456) }
|
|
208
|
-
|
|
209
|
-
it { expect(subject.codigo_cedente_seis_digitos?).to be true }
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
context "when is false" do
|
|
213
|
-
subject { BancoBrasil.new(codigo_cedente: 1234567) }
|
|
214
|
-
|
|
215
|
-
it { expect(subject.codigo_cedente_seis_digitos?).to be false }
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
describe "#codigo_cedente_sete_digitos?" do
|
|
220
|
-
context "when is true" do
|
|
221
|
-
subject { BancoBrasil.new(codigo_cedente: 1234567) }
|
|
222
|
-
|
|
223
|
-
it { expect(subject.codigo_cedente_sete_digitos?).to be true }
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
context "when is false" do
|
|
227
|
-
subject { BancoBrasil.new(codigo_cedente: 12345678) }
|
|
228
|
-
|
|
229
|
-
it { expect(subject.codigo_cedente_sete_digitos?).to be false }
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
describe "#codigo_cedente_oito_digitos?" do
|
|
234
|
-
context "when is true" do
|
|
235
|
-
subject { BancoBrasil.new(codigo_cedente: 12345678) }
|
|
236
|
-
|
|
237
|
-
it { expect(subject.codigo_cedente_oito_digitos?).to be true }
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
context "when is false" do
|
|
241
|
-
subject { BancoBrasil.new(codigo_cedente: 123456789) }
|
|
242
|
-
|
|
243
|
-
it { expect(subject.codigo_cedente_oito_digitos?).to be false }
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
describe "#nosso_numero_dezessete_posicoes?" do
|
|
248
|
-
context "when 'carteira' 18, 'numero_documento' 17 digits and 'codigo_cedente' 6 digits" do
|
|
249
|
-
subject { BancoBrasil.new(numero_documento: 12345678911234567, carteira: 18, codigo_cedente: 123456) }
|
|
250
|
-
|
|
251
|
-
it { expect(subject.nosso_numero_dezessete_posicoes?).to be true }
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
context "when 'carteira' 16, 'numero_documento' 17 digits and 'codigo_cedente' 6 digits" do
|
|
255
|
-
subject { BancoBrasil.new(numero_documento: 12345678911234567, carteira: 16, codigo_cedente: 123456) }
|
|
256
|
-
|
|
257
|
-
it { expect(subject.nosso_numero_dezessete_posicoes?).to be true }
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
context "when is 'carteira' is not supported" do
|
|
261
|
-
subject { BancoBrasil.new(numero_documento: 123456789, carteira: 12, codigo_cedente: 123456) }
|
|
262
|
-
|
|
263
|
-
it { expect(subject.nosso_numero_dezessete_posicoes?).to be false }
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
context "when is 'codigo_cedente' is not supported" do
|
|
267
|
-
subject { BancoBrasil.new(numero_documento: 123456789, carteira: 16, codigo_cedente: 1234567) }
|
|
268
|
-
|
|
269
|
-
it { expect(subject.nosso_numero_dezessete_posicoes?).to be false }
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
describe "#codigo_de_barras" do
|
|
274
|
-
context "'codigo_cedente' with 4 digits" do
|
|
275
|
-
subject do
|
|
276
|
-
BancoBrasil.new do |banco_brasil|
|
|
277
|
-
banco_brasil.carteira = 18
|
|
278
|
-
banco_brasil.valor_documento = 2952.95
|
|
279
|
-
banco_brasil.numero_documento = 90801
|
|
280
|
-
banco_brasil.agencia = 7123
|
|
281
|
-
banco_brasil.conta_corrente = 19345
|
|
282
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
283
|
-
banco_brasil.codigo_cedente = 4321
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
it { expect(subject.codigo_de_barras).to eq '00193556100002952954321009080171230001934518' }
|
|
288
|
-
it { expect(subject.linha_digitavel).to eq '00194.32103 09080.171235 00019.345180 3 55610000295295' }
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
context "'codigo_cedente' with 6 digits" do
|
|
292
|
-
subject do
|
|
293
|
-
BancoBrasil.new do |banco_brasil|
|
|
294
|
-
banco_brasil.carteira = 18
|
|
295
|
-
banco_brasil.valor_documento = 14001.99
|
|
296
|
-
banco_brasil.numero_documento = 12901
|
|
297
|
-
banco_brasil.agencia = 5030
|
|
298
|
-
banco_brasil.conta_corrente = 14204195
|
|
299
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
300
|
-
banco_brasil.codigo_cedente = 555444
|
|
301
|
-
end
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
it { expect(subject.codigo_de_barras).to eq '00197556100014001995554441290150301420419518' }
|
|
305
|
-
it { expect(subject.linha_digitavel).to eq '00195.55440 41290.150303 14204.195185 7 55610001400199' }
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
context "'codigo_cedente' with 6 digits and 'nosso numero' with 17 digits" do
|
|
309
|
-
subject do
|
|
310
|
-
BancoBrasil.new do |banco_brasil|
|
|
311
|
-
banco_brasil.carteira = 12
|
|
312
|
-
banco_brasil.valor_documento = 14001.99
|
|
313
|
-
banco_brasil.numero_documento = 12345678911234567
|
|
314
|
-
banco_brasil.agencia = 5030
|
|
315
|
-
banco_brasil.conta_corrente = 14204195
|
|
316
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
317
|
-
banco_brasil.codigo_cedente = 555444
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it { expect(subject.linha_digitavel).to eq '' }
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
context "'codigo_cedente' with 6 digits and 'nosso numero' with 17 digits" do
|
|
325
|
-
subject do
|
|
326
|
-
BancoBrasil.new do |banco_brasil|
|
|
327
|
-
banco_brasil.carteira = 18
|
|
328
|
-
banco_brasil.valor_documento = 14001.99
|
|
329
|
-
banco_brasil.numero_documento = 12345678911234567
|
|
330
|
-
banco_brasil.agencia = 5030
|
|
331
|
-
banco_brasil.conta_corrente = 14204195
|
|
332
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
333
|
-
banco_brasil.codigo_cedente = 555444
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
it { expect(subject.codigo_de_barras).to eq '00194556100014001995554441234567891123456721' }
|
|
338
|
-
it { expect(subject.linha_digitavel).to eq '00195.55440 41234.567893 11234.567219 4 55610001400199' }
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
context "'codigo_cedente' with 7 digits" do
|
|
342
|
-
subject do
|
|
343
|
-
BancoBrasil.new do |banco_brasil|
|
|
344
|
-
banco_brasil.carteira = 18
|
|
345
|
-
banco_brasil.valor_documento = 2952.95
|
|
346
|
-
banco_brasil.numero_documento = 87654
|
|
347
|
-
banco_brasil.agencia = 9999
|
|
348
|
-
banco_brasil.conta_corrente = 99999
|
|
349
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
350
|
-
banco_brasil.codigo_cedente = 7777777
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
it { expect(subject.codigo_de_barras).to eq '00197556100002952950000007777777000008765418' }
|
|
355
|
-
it { expect(subject.linha_digitavel).to eq '00190.00009 07777.777009 00087.654182 7 55610000295295' }
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
context "'codigo_cedente' with 8 digits" do
|
|
359
|
-
subject do
|
|
360
|
-
BancoBrasil.new do |banco_brasil|
|
|
361
|
-
banco_brasil.carteira = 18
|
|
362
|
-
banco_brasil.valor_documento = 2952.95
|
|
363
|
-
banco_brasil.numero_documento = 87654
|
|
364
|
-
banco_brasil.agencia = 9999
|
|
365
|
-
banco_brasil.conta_corrente = 99999
|
|
366
|
-
banco_brasil.data_vencimento = Date.parse('2012-12-28')
|
|
367
|
-
banco_brasil.codigo_cedente = 77777778
|
|
368
|
-
end
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
it { expect(subject.codigo_de_barras).to eq '00191556100002952950000007777777800008765418' }
|
|
372
|
-
it { expect(subject.linha_digitavel).to eq '00190.00009 07777.777801 00087.654182 1 55610000295295' }
|
|
373
|
-
end
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
end
|
|
377
|
-
end
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Core
|
|
5
|
-
describe Banrisul do
|
|
6
|
-
it_should_behave_like 'boleto bancario'
|
|
7
|
-
|
|
8
|
-
describe "on validations" do
|
|
9
|
-
it "agencia should have 3 digits" do
|
|
10
|
-
should have_valid(:agencia).when("1", "123", 1, 123)
|
|
11
|
-
should_not have_valid(:agencia).when(nil, "", "1234")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "codigo cedente should have 07 digits" do
|
|
15
|
-
should have_valid(:codigo_cedente).when("1234567", "12", "12345")
|
|
16
|
-
should_not have_valid(:codigo_cedente).when(nil, "", "12345678", "123456789")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "numero documento should have 8 digits" do
|
|
20
|
-
should have_valid(:numero_documento).when("12345678", "1234")
|
|
21
|
-
should_not have_valid(:numero_documento).when(nil, "", "123456789")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "carteira is supported" do
|
|
25
|
-
should have_valid(:carteira).when('00', '08', 0, 8)
|
|
26
|
-
should_not have_valid(:carteira).when(nil, '', '5', '20', '100')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe "#valor_documento" do
|
|
30
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
31
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe "#agencia" do
|
|
36
|
-
context "when have a value" do
|
|
37
|
-
subject { Banrisul.new(agencia: '34') }
|
|
38
|
-
|
|
39
|
-
it { expect(subject.agencia).to eq '034' }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "when is nil" do
|
|
43
|
-
subject { Banrisul.new(agencia: nil) }
|
|
44
|
-
|
|
45
|
-
it { expect(subject.agencia).to be nil }
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
describe "#numero_documento" do
|
|
50
|
-
context "when have a value" do
|
|
51
|
-
subject { Banrisul.new(numero_documento: '1234') }
|
|
52
|
-
|
|
53
|
-
it { expect(subject.numero_documento).to eq '00001234' }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when is nil" do
|
|
57
|
-
subject { Banrisul.new(numero_documento: nil) }
|
|
58
|
-
|
|
59
|
-
it { expect(subject.numero_documento).to be nil }
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe "#codigo_cedente" do
|
|
64
|
-
context "when have a value" do
|
|
65
|
-
subject { Banrisul.new(codigo_cedente: '1234') }
|
|
66
|
-
|
|
67
|
-
it { expect(subject.codigo_cedente).to eq '0001234' }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "when is nil" do
|
|
71
|
-
subject { Banrisul.new(codigo_cedente: nil) }
|
|
72
|
-
|
|
73
|
-
it { expect(subject.codigo_cedente).to be nil }
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe "#codigo_banco" do
|
|
78
|
-
it { expect(subject.codigo_banco).to eq '041' }
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
describe "#digito_codigo_banco" do
|
|
82
|
-
it { expect(subject.digito_codigo_banco).to eq '8' }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe "#agencia_codigo_cedente" do
|
|
86
|
-
subject { Banrisul.new(agencia: '100', codigo_cedente: '0000001') }
|
|
87
|
-
|
|
88
|
-
it { expect(subject.agencia_codigo_cedente).to eq '100.81 0000001.83' }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
describe "#nosso_numero" do
|
|
92
|
-
context "using one example from documentation" do
|
|
93
|
-
subject { Banrisul.new(numero_documento: '00009194') }
|
|
94
|
-
|
|
95
|
-
it { expect(subject.nosso_numero).to eq '00009194.38' }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context "using other example from documentation" do
|
|
99
|
-
subject { Banrisul.new(numero_documento: '00009274') }
|
|
100
|
-
|
|
101
|
-
it { expect(subject.nosso_numero).to eq '00009274.22' }
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context "another example" do
|
|
105
|
-
subject { Banrisul.new(numero_documento: '22832563') }
|
|
106
|
-
|
|
107
|
-
it { expect(subject.nosso_numero).to eq '22832563.51' }
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe "#codigo_de_barras" do
|
|
112
|
-
context "one example" do
|
|
113
|
-
subject do
|
|
114
|
-
Banrisul.new do |boleto|
|
|
115
|
-
boleto.numero_documento = 22832563
|
|
116
|
-
boleto.agencia = 100
|
|
117
|
-
boleto.data_vencimento = Date.parse('2004-07-04')
|
|
118
|
-
boleto.codigo_cedente = "0000001"
|
|
119
|
-
boleto.valor_documento = 5.0
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it { expect(subject.codigo_de_barras).to eq '04197246200000005002110000000012283256304168' }
|
|
124
|
-
it { expect(subject.linha_digitavel).to eq '04192.11008 00000.012286 32563.041683 7 24620000000500' }
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|