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.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.markdown +54 -2
  3. data/README.markdown +660 -189
  4. data/lib/boleto_bancario/calculos/documento.rb +191 -0
  5. data/lib/boleto_bancario/calculos/fator_vencimento.rb +78 -31
  6. data/lib/boleto_bancario/core/boleto.rb +30 -1
  7. data/lib/boleto_bancario/core/c6_bank.rb +155 -0
  8. data/lib/boleto_bancario/core/inter.rb +155 -0
  9. data/lib/boleto_bancario/core/nubank.rb +156 -0
  10. data/lib/boleto_bancario/locales/pt-BR.yml +55 -0
  11. data/lib/boleto_bancario/renderers/base.rb +154 -0
  12. data/lib/boleto_bancario/renderers/html_renderer.rb +92 -0
  13. data/lib/boleto_bancario/renderers/pdf_renderer.rb +130 -0
  14. data/lib/boleto_bancario/renderers/png_renderer.rb +66 -0
  15. data/lib/boleto_bancario/templates/_barcode.html.erb +3 -0
  16. data/lib/boleto_bancario/templates/_cedente.html.erb +14 -0
  17. data/lib/boleto_bancario/templates/_header.html.erb +4 -0
  18. data/lib/boleto_bancario/templates/_instructions.html.erb +10 -0
  19. data/lib/boleto_bancario/templates/_payment.html.erb +36 -0
  20. data/lib/boleto_bancario/templates/_sacado.html.erb +10 -0
  21. data/lib/boleto_bancario/templates/boleto.html.erb +22 -0
  22. data/lib/boleto_bancario/templates/boleto_styles.css +18 -0
  23. data/lib/boleto_bancario/version.rb +3 -1
  24. data/lib/boleto_bancario.rb +23 -6
  25. data/lib/generators/boleto_bancario/views_generator.rb +47 -0
  26. metadata +91 -129
  27. data/.gitignore +0 -19
  28. data/.rspec +0 -1
  29. data/.travis.yml +0 -10
  30. data/Gemfile +0 -3
  31. data/Planning.markdown +0 -63
  32. data/Rakefile +0 -15
  33. data/TODO.markdown +0 -19
  34. data/boleto_bancario.gemspec +0 -29
  35. data/documentacoes_dos_boletos/Bradesco/Manual_BRADESCO.PDF +0 -0
  36. data/lib/boleto_bancario/core/hsbc.rb +0 -170
  37. data/lib/boleto_bancario/core/real.rb +0 -177
  38. data/spec/boleto_bancario/calculos/digitos_spec.rb +0 -19
  39. data/spec/boleto_bancario/calculos/fator_vencimento_spec.rb +0 -59
  40. data/spec/boleto_bancario/calculos/fatores_de_multiplicacao_spec.rb +0 -69
  41. data/spec/boleto_bancario/calculos/linha_digitavel_spec.rb +0 -57
  42. data/spec/boleto_bancario/calculos/modulo10_spec.rb +0 -53
  43. data/spec/boleto_bancario/calculos/modulo11_fator_de2a7_spec.rb +0 -43
  44. data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_resto_zero_spec.rb +0 -39
  45. data/spec/boleto_bancario/calculos/modulo11_fator_de2a9_spec.rb +0 -67
  46. data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_resto_x_spec.rb +0 -37
  47. data/spec/boleto_bancario/calculos/modulo11_fator_de9a2_spec.rb +0 -31
  48. data/spec/boleto_bancario/calculos/modulo11_spec.rb +0 -19
  49. data/spec/boleto_bancario/calculos/modulo_numero_de_controle_spec.rb +0 -37
  50. data/spec/boleto_bancario/core/banco_brasil_spec.rb +0 -377
  51. data/spec/boleto_bancario/core/banrisul_spec.rb +0 -129
  52. data/spec/boleto_bancario/core/boleto_spec.rb +0 -218
  53. data/spec/boleto_bancario/core/bradesco_spec.rb +0 -163
  54. data/spec/boleto_bancario/core/caixa_spec.rb +0 -111
  55. data/spec/boleto_bancario/core/hsbc_spec.rb +0 -72
  56. data/spec/boleto_bancario/core/itau_spec.rb +0 -333
  57. data/spec/boleto_bancario/core/real_spec.rb +0 -104
  58. data/spec/boleto_bancario/core/santander_spec.rb +0 -137
  59. data/spec/boleto_bancario/core/sicoob_spec.rb +0 -111
  60. data/spec/boleto_bancario/core/sicredi_spec.rb +0 -149
  61. data/spec/inheritance/banco_brasil_spec.rb +0 -22
  62. data/spec/inheritance/banrisul_spec.rb +0 -22
  63. data/spec/inheritance/boleto_spec.rb +0 -15
  64. data/spec/inheritance/bradesco_spec.rb +0 -22
  65. data/spec/inheritance/caixa_spec.rb +0 -22
  66. data/spec/inheritance/hsbc_spec.rb +0 -22
  67. data/spec/inheritance/itau_spec.rb +0 -22
  68. data/spec/inheritance/real_spec.rb +0 -22
  69. data/spec/inheritance/santander_spec.rb +0 -22
  70. data/spec/inheritance/sicoob_spec.rb +0 -22
  71. data/spec/inheritance/sicredi_spec.rb +0 -22
  72. data/spec/shared_examples/boleto_bancario_shared_example.rb +0 -151
  73. data/spec/spec_helper.rb +0 -14
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo10 do
6
- it "should accept the examples by the 'Itau documentation'" do
7
- Modulo10.new('341911012').should eq '1'
8
- Modulo10.new('3456788005').should eq '8'
9
- Modulo10.new('7123457000').should eq '1'
10
- end
11
-
12
- it "should accept the example from Banrisul" do
13
- Modulo10.new('00009274').should eq '2'
14
- end
15
-
16
- it "returns zero when number is 0" do
17
- Modulo10.new('0').should eq '0'
18
- end
19
-
20
- it "returns zero when mod 10 is zero" do
21
- Modulo10.new('99906').should eq '0'
22
- end
23
-
24
- it "calculate when number had 1 digit" do
25
- Modulo10.new('1').should eq '8'
26
- end
27
-
28
- it "calculate when number had 2 digits" do
29
- Modulo10.new('10').should eq '9'
30
- end
31
-
32
- it "calculate when number had 3 digits" do
33
- Modulo10.new('994').should eq '4'
34
- end
35
-
36
- it "calculate when number had 5 digits" do
37
- Modulo10.new('97831').should eq '2'
38
- end
39
-
40
- it "calculate when number had 6 digits" do
41
- Modulo10.new('147966').should eq '6'
42
- end
43
-
44
- it "calculate when number had 10 digits" do
45
- Modulo10.new('3456788005').should eq '8'
46
- end
47
-
48
- it "should accept numbers too" do
49
- Modulo10.new(12345).should eq '5'
50
- end
51
- end
52
- end
53
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11FatorDe2a7 do
6
- context 'with Bradesco documentation example' do
7
- subject { Modulo11FatorDe2a7.new('1900000000002') }
8
-
9
- it { should eq '8' }
10
- end
11
-
12
- context 'with Bradesco example that returns P' do
13
- subject { Modulo11FatorDe2a7.new('1900000000001') }
14
-
15
- it { should eq 'P' }
16
- end
17
-
18
- context 'with Bradesco example that returns zero' do
19
- subject { Modulo11FatorDe2a7.new('1900000000006') }
20
-
21
- it { should eq '0' }
22
- end
23
-
24
- context "when have two digits" do
25
- subject { Modulo11FatorDe2a7.new('20') }
26
-
27
- it { should eq '5' }
28
- end
29
-
30
- context "when have two digits (more examples)" do
31
- subject { Modulo11FatorDe2a7.new('26') }
32
-
33
- it { should eq '4' }
34
- end
35
-
36
- context "more examples" do
37
- subject { Modulo11FatorDe2a7.new('64') }
38
-
39
- it { should eq '7' }
40
- end
41
- end
42
- end
43
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11FatorDe2a9RestoZero do
6
- describe "#calculate" do
7
- context "with a one number digit" do
8
- subject { Modulo11FatorDe2a9RestoZero.new(6) }
9
-
10
- it { should eq '0' }
11
- end
12
-
13
- context "with a two number digit" do
14
- subject { Modulo11FatorDe2a9RestoZero.new(100) }
15
-
16
- it { should eq '7' }
17
- end
18
-
19
- context "with a three number digit" do
20
- subject { Modulo11FatorDe2a9RestoZero.new(1004) }
21
-
22
- it { should eq '9' }
23
- end
24
-
25
- context "with a three number digit that returns zero" do
26
- subject { Modulo11FatorDe2a9RestoZero.new(1088) }
27
-
28
- it { should eq '0' }
29
- end
30
-
31
- context "when mod division return '10'" do
32
- subject { Modulo11FatorDe2a9RestoZero.new(1073) }
33
-
34
- it { should eq '1' }
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11FatorDe2a9 do
6
- context 'with Itau example' do
7
- subject { Modulo11FatorDe2a9.new('3419166700000123451101234567880057123457000') }
8
-
9
- it { should eq '6' }
10
- end
11
-
12
- context 'with Bradesco example' do
13
- subject { Modulo11FatorDe2a9.new('9999101200000350007772130530150081897500000') }
14
-
15
- it { should eq '1' }
16
- end
17
-
18
- context 'with Banco Brasil example' do
19
- subject { Modulo11FatorDe2a9.new('0019373700000001000500940144816060680935031') }
20
-
21
- it { should eq '3' }
22
- end
23
-
24
- context 'with Caixa example' do
25
- subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901200200') }
26
-
27
- it { should eq '1' }
28
- end
29
-
30
- context 'with Banrisul example' do
31
- subject { Modulo11FatorDe2a9.new('0419100100000550002110000000012283256304168') }
32
-
33
- it { should eq '1' }
34
- end
35
-
36
- context 'when calculations returns 11' do
37
- subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901200298') }
38
-
39
- it { should eq '1' }
40
- end
41
-
42
- context 'when calculations returns 1' do
43
- subject { Modulo11FatorDe2a9.new('1049107400000160000001100128701000901244437') }
44
-
45
- it { should eq '1' }
46
- end
47
-
48
- context 'with one digit' do
49
- subject { Modulo11FatorDe2a9.new('1') }
50
-
51
- it { should eq '9' }
52
- end
53
-
54
- context 'with two digits' do
55
- subject { Modulo11FatorDe2a9.new('91') }
56
-
57
- it { should eq '4' }
58
- end
59
-
60
- context 'with three digits' do
61
- subject { Modulo11FatorDe2a9.new('189') }
62
-
63
- it { should eq '9' }
64
- end
65
- end
66
- end
67
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11FatorDe9a2RestoX do
6
- context "when the mod result is 10 (ten)" do
7
- subject { Modulo11FatorDe9a2RestoX.new('3973') }
8
-
9
- it { should eq 'X' }
10
- end
11
-
12
- context "when the mod result is zero" do
13
- subject { Modulo11FatorDe9a2RestoX.new('3995') }
14
-
15
- it { should eq '0' }
16
- end
17
-
18
- context "using the 'Banco Brasil' documentation example" do
19
- subject { Modulo11FatorDe9a2RestoX.new('01129004590') }
20
-
21
- it { should eq '3' }
22
- end
23
-
24
- context "when the result is one" do
25
- subject { Modulo11FatorDe9a2RestoX.new('5964') }
26
-
27
- it { should eq '1' }
28
- end
29
-
30
- context "with a five digit number" do
31
- subject { Modulo11FatorDe9a2RestoX.new('10949') }
32
-
33
- it { should eq '5' }
34
- end
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11FatorDe9a2 do
6
- context "when the mod result is 10 (ten)" do
7
- subject { Modulo11FatorDe9a2.new('3973') }
8
-
9
- it { should eq '10' }
10
- end
11
-
12
- context "when the mod result is zero" do
13
- subject { Modulo11FatorDe9a2.new('3995') }
14
-
15
- it { should eq '0' }
16
- end
17
-
18
- context "when the result is one" do
19
- subject { Modulo11FatorDe9a2.new('5964') }
20
-
21
- it { should eq '1' }
22
- end
23
-
24
- context "with a five digit number" do
25
- subject { Modulo11FatorDe9a2.new('10949') }
26
-
27
- it { should eq '5' }
28
- end
29
- end
30
- end
31
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe Modulo11 do
6
- subject { Modulo11.new(1) }
7
-
8
- describe "#fatores" do
9
- before { Modulo11.any_instance.stub(:calculate).and_return(1) }
10
-
11
- it { expect { subject.fatores }.to raise_error(NotImplementedError, "Not implemented #fatores in subclass.") }
12
- end
13
-
14
- describe "#calculate" do
15
- it { expect { Modulo11.new(1) }.to raise_error(NotImplementedError, "Not implemented #calculate in subclass.") }
16
- end
17
- end
18
- end
19
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module BoletoBancario
4
- module Calculos
5
- describe ModuloNumeroDeControle do
6
- context "when is simple calculation" do
7
- subject { ModuloNumeroDeControle.new('00009274') }
8
-
9
- it { should eq '22' }
10
- end
11
-
12
- context "another example" do
13
- subject { ModuloNumeroDeControle.new('0000001') }
14
-
15
- it { should eq '83' }
16
- end
17
-
18
- context "example with second digit invalid" do
19
- subject { ModuloNumeroDeControle.new('00009194') }
20
-
21
- it { should eq '38' }
22
- end
23
-
24
- context "example with second digit invalid and first digit with '9'" do
25
- subject { ModuloNumeroDeControle.new('411') }
26
-
27
- it { should eq '06' }
28
- end
29
-
30
- context 'should calculate when the first digit is not 10 (ten)' do
31
- subject { ModuloNumeroDeControle.new('5') }
32
-
33
- it { should eq '90' }
34
- end
35
- end
36
- end
37
- end