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,333 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module BoletoBancario
|
|
4
|
-
module Core
|
|
5
|
-
describe Itau do
|
|
6
|
-
it_should_behave_like 'boleto bancario'
|
|
7
|
-
|
|
8
|
-
describe "on validations" do
|
|
9
|
-
context "#carteira" do
|
|
10
|
-
it { should have_valid(:carteira).when('107', '109', '174', '175', '196', '198', '126', '131', '146', '122', '142', '143', '150', '168', 109, 131, 168) }
|
|
11
|
-
it { should_not have_valid(:carteira).when(nil, '', '05', '20', '100', '115', '145', '170') }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "#numero_documento" do
|
|
15
|
-
it { should have_valid(:numero_documento).when('12345', '123456', '12345678') }
|
|
16
|
-
it { should_not have_valid(:numero_documento).when('123456789', nil, '', '12345678910') }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "#conta_corrente" do
|
|
20
|
-
it { should have_valid(:conta_corrente).when('1', '1234', '12345') }
|
|
21
|
-
it { should_not have_valid(:conta_corrente).when('123456', nil, '1234567', '') }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe "#agencia" do
|
|
25
|
-
it { should have_valid(:agencia).when('1', '1234', '1234') }
|
|
26
|
-
it { should_not have_valid(:agencia).when('12345', nil, '123456', '') }
|
|
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
|
-
|
|
34
|
-
describe "#codigo_cedente" do
|
|
35
|
-
%w(107 122 142 143 196 198).each do |carteira_especial|
|
|
36
|
-
context "when 'carteira' is special: #{carteira_especial}" do
|
|
37
|
-
subject { Itau.new(carteira: carteira_especial) }
|
|
38
|
-
|
|
39
|
-
it { should have_valid(:codigo_cedente).when('1', '1234', '12345') }
|
|
40
|
-
it { should_not have_valid(:codigo_cedente).when('123456', nil, '1234567', '') }
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
%w(109 126 131 146 150 168 174 175).each do |carteira|
|
|
45
|
-
context "when 'carteira' isn't special: #{carteira}" do
|
|
46
|
-
subject { Itau.new(carteira: carteira) }
|
|
47
|
-
|
|
48
|
-
# Código do Cedente não precisa ser validado quando possui essas carteiras.
|
|
49
|
-
#
|
|
50
|
-
it { should have_valid(:codigo_cedente).when('1', '1234', '12345', nil, '') }
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "#seu_numero" do
|
|
55
|
-
%w(107 122 142 143 196 198).each do |carteira_especial|
|
|
56
|
-
context "when 'carteira' is special: #{carteira_especial}" do
|
|
57
|
-
subject { Itau.new(carteira: carteira_especial) }
|
|
58
|
-
|
|
59
|
-
it { should have_valid(:seu_numero).when('1', '1234', '1234567') }
|
|
60
|
-
it { should_not have_valid(:seu_numero).when('12345678', nil, '123456789', '') }
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
%w(109 126 131 146 150 168 174 175).each do |carteira|
|
|
65
|
-
context "when 'carteira' isn't special: #{carteira}" do
|
|
66
|
-
subject { Itau.new(carteira: carteira) }
|
|
67
|
-
|
|
68
|
-
# Seu número não precisa ser validado quando possui essas carteiras.
|
|
69
|
-
#
|
|
70
|
-
it { should have_valid(:seu_numero).when('1', '1234', '12345', nil, '') }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe "#numero_documento" do
|
|
78
|
-
subject { Itau.new(:numero_documento => '123') }
|
|
79
|
-
|
|
80
|
-
it { expect(subject.numero_documento).to eq '00000123' }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
describe "#seu_numero" do
|
|
84
|
-
context "when have a value" do
|
|
85
|
-
subject { Itau.new(:seu_numero => '11804') }
|
|
86
|
-
|
|
87
|
-
it { expect(subject.seu_numero).to eq '0011804' }
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context "when is nil" do
|
|
91
|
-
subject { Itau.new(:seu_numero => nil) }
|
|
92
|
-
|
|
93
|
-
it { expect(subject.seu_numero).to be nil }
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
describe "#agencia" do
|
|
98
|
-
context "when have a value" do
|
|
99
|
-
subject { Itau.new(:agencia => '001') }
|
|
100
|
-
|
|
101
|
-
it { expect(subject.agencia).to eq '0001' }
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context "when is nil" do
|
|
105
|
-
subject { Itau.new(:agencia => nil) }
|
|
106
|
-
|
|
107
|
-
it { expect(subject.agencia).to be nil }
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe "#conta_corrente" do
|
|
112
|
-
context "when have a value" do
|
|
113
|
-
subject { Itau.new(:conta_corrente => 9013) }
|
|
114
|
-
|
|
115
|
-
it { expect(subject.conta_corrente).to eq '09013' }
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
context "when is nil" do
|
|
119
|
-
subject { Itau.new(:conta_corrente => nil) }
|
|
120
|
-
|
|
121
|
-
it { expect(subject.conta_corrente).to be nil }
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
describe "#codigo_cedente" do
|
|
126
|
-
context "when have a value" do
|
|
127
|
-
subject { Itau.new(:codigo_cedente => 1987) }
|
|
128
|
-
|
|
129
|
-
it { expect(subject.codigo_cedente).to eq '01987' }
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context "when is nil" do
|
|
133
|
-
subject { Itau.new(:codigo_cedente => nil) }
|
|
134
|
-
|
|
135
|
-
it { expect(subject.codigo_cedente).to be nil }
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
describe "#codigo_banco" do
|
|
140
|
-
it { expect(subject.codigo_banco).to eq '341' }
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
describe "#digito_codigo_banco" do
|
|
144
|
-
it { expect(subject.digito_codigo_banco).to eq '7' }
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
describe "#agencia_codigo_cedente" do
|
|
148
|
-
subject { Itau.new(:agencia => '0057', :conta_corrente => '12345') }
|
|
149
|
-
|
|
150
|
-
it "should return the agency and bank account with digit" do
|
|
151
|
-
subject.agencia_codigo_cedente.should eq '0057 / 12345-7'
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
describe "#nosso_numero" do
|
|
156
|
-
context "when 'carteira' is 126" do
|
|
157
|
-
subject { Itau.new(:carteira => '126', :numero_documento => '12345') }
|
|
158
|
-
|
|
159
|
-
it "should calculate the 'nosso numero' with carteira and document number" do
|
|
160
|
-
subject.nosso_numero.should eq '126/00012345-8'
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context "when 'carteira' is 131" do
|
|
165
|
-
subject { Itau.new(:carteira => '131', :numero_documento => '6789') }
|
|
166
|
-
|
|
167
|
-
it "should calculate the 'nosso numero' with carteira and document number" do
|
|
168
|
-
subject.nosso_numero.should eq '131/00006789-5'
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
context "when 'carteira' is 146" do
|
|
173
|
-
subject { Itau.new(:carteira => '146', :numero_documento => '147890') }
|
|
174
|
-
|
|
175
|
-
it "should calculate the 'nosso numero' with carteira and document number" do
|
|
176
|
-
subject.nosso_numero.should eq '146/00147890-9'
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
context "when 'carteira' is 150" do
|
|
181
|
-
subject { Itau.new(:carteira => '150', :numero_documento => '18765476') }
|
|
182
|
-
|
|
183
|
-
it "should calculate the 'nosso numero' with carteira and document number" do
|
|
184
|
-
subject.nosso_numero.should eq '150/18765476-2'
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
context "when 'carteira' is 168" do
|
|
189
|
-
subject { Itau.new(:carteira => '168', :numero_documento => '12784698') }
|
|
190
|
-
|
|
191
|
-
it "should calculate the 'nosso numero' with carteira and document number" do
|
|
192
|
-
subject.nosso_numero.should eq '168/12784698-3'
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
context "when 'carteira' is 110" do
|
|
197
|
-
subject do
|
|
198
|
-
Itau.new(
|
|
199
|
-
:agencia => '0057',
|
|
200
|
-
:conta_corrente => '12345',
|
|
201
|
-
:carteira => '110',
|
|
202
|
-
:numero_documento => '12345678'
|
|
203
|
-
)
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "should format the 'nosso numero' with agencia, conta_corrente, carteira and document number" do
|
|
207
|
-
subject.nosso_numero.should eq '110/12345678-8'
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
context "when 'carteira' is 198" do
|
|
212
|
-
subject do
|
|
213
|
-
Itau.new(
|
|
214
|
-
:agencia => '0057',
|
|
215
|
-
:conta_corrente => '72192',
|
|
216
|
-
:carteira => '198',
|
|
217
|
-
:numero_documento => '98712345'
|
|
218
|
-
)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "should follow the Itau documentation" do
|
|
222
|
-
subject.nosso_numero.should eq '198/98712345-1'
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
describe "#carteira_especial?" do
|
|
228
|
-
%w(107 122 142 143 196 198).each do |carteira_especial|
|
|
229
|
-
context "when 'carteira' is special: #{carteira_especial}" do
|
|
230
|
-
subject { Itau.new(carteira: carteira_especial) }
|
|
231
|
-
|
|
232
|
-
it { expect(subject.carteira_especial?).to be true }
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
context "when 'carteira' is special: #{carteira_especial} as numeric" do
|
|
236
|
-
subject { Itau.new(carteira: carteira_especial.to_i) }
|
|
237
|
-
|
|
238
|
-
it { expect(subject.carteira_especial?).to be true }
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
%w(109 126 131 146 150 168 174 175).each do |carteira|
|
|
243
|
-
context "when 'carteira' isn't special: #{carteira}" do
|
|
244
|
-
subject { Itau.new(carteira: carteira) }
|
|
245
|
-
|
|
246
|
-
it { expect(subject.carteira_especial?).to be false }
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
describe "#codigo_de_barras_do_banco" do
|
|
252
|
-
context "when default carteira" do
|
|
253
|
-
subject do
|
|
254
|
-
Itau.new do |boleto|
|
|
255
|
-
boleto.carteira = '109'
|
|
256
|
-
boleto.numero_documento = '12345678'
|
|
257
|
-
boleto.agencia = '0057'
|
|
258
|
-
boleto.conta_corrente = '12345'
|
|
259
|
-
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1091234567800057123457000' }
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
context "when special 'carteira'" do
|
|
266
|
-
subject do
|
|
267
|
-
Itau.new(
|
|
268
|
-
:codigo_cedente => '94786',
|
|
269
|
-
:carteira => carteira,
|
|
270
|
-
:numero_documento => '12345678',
|
|
271
|
-
:seu_numero => '1108954'
|
|
272
|
-
)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
context "when 'carteira' is 107" do
|
|
276
|
-
let(:carteira) { '107' }
|
|
277
|
-
|
|
278
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1071234567811089549478620' }
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
context "when 'carteira' is 122" do
|
|
282
|
-
let(:carteira) { '122' }
|
|
283
|
-
|
|
284
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1221234567811089549478610' }
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
context "when 'carteira' is 142" do
|
|
288
|
-
let(:carteira) { '142' }
|
|
289
|
-
|
|
290
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1421234567811089549478690' }
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
context "when 'carteira' is 143" do
|
|
294
|
-
let(:carteira) { '143' }
|
|
295
|
-
|
|
296
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1431234567811089549478670' }
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
context "when 'carteira' is 196" do
|
|
300
|
-
let(:carteira) { '196' }
|
|
301
|
-
|
|
302
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1961234567811089549478650' }
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
context "when 'carteira' is 198" do
|
|
306
|
-
let(:carteira) { '198' }
|
|
307
|
-
|
|
308
|
-
it { expect(subject.codigo_de_barras_do_banco).to eq '1981234567811089549478610' }
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
describe "#linha_digitavel" do
|
|
314
|
-
subject do
|
|
315
|
-
Itau.new do |boleto|
|
|
316
|
-
boleto.carteira = '175'
|
|
317
|
-
boleto.agencia = 1565
|
|
318
|
-
boleto.conta_corrente = 13877
|
|
319
|
-
boleto.numero_documento = 12345678
|
|
320
|
-
boleto.data_vencimento = Date.parse('2012-12-21')
|
|
321
|
-
boleto.valor_documento = 2952.95
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
it { expect(subject.linha_digitavel).to eq '34191.75124 34567.861561 51387.710000 1 55540000295295' }
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
describe "#to_partial_path" do
|
|
329
|
-
it { expect(subject.to_partial_path).to eq 'boleto_bancario/itau' }
|
|
330
|
-
end
|
|
331
|
-
end
|
|
332
|
-
end
|
|
333
|
-
end
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
module BoletoBancario
|
|
5
|
-
module Core
|
|
6
|
-
describe Real do
|
|
7
|
-
it_should_behave_like 'boleto bancario'
|
|
8
|
-
|
|
9
|
-
describe "on validations" do
|
|
10
|
-
it { should have_valid(:agencia).when('1', '12', '123', '1234') }
|
|
11
|
-
it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
|
|
12
|
-
|
|
13
|
-
it { should have_valid(:conta_corrente).when('1', '12', '123', '1234567') }
|
|
14
|
-
it { should_not have_valid(:conta_corrente).when('12345678', '123456789', nil, '') }
|
|
15
|
-
|
|
16
|
-
it { should have_valid(:numero_documento).when('1', '12', '123', '1234567891123') }
|
|
17
|
-
it { should_not have_valid(:numero_documento).when('12345678911234', nil, '') }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('0', 20, '31', 42, '47', 85) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(nil, '1', 2, '123') }
|
|
21
|
-
|
|
22
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
23
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "#agencia" do
|
|
27
|
-
context "when have a value" do
|
|
28
|
-
subject { Real.new(agencia: '802') }
|
|
29
|
-
|
|
30
|
-
it { expect(subject.agencia).to eq '0802' }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "when is nil" do
|
|
34
|
-
it { expect(subject.agencia).to be nil }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#conta_corrente" do
|
|
39
|
-
context "when have a value" do
|
|
40
|
-
subject { Real.new(conta_corrente: '1625') }
|
|
41
|
-
|
|
42
|
-
it { expect(subject.conta_corrente).to eq '0001625' }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when is nil" do
|
|
46
|
-
it { expect(subject.conta_corrente).to be nil }
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "#numero_documento" do
|
|
51
|
-
context "when have a value" do
|
|
52
|
-
subject { Real.new(numero_documento: '2483169') }
|
|
53
|
-
|
|
54
|
-
it { expect(subject.numero_documento).to eq '0000002483169' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when is nil" do
|
|
58
|
-
it { expect(subject.numero_documento).to be nil }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe "#carteira" do
|
|
63
|
-
context "when have a value" do
|
|
64
|
-
subject { Real.new(carteira: '20') }
|
|
65
|
-
|
|
66
|
-
it { expect(subject.carteira).to eq '20' }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "when is nil" do
|
|
70
|
-
it { expect(subject.carteira).to be nil }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe "#codigo_banco" do
|
|
75
|
-
it { expect(subject.codigo_banco).to eq '356' }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe "#digito_codigo_banco" do
|
|
79
|
-
it { expect(subject.digito_codigo_banco).to eq '5' }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe "#agencia_codigo_beneficiario" do
|
|
83
|
-
subject { Real.new(agencia: '501', conta_corrente: 6703255) }
|
|
84
|
-
|
|
85
|
-
it { expect(subject.agencia_codigo_cedente).to eq '0501/6703255/1' }
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "#codigo_de_barras" do
|
|
89
|
-
subject do
|
|
90
|
-
Real.new do |real|
|
|
91
|
-
real.agencia = 501
|
|
92
|
-
real.conta_corrente = '6703255'
|
|
93
|
-
real.numero_documento = 3020
|
|
94
|
-
real.valor_documento = 35
|
|
95
|
-
real.data_vencimento = Date.parse('2001-10-02')
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it { expect(subject.codigo_de_barras).to eq '35699145600000035000501670325510000000003020' }
|
|
100
|
-
it { expect(subject.linha_digitavel).to eq '35690.50168 70325.510009 00000.030205 9 14560000003500' }
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
module BoletoBancario
|
|
5
|
-
module Core
|
|
6
|
-
describe Santander do
|
|
7
|
-
it_should_behave_like 'boleto bancario'
|
|
8
|
-
|
|
9
|
-
describe "on validations" do
|
|
10
|
-
it { should have_valid(:agencia).when('1', '12', '123', '1234') }
|
|
11
|
-
it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
|
|
12
|
-
|
|
13
|
-
it { should have_valid(:codigo_cedente).when('1', '12', '123', '1234567') }
|
|
14
|
-
it { should_not have_valid(:codigo_cedente).when('12345678', '123456789', nil, '') }
|
|
15
|
-
|
|
16
|
-
it { should have_valid(:numero_documento).when('1', '12', '123', '123456789112') }
|
|
17
|
-
it { should_not have_valid(:numero_documento).when('1234567891123', nil, '') }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('101', '102', '121', 101, 102, 121) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(nil, '', '05', '20', '100', '120') }
|
|
21
|
-
|
|
22
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
23
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "#agencia" do
|
|
27
|
-
context "when have a value" do
|
|
28
|
-
subject { Santander.new(agencia: '2') }
|
|
29
|
-
|
|
30
|
-
it { expect(subject.agencia).to eq '0002' }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "when is nil" do
|
|
34
|
-
it { expect(subject.agencia).to be nil }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#codigo_cedente" do
|
|
39
|
-
context "when have a value" do
|
|
40
|
-
subject { Santander.new(codigo_cedente: '1') }
|
|
41
|
-
|
|
42
|
-
it { expect(subject.codigo_cedente).to eq '0000001' }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when is nil" do
|
|
46
|
-
it { expect(subject.codigo_cedente).to be nil }
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "#numero_documento" do
|
|
51
|
-
context "when have a value" do
|
|
52
|
-
subject { Santander.new(numero_documento: '1') }
|
|
53
|
-
|
|
54
|
-
it { expect(subject.numero_documento).to eq '000000000001' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when is nil" do
|
|
58
|
-
it { expect(subject.numero_documento).to be nil }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe "#carteira" do
|
|
63
|
-
context "when have a value" do
|
|
64
|
-
subject { Santander.new(carteira: '101') }
|
|
65
|
-
|
|
66
|
-
it { expect(subject.carteira).to eq '101' }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "when is nil" do
|
|
70
|
-
it { expect(subject.carteira).to be nil }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe "#carteira_formatada" do
|
|
75
|
-
context "when is registered" do
|
|
76
|
-
subject { Santander.new(:carteira => 101) }
|
|
77
|
-
|
|
78
|
-
it { expect(subject.carteira_formatada).to eq 'COBRANÇA SIMPLES ECR' }
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context "when isn't registered" do
|
|
82
|
-
subject { Santander.new(:carteira => 102) }
|
|
83
|
-
|
|
84
|
-
it { expect(subject.carteira_formatada).to eq 'COBRANÇA SIMPLES CSR' }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "#codigo_banco" do
|
|
89
|
-
it { expect(subject.codigo_banco).to eq '033' }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe "#digito_codigo_banco" do
|
|
93
|
-
it { expect(subject.digito_codigo_banco).to eq '7' }
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
describe "#agencia_codigo_cedente" do
|
|
97
|
-
subject { Santander.new(agencia: '0235', codigo_cedente: '1625462') }
|
|
98
|
-
|
|
99
|
-
it { expect(subject.agencia_codigo_cedente).to eq '0235 / 1625462' }
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
describe "#nosso_numero" do
|
|
103
|
-
subject { Santander.new(numero_documento: '566612457800') }
|
|
104
|
-
|
|
105
|
-
it { expect(subject.nosso_numero).to eq '566612457800-2' }
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
describe "#codigo_de_barras" do
|
|
109
|
-
subject do
|
|
110
|
-
Santander.new do |santander|
|
|
111
|
-
santander.codigo_cedente = '0707077'
|
|
112
|
-
santander.numero_documento = '000001234567'
|
|
113
|
-
santander.valor_documento = 2952.95
|
|
114
|
-
santander.carteira = '102'
|
|
115
|
-
santander.agencia = 1333
|
|
116
|
-
santander.data_vencimento = Date.parse('2012-12-28')
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it { expect(subject.codigo_de_barras).to eq '03391556100002952959070707700000123456790102' }
|
|
121
|
-
it { expect(subject.linha_digitavel).to eq '03399.07073 07700.000123 34567.901029 1 55610000295295' }
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
describe "#iof" do
|
|
125
|
-
context "default iof" do
|
|
126
|
-
it { expect(subject.iof).to eq '0' }
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
context "setting iof" do
|
|
130
|
-
subject { Santander.new(iof: 7) }
|
|
131
|
-
|
|
132
|
-
it { expect(subject.iof).to eq '7' }
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
module BoletoBancario
|
|
5
|
-
module Core
|
|
6
|
-
describe Sicoob do
|
|
7
|
-
it_should_behave_like 'boleto bancario'
|
|
8
|
-
|
|
9
|
-
describe "on validations" do
|
|
10
|
-
it { should have_valid(:agencia).when('1', '12', '123', '1234') }
|
|
11
|
-
it { should_not have_valid(:agencia).when('12345', '123456', nil, '') }
|
|
12
|
-
|
|
13
|
-
it { should have_valid(:codigo_cedente).when('1', 12345, '1234567') }
|
|
14
|
-
it { should_not have_valid(:codigo_cedente).when('12345678', 123456789, nil, '') }
|
|
15
|
-
|
|
16
|
-
it { should have_valid(:numero_documento).when('1', 12345, '123456') }
|
|
17
|
-
it { should_not have_valid(:numero_documento).when('1234567', nil, '') }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('1', 1, '9', 9) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(nil, '', 2, '6') }
|
|
21
|
-
|
|
22
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
23
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "#agencia" do
|
|
27
|
-
context "when have a value" do
|
|
28
|
-
subject { Sicoob.new(agencia: '215') }
|
|
29
|
-
|
|
30
|
-
it { expect(subject.agencia).to eq '0215' }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "when is nil" do
|
|
34
|
-
it { expect(subject.agencia).to be nil }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#conta_corrente" do
|
|
39
|
-
context "when have a value" do
|
|
40
|
-
subject { Sicoob.new(codigo_cedente: '9201') }
|
|
41
|
-
|
|
42
|
-
it { expect(subject.codigo_cedente).to eq '0009201' }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when is nil" do
|
|
46
|
-
it { expect(subject.codigo_cedente).to be nil }
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "#numero_documento" do
|
|
51
|
-
context "when have a value" do
|
|
52
|
-
subject { Sicoob.new(numero_documento: '1') }
|
|
53
|
-
|
|
54
|
-
it { expect(subject.numero_documento).to eq '000001' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when is nil" do
|
|
58
|
-
it { expect(subject.numero_documento).to be nil }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe "#carteira" do
|
|
63
|
-
context "when have a value" do
|
|
64
|
-
subject { Sicoob.new(carteira: '1') }
|
|
65
|
-
|
|
66
|
-
it { expect(subject.carteira).to eq '1' }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "when is nil" do
|
|
70
|
-
it { expect(subject.carteira).to be nil }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe "#codigo_banco" do
|
|
75
|
-
it { expect(subject.codigo_banco).to eq '756' }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe "#digito_codigo_banco" do
|
|
79
|
-
it { expect(subject.digito_codigo_banco).to eq '0' }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe "#agencia_codigo_beneficiario" do
|
|
83
|
-
subject { Sicoob.new(agencia: 48, codigo_cedente: '7368') }
|
|
84
|
-
|
|
85
|
-
it { expect(subject.agencia_codigo_cedente).to eq '0048 / 0007368' }
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "#nosso_numero" do
|
|
89
|
-
subject { Sicoob.new(numero_documento: '68315') }
|
|
90
|
-
|
|
91
|
-
it { expect(subject.nosso_numero).to eq '15068315' }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe "#codigo_de_barras" do
|
|
95
|
-
subject do
|
|
96
|
-
Sicoob.new do |sicoob|
|
|
97
|
-
sicoob.agencia = 95
|
|
98
|
-
sicoob.codigo_cedente = 6532
|
|
99
|
-
sicoob.numero_documento = 1101
|
|
100
|
-
sicoob.carteira = 1
|
|
101
|
-
sicoob.valor_documento = 93015.78
|
|
102
|
-
sicoob.data_vencimento = Date.parse('2019-02-17')
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it { expect(subject.codigo_de_barras).to eq '75692780300093015781009501000653215001101001' }
|
|
107
|
-
it { expect(subject.linha_digitavel).to eq '75691.00956 01000.653210 50011.010019 2 78030009301578' }
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|