kivanio-brcobranca 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +48 -0
  3. data/README.rdoc +72 -0
  4. data/Rakefile +32 -0
  5. data/brcobranca.gemspec +47 -0
  6. data/lib/brcobranca/arquivos/logos/bb.jpg +0 -0
  7. data/lib/brcobranca/arquivos/logos/bradesco.jpg +0 -0
  8. data/lib/brcobranca/arquivos/logos/hsbc.jpg +0 -0
  9. data/lib/brcobranca/arquivos/logos/itau.jpg +0 -0
  10. data/lib/brcobranca/arquivos/logos/real.jpg +0 -0
  11. data/lib/brcobranca/arquivos/logos/unibanco.jpg +0 -0
  12. data/lib/brcobranca/arquivos/templates/modelo_generico.eps +0 -0
  13. data/lib/brcobranca/boleto/banco_bradesco.rb +31 -0
  14. data/lib/brcobranca/boleto/banco_brasil.rb +79 -0
  15. data/lib/brcobranca/boleto/banco_hsbc.rb +63 -0
  16. data/lib/brcobranca/boleto/banco_itau.rb +105 -0
  17. data/lib/brcobranca/boleto/banco_real.rb +56 -0
  18. data/lib/brcobranca/boleto/banco_unibanco.rb +65 -0
  19. data/lib/brcobranca/boleto/base.rb +148 -0
  20. data/lib/brcobranca/boleto/template/rghost.rb +151 -0
  21. data/lib/brcobranca/boleto/template/util.rb +30 -0
  22. data/lib/brcobranca/config.rb +9 -0
  23. data/lib/brcobranca/core_ext.rb +269 -0
  24. data/lib/brcobranca/currency.rb +70 -0
  25. data/lib/brcobranca/retorno/base.rb +43 -0
  26. data/lib/brcobranca/retorno/retorno_cbr643.rb +44 -0
  27. data/lib/brcobranca.rb +27 -0
  28. data/script/console +10 -0
  29. data/script/destroy +14 -0
  30. data/script/generate +14 -0
  31. data/script/txt2html +71 -0
  32. data/test/arquivos/CBR64310.RET +28 -0
  33. data/test/test_banco_bradesco.rb +87 -0
  34. data/test/test_banco_brasil.rb +276 -0
  35. data/test/test_banco_hsbc.rb +81 -0
  36. data/test/test_banco_itau.rb +103 -0
  37. data/test/test_banco_real.rb +112 -0
  38. data/test/test_banco_unibanco.rb +92 -0
  39. data/test/test_base.rb +162 -0
  40. data/test/test_core_ext.rb +227 -0
  41. data/test/test_currency.rb +51 -0
  42. data/test/test_helper.rb +5 -0
  43. data/test/test_retorno_cbr643.rb +66 -0
  44. data/website/index.html +89 -0
  45. data/website/index.txt +46 -0
  46. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  47. data/website/stylesheets/screen.css +159 -0
  48. data/website/template.html.erb +57 -0
  49. metadata +164 -0
