kivanio-brcobranca 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +5 -1
  2. data/Manifest.txt +24 -0
  3. data/PostInstall.txt +4 -0
  4. data/README.rdoc +4 -4
  5. data/Rakefile +9 -6
  6. data/brcobranca.gemspec +9 -9
  7. data/lib/brcobranca.rb +10 -2
  8. data/lib/brcobranca/arquivos/logos/banespa.jpg +0 -0
  9. data/lib/brcobranca/boleto/banco_banespa.rb +85 -0
  10. data/lib/brcobranca/boleto/banco_bradesco.rb +14 -1
  11. data/lib/brcobranca/boleto/banco_brasil.rb +18 -9
  12. data/lib/brcobranca/boleto/banco_hsbc.rb +22 -8
  13. data/lib/brcobranca/boleto/banco_itau.rb +20 -10
  14. data/lib/brcobranca/boleto/banco_real.rb +16 -2
  15. data/lib/brcobranca/boleto/banco_unibanco.rb +19 -5
  16. data/lib/brcobranca/boleto/base.rb +21 -15
  17. data/lib/brcobranca/boleto/template/rghost.rb +18 -16
  18. data/lib/brcobranca/boleto/template/util.rb +2 -0
  19. data/lib/brcobranca/core_ext.rb +57 -47
  20. data/lib/brcobranca/currency.rb +7 -10
  21. data/spec/arquivos/CBR64310.RET +28 -0
  22. data/spec/brcobranca/banco_banespa_spec.rb +195 -0
  23. data/spec/brcobranca/banco_bradesco_spec.rb +179 -0
  24. data/spec/brcobranca/banco_brasil_spec.rb +353 -0
  25. data/spec/brcobranca/banco_hsbc_spec.rb +216 -0
  26. data/spec/brcobranca/banco_itau_spec.rb +202 -0
  27. data/spec/brcobranca/banco_real_spec.rb +145 -0
  28. data/spec/brcobranca/banco_unibanco_spec.rb +193 -0
  29. data/spec/brcobranca/base_spec.rb +240 -0
  30. data/spec/brcobranca/core_ext_spec.rb +275 -0
  31. data/spec/brcobranca/currency_spec.rb +81 -0
  32. data/spec/brcobranca/retorno_cbr643_spec.rb +69 -0
  33. data/spec/brcobranca/rghost_spec.rb +36 -0
  34. data/spec/brcobranca/template/rghost_spec.rb +65 -0
  35. data/spec/brcobranca/template/util_spec.rb +42 -0
  36. data/spec/brcobranca_spec.rb +8 -0
  37. data/spec/rcov.opts +2 -0
  38. data/spec/spec.opts +6 -0
  39. data/spec/spec_helper.rb +10 -0
  40. data/tasks/rcov.rake +12 -0
  41. data/tasks/rspec.rake +21 -0
  42. metadata +34 -31
  43. data/test/test_banco_bradesco.rb +0 -87
  44. data/test/test_banco_brasil.rb +0 -276
  45. data/test/test_banco_hsbc.rb +0 -81
  46. data/test/test_banco_itau.rb +0 -103
  47. data/test/test_banco_real.rb +0 -112
  48. data/test/test_banco_unibanco.rb +0 -92
  49. data/test/test_base.rb +0 -162
  50. data/test/test_core_ext.rb +0 -227
  51. data/test/test_currency.rb +0 -51
  52. data/test/test_helper.rb +0 -5
  53. data/test/test_retorno_cbr643.rb +0 -66
  54. data/test/test_rghost.rb +0 -49