@@ -0,0 +1,81 @@
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
@@ -0,0 +1,103 @@
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
@@ -0,0 +1,112 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class TestBancoReal < Test::Unit::TestCase #:nodoc:[all]
4
+
5
+ def setup
6
+ @boleto_novo = BancoReal.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_carteira_registrada
17
+ @boleto_novo.banco = "356"
18
+ @boleto_novo.agencia = "4042"
19
+ @boleto_novo.conta_corrente = "61900"
20
+ @boleto_novo.carteira = "56"
21
+ @boleto_novo.moeda = "9"
22
+ @boleto_novo.valor = 135.00
23
+ @boleto_novo.numero_documento = "7701684"
24
+ @boleto_novo.data_documento = Date.parse("2008-02-01")
25
+ @boleto_novo.dias_vencimento = 0
26
+ end
27
+
28
+ def boleto_carteira_sem_registro
29
+ @boleto_novo.banco = "356"
30
+ @boleto_novo.agencia = "4042"
31
+ @boleto_novo.conta_corrente = "61900"
32
+ @boleto_novo.carteira = "57"
33
+ @boleto_novo.moeda = "9"
34
+ @boleto_novo.valor = 135.00
35
+ @boleto_novo.numero_documento = "777700168"
36
+ @boleto_novo.data_documento = Date.parse("2008-02-01")
37
+ @boleto_novo.dias_vencimento = 1
38
+ end
39
+
40
+ def boleto_carteira_sem_registro_2
41
+ @boleto_novo.banco = "356"
42
+ @boleto_novo.agencia = "1018"
43
+ @boleto_novo.conta_corrente = "0016324"
44
+ @boleto_novo.carteira = "57"
45
+ @boleto_novo.moeda = "9"
46
+ @boleto_novo.valor = 934.23
47
+ @boleto_novo.numero_documento = "00005020"
48
+ @boleto_novo.data_documento = Date.parse("2004-09-03")
49
+ @boleto_novo.dias_vencimento = 0
50
+ end
51
+
52
+ def boleto_nil
53
+ @boleto_novo.banco = ""
54
+ @boleto_novo.carteira = ""
55
+ @boleto_novo.moeda = ""
56
+ @boleto_novo.valor = 0
57
+ @boleto_novo.convenio = ""
58
+ @boleto_novo.numero_documento = ""
59
+ @boleto_novo.data_documento = Date.parse("2008-02-01")
60
+ @boleto_novo.dias_vencimento = 0
61
+ end
62
+
63
+ def test_should_initialize_correctly
64
+ assert_equal '356', @boleto_novo.banco
65
+ assert_equal '57', @boleto_novo.carteira
66
+ assert_equal "DM", @boleto_novo.especie_documento
67
+ assert_equal "R$", @boleto_novo.especie
68
+ assert_equal "9", @boleto_novo.moeda
69
+ assert_equal Date.today, @boleto_novo.data_documento
70
+ assert_equal 1, @boleto_novo.dias_vencimento
71
+ assert_equal((Date.today + 1), @boleto_novo.data_vencimento)
72
+ assert_equal "S", @boleto_novo.aceite
73
+ assert_equal 1, @boleto_novo.quantidade
74
+ assert_equal 0.0, @boleto_novo.valor
75
+ assert_equal 0.0, @boleto_novo.valor_documento
76
+ assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto_novo.local_pagamento
77
+ end
78
+
79
+ def test_should_mont_correct_codigo_barras
80
+ boleto_carteira_sem_registro
81
+ assert_equal "3569377000000135004042006190030000777700168", @boleto_novo.monta_codigo_43_digitos
82
+ assert_equal "35692377000000135004042006190030000777700168", @boleto_novo.codigo_barras
83
+ boleto_carteira_sem_registro_2
84
+ assert_equal "3569252300000934231018001632490000000005020", @boleto_novo.monta_codigo_43_digitos
85
+ assert_equal "35697252300000934231018001632490000000005020", @boleto_novo.codigo_barras
86
+ boleto_carteira_registrada
87
+ assert_equal "3569376900000135000000004042006190087701684", @boleto_novo.monta_codigo_43_digitos
88
+ assert_equal "35691376900000135000000004042006190087701684", @boleto_novo.codigo_barras
89
+ boleto_nil
90
+ assert_equal nil, @boleto_novo.codigo_barras
91
+ assert_raise RuntimeError do
92
+ boleto_nil
93
+ raise 'Verifique as informações do boleto!!!'
94
+ end
95
+ end
96
+
97
+ def test_should_mont_correct_linha_digitalvel
98
+ boleto_carteira_registrada
99
+ assert_equal("35690.00007 04042.006199 00877.016840 1 37690000013500", @boleto_novo.codigo_barras.linha_digitavel)
100
+ boleto_carteira_sem_registro
101
+ assert_equal("35694.04209 06190.030004 07777.001681 2 37700000013500", @boleto_novo.codigo_barras.linha_digitavel)
102
+ boleto_carteira_sem_registro_2
103
+ assert_equal("35691.01805 01632.490007 00000.050203 7 25230000093423", @boleto_novo.codigo_barras.linha_digitavel)
104
+ end
105
+
106
+ def test_should_return_agencia_conta_corrente_nosso_numero_dv
107
+ boleto_carteira_registrada
108
+ assert_equal 8, @boleto_novo.agencia_conta_corrente_nosso_numero_dv
109
+ boleto_carteira_sem_registro
110
+ assert_equal 3, @boleto_novo.agencia_conta_corrente_nosso_numero_dv
111
+ end
112
+ end
@@ -0,0 +1,92 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class TestBancoUnibanco < Test::Unit::TestCase #:nodoc:[all]
4
+
5
+ def setup
6
+ @boleto_novo = BancoUnibanco.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_com_registro
17
+ @boleto_novo.agencia = "0123"
18
+ @boleto_novo.conta_corrente = "100618"
19
+ @boleto_novo.carteira = "4"
20
+ @boleto_novo.convenio = 2031671
21
+ @boleto_novo.valor = 2952.95
22
+ @boleto_novo.numero_documento = "1803029901"
23
+ @boleto_novo.data_documento = Date.parse("2009-04-30")
24
+ @boleto_novo.dias_vencimento = 0
25
+ end
26
+
27
+ def boleto_sem_registro
28
+ @boleto_novo.agencia = "0123"
29
+ @boleto_novo.conta_corrente = "100618"
30
+ @boleto_novo.carteira = "5"
31
+ @boleto_novo.convenio = 2031671
32
+ @boleto_novo.valor = 2952.95
33
+ @boleto_novo.numero_documento = "1803029901"
34
+ @boleto_novo.data_documento = Date.parse("2009-04-30")
35
+ @boleto_novo.dias_vencimento = 0
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 '409', @boleto_novo.banco
51
+ assert_equal '5', @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 return_correct_nosso_numero_dv
66
+ @boleto_novo.numero_documento = "00001803029901"
67
+ assert_equal "5", @boleto_novo.nosso_numero_dv
68
+ end
69
+
70
+ def test_should_mont_correct_codigo_barras
71
+ boleto_sem_registro
72
+ assert_equal "4099422300002952955203167100000018030299015", @boleto_novo.monta_codigo_43_digitos
73
+ assert_equal "40995422300002952955203167100000018030299015", @boleto_novo.codigo_barras
74
+ boleto_com_registro
75
+ assert_equal "4099422300002952950409043001236018030299015", @boleto_novo.monta_codigo_43_digitos
76
+ assert_equal "40997422300002952950409043001236018030299015", @boleto_novo.codigo_barras
77
+ boleto_nil
78
+ assert_equal nil, @boleto_novo.codigo_barras
79
+ assert_raise RuntimeError do
80
+ boleto_nil
81
+ raise 'Verifique as informações do boleto!!!'
82
+ end
83
+ end
84
+
85
+ def test_should_mont_correct_linha_digitalvel
86
+ boleto_sem_registro
87
+ assert_equal("40995.20316 67100.000016 80302.990157 5 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
88
+ boleto_com_registro
89
+ assert_equal("40990.40901 43001.236017 80302.990157 7 42230000295295", @boleto_novo.codigo_barras.linha_digitavel)
90
+ end
91
+
92
+ end
data/test/test_base.rb ADDED
@@ -0,0 +1,162 @@
1
+ require File.join(File.dirname(__FILE__),'test_helper.rb')
2
+
3
+ class TestBase < Test::Unit::TestCase #:nodoc:[all]
4
+
5
+ def setup
6
+ @boleto = Brcobranca::Boleto::Base.new
7
+ end
8
+
9
+ def test_should_initialize_correctly
10
+ assert_equal "DM", @boleto.especie_documento
11
+ assert_equal "R$", @boleto.especie
12
+ assert_equal "9", @boleto.moeda
13
+ assert_equal Date.today, @boleto.data_documento
14
+ assert_equal 1, @boleto.dias_vencimento
15
+ assert_equal((Date.today + 1), @boleto.data_vencimento)
16
+ assert_equal "S", @boleto.aceite
17
+ assert_equal 1, @boleto.quantidade
18
+ assert_equal 0.0, @boleto.valor
19
+ assert_equal 0.0, @boleto.valor_documento
20
+ assert_equal "QUALQUER BANCO ATÉ O VENCIMENTO", @boleto.local_pagamento
21
+ end
22
+
23
+ def test_should_calculate_correct_banco_dv
24
+ @boleto.banco = "85068014982"
25
+ assert_equal 9, @boleto.banco_dv
26
+ @boleto.banco = "05009401448"
27
+ assert_equal 1, @boleto.banco_dv
28
+ @boleto.banco = "12387987777700168"
29
+ assert_equal 2, @boleto.banco_dv
30
+ @boleto.banco = "4042"
31
+ assert_equal 8, @boleto.banco_dv
32
+ @boleto.banco = "61900"
33
+ assert_equal 0, @boleto.banco_dv
34
+ @boleto.banco = "0719"
35
+ assert_equal 6, @boleto.banco_dv
36
+ @boleto.banco = 85068014982
37
+ assert_equal 9, @boleto.banco_dv
38
+ @boleto.banco = 5009401448
39
+ assert_equal 1, @boleto.banco_dv
40
+ @boleto.banco = 12387987777700168
41
+ assert_equal 2, @boleto.banco_dv
42
+ @boleto.banco = 4042
43
+ assert_equal 8, @boleto.banco_dv
44
+ @boleto.banco = 61900
45
+ assert_equal 0, @boleto.banco_dv
46
+ @boleto.banco = 719
47
+ assert_equal 6, @boleto.banco_dv
48
+ end
49
+
50
+ def test_should_calculate_correct_agencia_dv
51
+ @boleto.agencia = "85068014982"
52
+ assert_equal 9, @boleto.agencia_dv
53
+ @boleto.agencia = "05009401448"
54
+ assert_equal 1, @boleto.agencia_dv
55
+ @boleto.agencia = "12387987777700168"
56
+ assert_equal 2, @boleto.agencia_dv
57
+ @boleto.agencia = "4042"
58
+ assert_equal 8, @boleto.agencia_dv
59
+ @boleto.agencia = "61900"
60
+ assert_equal 0, @boleto.agencia_dv
61
+ @boleto.agencia = "0719"
62
+ assert_equal 6, @boleto.agencia_dv
63
+ @boleto.agencia = 85068014982
64
+ assert_equal 9, @boleto.agencia_dv
65
+ @boleto.agencia = 5009401448
66
+ assert_equal 1, @boleto.agencia_dv
67
+ @boleto.agencia = 12387987777700168
68
+ assert_equal 2, @boleto.agencia_dv
69
+ @boleto.agencia = 4042
70
+ assert_equal 8, @boleto.agencia_dv
71
+ @boleto.agencia = 61900
72
+ assert_equal 0, @boleto.agencia_dv
73
+ @boleto.agencia = 719
74
+ assert_equal 6, @boleto.agencia_dv
75
+ end
76
+
77
+ def test_should_calculate_correct_conta_corrente_dv
78
+ @boleto.conta_corrente = "85068014982"
79
+ assert_equal 9, @boleto.conta_corrente_dv
80
+ @boleto.conta_corrente = "05009401448"
81
+ assert_equal 1, @boleto.conta_corrente_dv
82
+ @boleto.conta_corrente = "12387987777700168"
83
+ assert_equal 2, @boleto.conta_corrente_dv
84
+ @boleto.conta_corrente = "4042"
85
+ assert_equal 8, @boleto.conta_corrente_dv
86
+ @boleto.conta_corrente = "61900"
87
+ assert_equal 0, @boleto.conta_corrente_dv
88
+ @boleto.conta_corrente = "0719"
89
+ assert_equal 6, @boleto.conta_corrente_dv
90
+ @boleto.conta_corrente = 85068014982
91
+ assert_equal 9, @boleto.conta_corrente_dv
92
+ @boleto.conta_corrente = 5009401448
93
+ assert_equal 1, @boleto.conta_corrente_dv
94
+ @boleto.conta_corrente = 12387987777700168
95
+ assert_equal 2, @boleto.conta_corrente_dv
96
+ @boleto.conta_corrente = 4042
97
+ assert_equal 8, @boleto.conta_corrente_dv
98
+ @boleto.conta_corrente = 61900
99
+ assert_equal 0, @boleto.conta_corrente_dv
100
+ @boleto.conta_corrente = 719
101
+ assert_equal 6, @boleto.conta_corrente_dv
102
+ end
103
+
104
+ def test_should_calculate_correct_nosso_numero_dv
105
+ @boleto.numero_documento = "85068014982"
106
+ assert_equal 9, @boleto.nosso_numero_dv
107
+ @boleto.numero_documento = "05009401448"
108
+ assert_equal 1, @boleto.nosso_numero_dv
109
+ @boleto.numero_documento = "12387987777700168"
110
+ assert_equal 2, @boleto.nosso_numero_dv
111
+ @boleto.numero_documento = "4042"
112
+ assert_equal 8, @boleto.nosso_numero_dv
113
+ @boleto.numero_documento = "61900"
114
+ assert_equal 0, @boleto.nosso_numero_dv
115
+ @boleto.numero_documento = "0719"
116
+ assert_equal 6, @boleto.nosso_numero_dv
117
+ @boleto.numero_documento = 85068014982
118
+ assert_equal 9, @boleto.nosso_numero_dv
119
+ @boleto.numero_documento = 5009401448
120
+ assert_equal 1, @boleto.nosso_numero_dv
121
+ @boleto.numero_documento = 12387987777700168
122
+ assert_equal 2, @boleto.nosso_numero_dv
123
+ @boleto.numero_documento = 4042
124
+ assert_equal 8, @boleto.nosso_numero_dv
125
+ @boleto.numero_documento = 61900
126
+ assert_equal 0, @boleto.nosso_numero_dv
127
+ @boleto.numero_documento = 719
128
+ assert_equal 6, @boleto.nosso_numero_dv
129
+ end
130
+
131
+ def test_should_return_correct_valor_documento
132
+ @boleto.quantidade = 1
133
+ @boleto.valor = 1
134
+ assert_equal 1, @boleto.valor_documento
135
+ @boleto.quantidade = 1
136
+ @boleto.valor = 1.0
137
+ assert_equal 1.0, @boleto.valor_documento
138
+ @boleto.quantidade = 1
139
+ @boleto.valor = 1.2
140
+ assert_equal 1.2, @boleto.valor_documento
141
+ @boleto.quantidade = 100
142
+ @boleto.valor = 1
143
+ assert_equal 100, @boleto.valor_documento
144
+ @boleto.quantidade = 1
145
+ @boleto.valor = 135.43
146
+ assert_equal 135.43, @boleto.valor_documento
147
+ end
148
+
149
+ def test_should_return_correct_data_vencimento
150
+ @boleto.data_documento = Date.parse "2008-02-01"
151
+ @boleto.dias_vencimento = 1
152
+ assert_equal "2008-02-02", @boleto.data_vencimento.to_s
153
+ @boleto.data_documento = Date.parse "2008-02-02"
154
+ @boleto.dias_vencimento = 28
155
+ assert_equal "2008-03-01", @boleto.data_vencimento.to_s
156
+ @boleto.data_documento = Date.parse "2008-02-06"
157
+ @boleto.dias_vencimento = 100
158
+ assert_equal "2008-05-16", @boleto.data_vencimento.to_s
159
+ assert_equal Date.parse("2008-05-16"), @boleto.data_vencimento
160
+ end
161
+
162
+ end