@@ -1,87 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoBradesco < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto_novo = BancoBradesco.new
7
- @boleto_novo.cedente = "Kivanio Barbosa"
8
- @boleto_novo.documento_cedente = "12345678912"
9
- @boleto_novo.sacado = "Claudio Pozzebom"
10
- @boleto_novo.sacado_documento = "12345678900"
11
- @boleto_novo.aceite = "S"
12
- @boleto_novo.agencia = "4042"
13
- @boleto_novo.conta_corrente = "61900"
14
- end
15
-
16
- def boleto_1
17
- @boleto_novo.agencia = "1172"
18
- @boleto_novo.conta_corrente = "0403005"
19
- @boleto_novo.carteira = "06"
20
- @boleto_novo.moeda = "9"
21
- @boleto_novo.valor = 2952.95
22
- @boleto_novo.numero_documento = "75896452"
23
- @boleto_novo.data_documento = Date.parse("2009-04-30")
24
- @boleto_novo.dias_vencimento = 0
25
- end
26
-
27
- def boleto_2
28
- @boleto_novo.agencia = "4042"
29
- @boleto_novo.conta_corrente = "61900"
30
- @boleto_novo.carteira = "03"
31
- @boleto_novo.moeda = "9"
32
- @boleto_novo.valor = 135.00
33
- @boleto_novo.numero_documento = "777700168"
34
- @boleto_novo.data_documento = Date.parse("2008-02-01")
35
- @boleto_novo.dias_vencimento = 1
36
- end
37
-
38
- def boleto_nil
39
- @boleto_novo.banco = ""
40
- @boleto_novo.carteira = ""
41
- @boleto_novo.moeda = ""
42
- @boleto_novo.valor = 0
43
- @boleto_novo.convenio = ""
44
- @boleto_novo.numero_documento = ""
45
- @boleto_novo.data_documento = Date.parse("2008-02-01")
46
- @boleto_novo.dias_vencimento = 0
47
- end
48
-
49
- def test_should_initialize_correctly
50
- assert_equal '237', @boleto_novo.banco
51
- assert_equal '06', @boleto_novo.carteira
52
- assert_equal "DM", @boleto_novo.especie_documento
53
- assert_equal "R$", @boleto_novo.especie
54
- assert_equal "9", @boleto_novo.moeda
55
- assert_equal Date.today, @boleto_novo.data_documento
56
- assert_equal 1, @boleto_novo.dias_vencimento
57
- assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
58
- assert_equal "S", @boleto_novo.aceite
59
- assert_equal 1, @boleto_novo.quantidade
60
- assert_equal 0.0, @boleto_novo.valor
61
- assert_equal 0.0, @boleto_novo.valor_documento
62
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
63
- end
64
-
65
- def test_should_mont_correct_codigo_barras
66
- boleto_1
67
- assert_equal "2379422300002952951172060007589645204030050", @boleto_novo.monta_codigo_43_digitos
68
- assert_equal "23795422300002952951172060007589645204030050", @boleto_novo.codigo_barras
69
- boleto_2
70
- assert_equal "2379377000000135004042030077770016800619000", @boleto_novo.monta_codigo_43_digitos
71
- assert_equal "23791377000000135004042030077770016800619000", @boleto_novo.codigo_barras
72
- boleto_nil
73
- assert_equal nil, @boleto_novo.codigo_barras
74
- assert_raise RuntimeError do
75
- boleto_nil
76
- raise 'Verifique as informações do boleto!!!'
77
- end
78
- end
79
-
80
- def test_should_mont_correct_linha_digitalvel
81
- boleto_1
82
- assert_equal("23791.17209 60007.589645 52040.300502 5 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
83
- boleto_2
84
- assert_equal("23794.04201 30077.770011 68006.190000 1 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
85
- end
86
-
87
- end
@@ -1,276 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoBrasil < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto_novo = BancoBrasil.new
7
- @boleto_novo.cedente = "Kivanio Barbosa"
8
- @boleto_novo.documento_cedente = "12345678912"
9
- @boleto_novo.sacado = "Claudio Pozzebom"
10
- @boleto_novo.sacado_documento = "12345678900"
11
- @boleto_novo.aceite = "S"
12
- @boleto_novo.agencia = "4042"
13
- @boleto_novo.conta_corrente = "61900"
14
- end
15
-
16
- def boleto_convenio8_numero9_um
17
- @boleto_novo.banco = "001"
18
- @boleto_novo.carteira = "18"
19
- @boleto_novo.moeda = "9"
20
- @boleto_novo.valor = 135.00
21
- @boleto_novo.convenio = 12387989
22
- @boleto_novo.numero_documento = "777700168"
23
- @boleto_novo.data_documento = Date.parse("2008-02-01")
24
- @boleto_novo.dias_vencimento = 0
25
- end
26
-
27
- def boleto_convenio8_numero9_dois
28
- @boleto_novo.banco = "001"
29
- @boleto_novo.carteira = "18"
30
- @boleto_novo.moeda = "9"
31
- @boleto_novo.valor = 135.00
32
- @boleto_novo.convenio = 12387989
33
- @boleto_novo.numero_documento = "7700168"
34
- @boleto_novo.data_documento = Date.parse("2008-02-01")
35
- @boleto_novo.dias_vencimento = 1
36
- end
37
-
38
- def boleto_convenio7_numero10_um
39
- @boleto_novo.banco = "001"
40
- @boleto_novo.carteira = "18"
41
- @boleto_novo.moeda = "9"
42
- @boleto_novo.valor = 135.00
43
- @boleto_novo.convenio = 1238798
44
- @boleto_novo.numero_documento = "7777700168"
45
- @boleto_novo.data_documento = Date.parse("2008-02-01")
46
- @boleto_novo.dias_vencimento = 2
47
- end
48
-
49
- def boleto_convenio7_numero10_dois
50
- @boleto_novo.banco = "001"
51
- @boleto_novo.carteira = "18"
52
- @boleto_novo.moeda = "9"
53
- @boleto_novo.valor = 723.56
54
- @boleto_novo.convenio = 1238798
55
- @boleto_novo.numero_documento = "7777700168"
56
- @boleto_novo.data_documento = Date.parse("2008-02-01")
57
- @boleto_novo.dias_vencimento = 2
58
- end
59
-
60
- def boleto_convenio7_numero10_tres
61
- @boleto_novo.banco = "001"
62
- @boleto_novo.agencia = "4042"
63
- @boleto_novo.conta_corrente = "15735"
64
- @boleto_novo.carteira = "18"
65
- @boleto_novo.moeda = "9"
66
- @boleto_novo.valor = 723.56
67
- @boleto_novo.convenio = 1238798
68
- @boleto_novo.numero_documento = "7777700168"
69
- @boleto_novo.data_documento = Date.parse("2008-02-01")
70
- @boleto_novo.dias_vencimento = 0
71
- end
72
-
73
- def boleto_convenio6_numero5
74
- @boleto_novo.banco = "001"
75
- @boleto_novo.carteira = "18"
76
- @boleto_novo.agencia = "4042"
77
- @boleto_novo.conta_corrente = "61900"
78
- @boleto_novo.moeda = "9"
79
- @boleto_novo.valor = 135.00
80
- @boleto_novo.convenio = 123879
81
- @boleto_novo.numero_documento = "1234"
82
- @boleto_novo.data_documento = Date.parse("2008-02-01")
83
- @boleto_novo.dias_vencimento = 0
84
- @boleto_novo.codigo_servico = false
85
- end
86
-
87
- def boleto_convenio6_numero17_carteira16
88
- @boleto_novo.banco = "001"
89
- @boleto_novo.carteira = "16"
90
- @boleto_novo.agencia = "4042"
91
- @boleto_novo.conta_corrente = "61900"
92
- @boleto_novo.moeda = "9"
93
- @boleto_novo.valor = 135.00
94
- @boleto_novo.convenio = 123879
95
- @boleto_novo.numero_documento = "1234567899"
96
- @boleto_novo.data_documento = Date.parse("2008-02-01")
97
- @boleto_novo.dias_vencimento = 0
98
- @boleto_novo.codigo_servico = true
99
- end
100
-
101
- def boleto_convenio6_numero17_carteira17
102
- @boleto_novo.banco = "001"
103
- @boleto_novo.carteira = "17"
104
- @boleto_novo.agencia = "4042"
105
- @boleto_novo.conta_corrente = "61900"
106
- @boleto_novo.moeda = "9"
107
- @boleto_novo.valor = 135.00
108
- @boleto_novo.convenio = 123879
109
- @boleto_novo.numero_documento = "1234567899"
110
- @boleto_novo.data_documento = Date.parse("2008-02-01")
111
- @boleto_novo.dias_vencimento = 0
112
- @boleto_novo.codigo_servico = true
113
- end
114
-
115
- def boleto_convenio6_numero17_carteira18
116
- @boleto_novo.banco = "001"
117
- @boleto_novo.carteira = "18"
118
- @boleto_novo.agencia = "4042"
119
- @boleto_novo.conta_corrente = "61900"
120
- @boleto_novo.moeda = "9"
121
- @boleto_novo.valor = 135.00
122
- @boleto_novo.convenio = 123879
123
- @boleto_novo.numero_documento = "1234567899"
124
- @boleto_novo.data_documento = Date.parse("2008-02-01")
125
- @boleto_novo.dias_vencimento = 0
126
- @boleto_novo.codigo_servico = true
127
- end
128
-
129
- def boleto_convenio4_numero7
130
- @boleto_novo.banco = "001"
131
- @boleto_novo.carteira = "18"
132
- @boleto_novo.agencia = "4042"
133
- @boleto_novo.conta_corrente = "61900"
134
- @boleto_novo.moeda = "9"
135
- @boleto_novo.valor = 135.00
136
- @boleto_novo.convenio = 1238
137
- @boleto_novo.numero_documento = "123456"
138
- @boleto_novo.data_documento = Date.parse("2008-02-01")
139
- @boleto_novo.dias_vencimento = 0
140
- end
141
-
142
- def boleto_nil
143
- @boleto_novo.banco = ""
144
- @boleto_novo.carteira = ""
145
- @boleto_novo.moeda = ""
146
- @boleto_novo.valor = 0
147
- @boleto_novo.convenio = ""
148
- @boleto_novo.numero_documento = ""
149
- @boleto_novo.data_documento = Date.parse("2008-02-01")
150
- @boleto_novo.dias_vencimento = 0
151
- end
152
-
153
- def test_should_initialize_correctly
154
- assert_equal '001', @boleto_novo.banco
155
- assert_equal "DM", @boleto_novo.especie_documento
156
- assert_equal "R$", @boleto_novo.especie
157
- assert_equal "9", @boleto_novo.moeda
158
- assert_equal Date.today, @boleto_novo.data_documento
159
- assert_equal 1, @boleto_novo.dias_vencimento
160
- assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
161
- assert_equal "S", @boleto_novo.aceite
162
- assert_equal 1, @boleto_novo.quantidade
163
- assert_equal 0.0, @boleto_novo.valor
164
- assert_equal 0.0, @boleto_novo.valor_documento
165
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
166
- end
167
-
168
- def test_should_mont_correct_codigo_barras
169
- boleto_convenio8_numero9_um
170
- assert_equal "0019376900000135000000001238798977770016818", @boleto_novo.monta_codigo_43_digitos
171
- assert_equal "00193376900000135000000001238798977770016818", @boleto_novo.codigo_barras
172
- boleto_convenio8_numero9_dois
173
- assert_equal "0019377000000135000000001238798900770016818", @boleto_novo.monta_codigo_43_digitos
174
- assert_equal "00193377000000135000000001238798900770016818", @boleto_novo.codigo_barras
175
- boleto_convenio7_numero10_um
176
- assert_equal "0019377100000135000000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
177
- assert_equal "00193377100000135000000001238798777770016818", @boleto_novo.codigo_barras
178
- boleto_convenio7_numero10_dois
179
- assert_equal "0019377100000723560000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
180
- assert_equal "00195377100000723560000001238798777770016818", @boleto_novo.codigo_barras
181
- boleto_convenio7_numero10_tres
182
- assert_equal "0019376900000723560000001238798777770016818", @boleto_novo.monta_codigo_43_digitos
183
- assert_equal "00194376900000723560000001238798777770016818", @boleto_novo.codigo_barras
184
- boleto_convenio6_numero5
185
- assert_equal "0019376900000135001238790123440420006190018", @boleto_novo.monta_codigo_43_digitos
186
- assert_equal "00192376900000135001238790123440420006190018", @boleto_novo.codigo_barras
187
- boleto_convenio6_numero17_carteira16
188
- assert_equal "0019376900000135001238790000000123456789921", @boleto_novo.monta_codigo_43_digitos
189
- assert_equal "00199376900000135001238790000000123456789921", @boleto_novo.codigo_barras
190
- assert_raise RuntimeError do
191
- boleto_convenio6_numero17_carteira17
192
- raise 'Verifique as informações do boleto!!!'
193
- end
194
- boleto_convenio6_numero17_carteira18
195
- assert_equal "0019376900000135001238790000000123456789921", @boleto_novo.monta_codigo_43_digitos
196
- assert_equal "00199376900000135001238790000000123456789921", @boleto_novo.codigo_barras
197
- boleto_convenio4_numero7
198
- assert_equal "0019376900000135001238012345640420006190018", @boleto_novo.monta_codigo_43_digitos
199
- assert_equal "00191376900000135001238012345640420006190018", @boleto_novo.codigo_barras
200
- boleto_nil
201
- assert_equal nil, @boleto_novo.codigo_barras
202
- assert_raise RuntimeError do
203
- boleto_nil
204
- raise 'Verifique as informações do boleto!!!'
205
- end
206
- end
207
-
208
- def test_should_mont_correct_linha_digitalvel
209
- boleto_convenio8_numero9_um
210
- assert_equal("00190.00009 01238.798977 77700.168188 3 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
211
- boleto_convenio8_numero9_dois
212
- assert_equal("00190.00009 01238.798902 07700.168185 3 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
213
- boleto_convenio7_numero10_um
214
- assert_equal("00190.00009 01238.798779 77700.168188 3 37710000013500", @boleto_novo.codigo_barras.linha_digitavel)
215
- boleto_convenio7_numero10_dois
216
- assert_equal("00190.00009 01238.798779 77700.168188 5 37710000072356", @boleto_novo.codigo_barras.linha_digitavel)
217
- boleto_convenio7_numero10_tres
218
- assert_equal("00190.00009 01238.798779 77700.168188 4 37690000072356", @boleto_novo.codigo_barras.linha_digitavel)
219
- boleto_convenio6_numero5
220
- assert_equal("00191.23876 90123.440423 00061.900189 2 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
221
- boleto_convenio6_numero17_carteira16
222
- assert_equal("00191.23876 90000.000126 34567.899215 9 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
223
- assert_raise RuntimeError do
224
- boleto_convenio6_numero17_carteira17
225
- raise 'Verifique as informações do boleto!!!'
226
- end
227
- boleto_convenio6_numero17_carteira18
228
- assert_equal("00191.23876 90000.000126 34567.899215 9 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
229
- boleto_convenio6_numero5
230
- assert_equal("00191.23876 90123.440423 00061.900189 2 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
231
- boleto_convenio4_numero7
232
- assert_equal("00191.23801 12345.640424 00061.900189 1 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
233
- assert_kind_of( String, @boleto_novo.codigo_barras.linha_digitavel)
234
- end
235
-
236
- def test_should_return_correctly_conta_corrente_dv
237
- boleto_convenio8_numero9_um
238
- assert_equal 0, @boleto_novo.conta_corrente_dv
239
- boleto_convenio8_numero9_dois
240
- assert_equal 0, @boleto_novo.conta_corrente_dv
241
- boleto_convenio7_numero10_um
242
- assert_equal 0, @boleto_novo.conta_corrente_dv
243
- boleto_convenio7_numero10_dois
244
- assert_equal 0, @boleto_novo.conta_corrente_dv
245
- boleto_convenio7_numero10_tres
246
- assert_equal "X", @boleto_novo.conta_corrente_dv
247
- boleto_convenio6_numero5
248
- assert_equal 0, @boleto_novo.conta_corrente_dv
249
- boleto_convenio6_numero17_carteira16
250
- assert_equal 0, @boleto_novo.conta_corrente_dv
251
- boleto_convenio6_numero17_carteira17
252
- assert_equal 0, @boleto_novo.conta_corrente_dv
253
- boleto_convenio6_numero17_carteira18
254
- assert_equal 0, @boleto_novo.conta_corrente_dv
255
- boleto_convenio4_numero7
256
- assert_equal 0, @boleto_novo.conta_corrente_dv
257
- end
258
-
259
- def test_should_verify_nosso_numero_dv_calculation
260
- @boleto_novo.numero_documento = "777700168"
261
- assert_equal 0, @boleto_novo.nosso_numero_dv
262
- @boleto_novo.numero_documento = "77700168"
263
- assert_equal 3, @boleto_novo.nosso_numero_dv
264
- @boleto_novo.numero_documento = "00015448"
265
- assert_equal 2, @boleto_novo.nosso_numero_dv
266
- @boleto_novo.numero_documento = "15448"
267
- assert_equal 2, @boleto_novo.nosso_numero_dv
268
- @boleto_novo.numero_documento = "12345678"
269
- assert_equal 9, @boleto_novo.nosso_numero_dv
270
- @boleto_novo.numero_documento = "34230"
271
- assert_equal 0, @boleto_novo.nosso_numero_dv
272
- @boleto_novo.numero_documento = "258281"
273
- assert_equal 3, @boleto_novo.nosso_numero_dv
274
- end
275
-
276
- end
@@ -1,81 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoHsbc < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- def setup
6
- @boleto_novo = BancoHsbc.new(:data_documento => Date.parse("2008-02-01"))
7
- @boleto_novo.cedente = "Kivanio Barbosa"
8
- @boleto_novo.documento_cedente = "12345678912"
9
- @boleto_novo.sacado = "Claudio Pozzebom"
10
- @boleto_novo.sacado_documento = "12345678900"
11
- @boleto_novo.aceite = "S"
12
- @boleto_novo.agencia = "4042"
13
- @boleto_novo.valor = 2952.95
14
- end
15
-
16
- def boleto_carteira_cnr
17
- @boleto_novo.carteira = "CNR"
18
- @boleto_novo.agencia = "1234"
19
- @boleto_novo.conta_corrente = "0016324"
20
- @boleto_novo.numero_documento = "07778899"
21
- @boleto_novo.dias_vencimento = 0
22
- @boleto_novo.valor = 934.23
23
- @boleto_novo.data_documento = Date.parse("2004-09-03")
24
- end
25
-
26
- def test_should_initialize_correctly
27
- assert_equal '399', @boleto_novo.banco
28
- assert_equal "DM", @boleto_novo.especie_documento
29
- assert_equal "R$", @boleto_novo.especie
30
- assert_equal "9", @boleto_novo.moeda
31
- assert_equal Date.parse("2008-02-01"), @boleto_novo.data_documento
32
- assert_equal 1, @boleto_novo.dias_vencimento
33
- assert_equal((@boleto_novo.data_documento + 1), @boleto_novo.data_vencimento)
34
- assert_equal "S", @boleto_novo.aceite
35
- assert_equal 1, @boleto_novo.quantidade
36
- assert_equal 2952.95, @boleto_novo.valor
37
- assert_equal 2952.95, @boleto_novo.valor_documento
38
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
39
- end
40
-
41
- def test_should_return_correct_nosso_numero
42
- @boleto_novo.conta_corrente = "1122334"
43
- @boleto_novo.numero_documento = "12345678"
44
- @boleto_novo.dias_vencimento = 5
45
- @boleto_novo.data_documento = Date.parse("2000-07-04")
46
- assert_equal "12345678942", @boleto_novo.nosso_numero
47
- @boleto_novo.conta_corrente = "351202"
48
- @boleto_novo.numero_documento = "39104766"
49
- @boleto_novo.dias_vencimento = 0
50
- @boleto_novo.data_documento = Date.parse("2000-07-04")
51
- assert_equal "39104766340", @boleto_novo.nosso_numero
52
- @boleto_novo.conta_corrente = "351202"
53
- @boleto_novo.numero_documento = "39104766"
54
- @boleto_novo.dias_vencimento = 0
55
- @boleto_novo.data_documento = ""
56
- assert_equal "39104766354", @boleto_novo.nosso_numero
57
- end
58
-
59
- def test_should_mont_correct_codigo_barras
60
- @boleto_novo.conta_corrente = "1122334"
61
- @boleto_novo.numero_documento = "12345678"
62
- @boleto_novo.dias_vencimento = 5
63
- @boleto_novo.data_documento = Date.parse("2009-04-03")
64
- assert_equal "3999420100002952951122334000001234567809892", @boleto_novo.monta_codigo_43_digitos
65
- assert_equal "39998420100002952951122334000001234567809892", @boleto_novo.codigo_barras
66
- boleto_carteira_cnr
67
- assert_equal "3999252300000934230016324000000777889924742", @boleto_novo.monta_codigo_43_digitos
68
- assert_equal "39993252300000934230016324000000777889924742", @boleto_novo.codigo_barras
69
- end
70
-
71
- def test_should_mont_correct_linha_digitalvel
72
- @boleto_novo.conta_corrente = "1122334"
73
- @boleto_novo.numero_documento = "12345678"
74
- @boleto_novo.dias_vencimento = 5
75
- @boleto_novo.data_documento = Date.parse("2009-04-03")
76
- assert_equal("39991.12232 34000.001239 45678.098927 8 42010000295295", @boleto_novo.codigo_barras.linha_digitavel)
77
- boleto_carteira_cnr
78
- assert_equal("39990.01633 24000.000778 78899.247429 3 25230000093423", @boleto_novo.codigo_barras.linha_digitavel)
79
- end
80
-
81
- end
@@ -1,103 +0,0 @@
1
- require File.join(File.dirname(__FILE__),'test_helper.rb')
2
-
3
- class TestBancoItau < Test::Unit::TestCase #:nodoc:[all]
4
-
5
- BOLETO_ITAU_CARTEIRA_175 = {
6
- :carteira => "175",
7
- :moeda => "9",
8
- :valor => 135.00,
9
- :convenio => 0,
10
- :numero_documento => "12345678",
11
- :data_documento => Date.parse("2008-02-01"),
12
- :dias_vencimento => 0,
13
- :agencia => "0810",
14
- :conta_corrente => "53678"
15
- }
16
-
17
- def setup
18
- @boleto_novo = BancoItau.new # (BOLETO_CARTEIRA_175)
19
- BOLETO_ITAU_CARTEIRA_175.each do |nome, valor|
20
- @boleto_novo.send("#{nome}=".to_sym, valor)
21
- end
22
- end
23
-
24
- def test_should_initialize_correctly
25
- assert_equal '341', @boleto_novo.banco
26
- assert_equal "DM", @boleto_novo.especie_documento
27
- assert_equal "R$", @boleto_novo.especie
28
- assert_equal "9", @boleto_novo.moeda
29
- assert_equal Date.parse("2008-02-01"), @boleto_novo.data_documento
30
- assert_equal 0, @boleto_novo.dias_vencimento
31
- assert_equal((@boleto_novo.data_documento + 0), @boleto_novo.data_vencimento)
32
- assert_equal "S", @boleto_novo.aceite
33
- assert_equal 1, @boleto_novo.quantidade
34
- assert_equal 135.00, @boleto_novo.valor
35
- assert_equal 135.00, @boleto_novo.valor_documento
36
- assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
37
- end
38
-
39
- def test_should_return_correct_agencia_conta_corrente_dv
40
- @boleto_novo.agencia = "0607"
41
- @boleto_novo.conta_corrente = "15255"
42
- assert_equal 0, @boleto_novo.agencia_conta_corrente_dv
43
- @boleto_novo.agencia = "1547"
44
- @boleto_novo.conta_corrente = "85547"
45
- assert_equal 6, @boleto_novo.agencia_conta_corrente_dv
46
- @boleto_novo.agencia = "1547"
47
- @boleto_novo.conta_corrente = "10207"
48
- assert_equal 7, @boleto_novo.agencia_conta_corrente_dv
49
- @boleto_novo.agencia = "0811"
50
- @boleto_novo.conta_corrente = "53678"
51
- assert_equal 8, @boleto_novo.agencia_conta_corrente_dv
52
- end
53
-
54
- def test_should_verify_nosso_numero_dv_calculation
55
- @boleto_novo.numero_documento = "00015448"
56
- assert_equal 6, @boleto_novo.nosso_numero_dv
57
- @boleto_novo.numero_documento = "15448"
58
- assert_equal 6, @boleto_novo.nosso_numero_dv
59
- @boleto_novo.numero_documento = "12345678"
60
- assert_equal 4, @boleto_novo.nosso_numero_dv
61
- @boleto_novo.numero_documento = "34230"
62
- assert_equal 5, @boleto_novo.nosso_numero_dv
63
- @boleto_novo.numero_documento = "258281"
64
- assert_equal 7, @boleto_novo.nosso_numero_dv
65
- end
66
-
67
- def test_should_build_correct_barcode
68
- assert_equal "3419376900000135001751234567840810536789000", @boleto_novo.monta_codigo_43_digitos
69
- assert_equal "34195376900000135001751234567840810536789000", @boleto_novo.codigo_barras
70
-
71
- @boleto_novo.numero_documento = "258281"
72
- @boleto_novo.data_documento = Date.parse("2004/09/03")
73
- assert_equal "3419252300000135001750025828170810536789000", @boleto_novo.monta_codigo_43_digitos
74
- assert_equal "34195252300000135001750025828170810536789000", @boleto_novo.codigo_barras
75
-
76
- @boleto_novo.numero_documento = "258281"
77
- @boleto_novo.data_documento = Date.parse("2004/09/03")
78
- @boleto_novo.carteira = 168
79
- assert_equal "3419252300000135001680025828120810536789000", @boleto_novo.monta_codigo_43_digitos
80
- assert_equal "34193252300000135001680025828120810536789000", @boleto_novo.codigo_barras
81
-
82
- @boleto_novo.carteira = 196
83
- @boleto_novo.convenio = "12345"
84
- @boleto_novo.seu_numero = "1234567"
85
- assert_equal "3419252300000135001960025828112345671234550", @boleto_novo.monta_codigo_43_digitos
86
- assert_equal "34199252300000135001960025828112345671234550", @boleto_novo.codigo_barras
87
- @boleto_novo.seu_numero = "123456"
88
- assert_equal "3419252300000135001960025828101234561234550", @boleto_novo.monta_codigo_43_digitos
89
- assert_equal "34191252300000135001960025828101234561234550", @boleto_novo.codigo_barras
90
-
91
- @boleto_novo.convenio = "1234"
92
- assert_equal "3419252300000135001960025828101234560123440", @boleto_novo.monta_codigo_43_digitos
93
- assert_equal "34191252300000135001960025828101234560123440", @boleto_novo.codigo_barras
94
- end
95
-
96
- def test_should_build_correct_typeable_line
97
- assert_equal "34191.75124 34567.840813 05367.890000 5 37690000013500", @boleto_novo.codigo_barras.linha_digitavel
98
- @boleto_novo.numero_documento = "258281"
99
- @boleto_novo.data_documento = Date.parse("2004/09/03")
100
- assert_equal "34191.75009 25828.170818 05367.890000 5 25230000013500", @boleto_novo.codigo_barras.linha_digitavel
101
- end
102
-
103
- end