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,149 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
module BoletoBancario
|
|
5
|
-
module Core
|
|
6
|
-
describe Sicredi 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', '12345') }
|
|
14
|
-
it { should_not have_valid(:conta_corrente).when('123456', '1234567', nil, '') }
|
|
15
|
-
|
|
16
|
-
it { should have_valid(:numero_documento).when('1', '12', '123', '12345') }
|
|
17
|
-
it { should_not have_valid(:numero_documento).when('123456', nil, '') }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('03', 'C') }
|
|
20
|
-
it { should_not have_valid(:carteira).when(nil, '', '05', '20', '100', '120') }
|
|
21
|
-
|
|
22
|
-
it { should have_valid(:posto).when('1', '56', 34, 99) }
|
|
23
|
-
it { should_not have_valid(:posto).when(nil, '', '100', 100) }
|
|
24
|
-
|
|
25
|
-
it { should have_valid(:byte_id).when('2', 2, 5, '9') }
|
|
26
|
-
it { should_not have_valid(:byte_id).when(nil, '', '1', 1, 10, '100') }
|
|
27
|
-
|
|
28
|
-
it { should have_valid(:valor_documento).when(1, 1.99, 100.99, 99_999_999.99, '100.99') }
|
|
29
|
-
it { should_not have_valid(:valor_documento).when(nil, '', '100,99', 100_000_000.99) }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "#agencia" do
|
|
33
|
-
context "when have a value" do
|
|
34
|
-
subject { Sicredi.new(agencia: '530') }
|
|
35
|
-
|
|
36
|
-
it { expect(subject.agencia).to eq '0530' }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context "when is nil" do
|
|
40
|
-
it { expect(subject.agencia).to be nil }
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe "#conta_corrente" do
|
|
45
|
-
context "when have a value" do
|
|
46
|
-
subject { Sicredi.new(conta_corrente: '96') }
|
|
47
|
-
|
|
48
|
-
it { expect(subject.conta_corrente).to eq '00096' }
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context "when is nil" do
|
|
52
|
-
it { expect(subject.conta_corrente).to be nil }
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
describe "#numero_documento" do
|
|
57
|
-
context "when have a value" do
|
|
58
|
-
subject { Sicredi.new(numero_documento: '1') }
|
|
59
|
-
|
|
60
|
-
it { expect(subject.numero_documento).to eq '00001' }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "when is nil" do
|
|
64
|
-
it { expect(subject.numero_documento).to be nil }
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
describe "#carteira" do
|
|
69
|
-
context "when have a value" do
|
|
70
|
-
subject { Sicredi.new(carteira: '03') }
|
|
71
|
-
|
|
72
|
-
it { expect(subject.carteira).to eq '03' }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context "when is nil" do
|
|
76
|
-
it { expect(subject.carteira).to be nil }
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe "#carteira_formatada" do
|
|
81
|
-
context "when is registered" do
|
|
82
|
-
subject { Sicredi.new(carteira: '03') }
|
|
83
|
-
|
|
84
|
-
it { expect(subject.carteira_formatada).to eq '1' }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
context "when isn't registered" do
|
|
88
|
-
subject { Sicredi.new(carteira: 'C') }
|
|
89
|
-
|
|
90
|
-
it { expect(subject.carteira_formatada).to eq '1' }
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe "#codigo_banco" do
|
|
95
|
-
it { expect(subject.codigo_banco).to eq '748' }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe "#digito_codigo_banco" do
|
|
99
|
-
it { expect(subject.digito_codigo_banco).to eq 'X' }
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
describe "#tipo_cobranca" do
|
|
103
|
-
it { expect(subject.tipo_cobranca).to eq '3' }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
describe "#tipo_carteira" do
|
|
107
|
-
it { expect(subject.tipo_carteira).to eq '1' }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
describe "#agencia_codigo_beneficiario" do
|
|
111
|
-
subject { Sicredi.new(agencia: '7190', posto: 2, conta_corrente: '25439') }
|
|
112
|
-
|
|
113
|
-
it { expect(subject.agencia_codigo_cedente).to eq '7190.02.25439' }
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
describe "#nosso_numero" do
|
|
117
|
-
subject do
|
|
118
|
-
Sicredi.new do |sicredi|
|
|
119
|
-
sicredi.agencia = 4927
|
|
120
|
-
sicredi.posto = '99'
|
|
121
|
-
sicredi.conta_corrente = 24837
|
|
122
|
-
sicredi.byte_id = '9'
|
|
123
|
-
sicredi.numero_documento = '72815'
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it { expect(subject.nosso_numero).to eq '15/972815-9' }
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
describe "#codigo_de_barras" do
|
|
131
|
-
subject do
|
|
132
|
-
Sicredi.new do |sicredi|
|
|
133
|
-
sicredi.agencia = '8136'
|
|
134
|
-
sicredi.conta_corrente = '62918'
|
|
135
|
-
sicredi.posto = 34
|
|
136
|
-
sicredi.byte_id = 3
|
|
137
|
-
sicredi.carteira = '03'
|
|
138
|
-
sicredi.numero_documento = 87264
|
|
139
|
-
sicredi.valor_documento = 8013.65
|
|
140
|
-
sicredi.data_vencimento = Date.parse('2006-10-29')
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it { expect(subject.codigo_de_barras).to eq '74894330900008013653115387264581363462918104' }
|
|
145
|
-
it { expect(subject.linha_digitavel).to eq '74893.11535 87264.581361 34629.181040 4 33090000801365' }
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class BancoBrasil < BoletoBancario::BancoBrasil
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
100 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[12 17] # Default %w[12 16 17 18]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe BancoBrasil do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 99.99, 25) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(100.01, 150) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(12, 17) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(16, 18, 20) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Banrisul < BoletoBancario::Banrisul
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
250 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[00] # Default %w[00 08]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Banrisul do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 249, 250) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(250.01, 260) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('00', 0) }
|
|
20
|
-
it { should_not have_valid(:carteira).when('08', 8, 10) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Boleto < BoletoBancario::Boleto
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
9_999.99 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe Boleto do
|
|
11
|
-
describe "on validations" do
|
|
12
|
-
it { should have_valid(:valor_documento).when(100.99, 9_999.99) }
|
|
13
|
-
it { should_not have_valid(:valor_documento).when(10_000.00, 99_999.99) }
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Bradesco < BoletoBancario::Bradesco
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
250 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[06 19 22] # Default %w[03 06 09 19 21 22]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Bradesco do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 249, 250) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(250.01, 260) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(6, 19, 22) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(3, 9, 21, 15) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Caixa < BoletoBancario::Caixa
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
100 # Default 9999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[12 17] # Default %w[14 24]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Caixa do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 99.99, 25) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(100.01, 150) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(12, 17) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(16, 14, 20) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Hsbc < BoletoBancario::Hsbc
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
100 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[ABC] # Default %w[CNR]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Hsbc do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 99.99, 25) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(100.01, 150) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when('ABC') }
|
|
20
|
-
it { should_not have_valid(:carteira).when('CNR', 14, 'CSB') }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Itau < BoletoBancario::Itau
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
250 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[109 175 198 131 146 142 168] # Default %w[107 109 174 175 196 198 126 131 146 122 142 143 150 168]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Itau do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 249, 250) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(250.01, 260) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(109, 175, 198, 131, 146, 142, 168) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(107, 174, 196, 126, 122, 143, 150) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Real < BoletoBancario::Real
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
711 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[20] # Default %w[00 20 31 42 47 85]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Real do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(1, 0.01, 711.00) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(711.01, 1000) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(20) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(00, 31, 42, 47, 85) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Santander < BoletoBancario::Santander
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
250 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[102] # Default %w[101 102 121]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Santander do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 249, 250) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(250.01, 260) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(102) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(101, 121) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Sicoob < BoletoBancario::Sicoob
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
456.50 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[1] # Default %w[1 9]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Sicoob do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 99.99, 25) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(456.51, 1000) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(1) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(9) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
|
|
4
|
-
class Sicredi < BoletoBancario::Sicredi
|
|
5
|
-
def self.valor_documento_tamanho_maximo
|
|
6
|
-
250 # Default 99999999.99
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.carteiras_suportadas
|
|
10
|
-
%w[102] # Default %w[11 31]
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe Sicredi do
|
|
15
|
-
describe "on validations" do
|
|
16
|
-
it { should have_valid(:valor_documento).when(99, 249, 250) }
|
|
17
|
-
it { should_not have_valid(:valor_documento).when(250.01, 260) }
|
|
18
|
-
|
|
19
|
-
it { should have_valid(:carteira).when(102) }
|
|
20
|
-
it { should_not have_valid(:carteira).when(1, 31) }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
shared_examples_for 'boleto bancario' do
|
|
2
|
-
describe "on validations" do
|
|
3
|
-
before do
|
|
4
|
-
subject.should respond_to(:cedente, :endereco_cedente, :valor_documento, :numero_documento)
|
|
5
|
-
subject.should respond_to(:carteira, :sacado, :documento_sacado, :data_vencimento)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it { should have_valid(:cedente).when('Razao Social') }
|
|
9
|
-
it { should_not have_valid(:cedente).when(nil, '') }
|
|
10
|
-
|
|
11
|
-
it { should have_valid(:endereco_cedente).when('Rua Itapaiuna') }
|
|
12
|
-
it { should_not have_valid(:endereco_cedente).when(nil, '') }
|
|
13
|
-
|
|
14
|
-
it { should have_valid(:numero_documento).when('09890') }
|
|
15
|
-
it { should_not have_valid(:numero_documento).when(nil, '') }
|
|
16
|
-
|
|
17
|
-
it { should have_valid(:sacado).when('Teste', 'Outro Teste') }
|
|
18
|
-
it { should_not have_valid(:sacado).when(nil, '') }
|
|
19
|
-
|
|
20
|
-
it { should have_valid(:documento_sacado).when('112.167.084-95', '613.318.746-88') }
|
|
21
|
-
it { should_not have_valid(:documento_sacado).when(nil, '') }
|
|
22
|
-
|
|
23
|
-
it { should have_valid(:data_vencimento).when(Date.today) }
|
|
24
|
-
it { should_not have_valid(:data_vencimento).when('', nil, '01/10/2012', '2012-10-2012') }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "#to_partial_path" do
|
|
28
|
-
it { should respond_to(:to_partial_path) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "#persisted?" do
|
|
32
|
-
before { subject.should respond_to(:persisted?) }
|
|
33
|
-
|
|
34
|
-
it { expect(subject.persisted?).to be false }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe "#carteira_formatada" do
|
|
38
|
-
it { subject.should respond_to(:carteira_formatada) }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "#valor_documento_formatado" do
|
|
42
|
-
it { subject.should respond_to(:valor_formatado_para_codigo_de_barras) }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe "#aceite_formatado" do
|
|
46
|
-
it { subject.should respond_to(:aceite_formatado) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
describe "#codigo_do_banco" do
|
|
50
|
-
before { subject.should respond_to(:codigo_banco) }
|
|
51
|
-
|
|
52
|
-
it { expect { subject.codigo_banco }.to_not raise_error() }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe "#digito_do_codigo_do_banco" do
|
|
56
|
-
before { subject.should respond_to(:digito_codigo_banco) }
|
|
57
|
-
|
|
58
|
-
it { expect { subject.digito_codigo_banco }.to_not raise_error() }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "#codigo_banco_formatado" do
|
|
62
|
-
before { subject.should respond_to(:codigo_banco_formatado) }
|
|
63
|
-
|
|
64
|
-
it "should format the 'codigo_banco' with digit" do
|
|
65
|
-
subject.stub(:codigo_banco).and_return('001')
|
|
66
|
-
subject.stub(:digito_codigo_banco).and_return('9')
|
|
67
|
-
subject.codigo_banco_formatado.should eq '001-9'
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
describe "#agencia_codigo_cedente" do
|
|
72
|
-
before { subject.should respond_to(:agencia_codigo_cedente) }
|
|
73
|
-
|
|
74
|
-
it { expect { subject.agencia_codigo_cedente }.to_not raise_error() }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe "#nosso_numero" do
|
|
78
|
-
before { subject.should respond_to(:nosso_numero) }
|
|
79
|
-
|
|
80
|
-
it { expect { subject.nosso_numero }.to_not raise_error() }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
describe "#carteira_formatada" do
|
|
84
|
-
it { should respond_to(:carteira, :carteira_formatada) }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "#codigo_de_barras_do_banco" do
|
|
88
|
-
before { subject.should respond_to(:codigo_de_barras_do_banco) }
|
|
89
|
-
|
|
90
|
-
it { expect { subject.codigo_de_barras_do_banco }.to_not raise_error() }
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
describe "#valor_formatado_para_codigo_de_barras" do
|
|
94
|
-
it { subject.should respond_to(:valor_documento) }
|
|
95
|
-
|
|
96
|
-
it { subject.should respond_to(:valor_formatado_para_codigo_de_barras) }
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
describe "#codigo_de_barras" do
|
|
100
|
-
before { subject.should respond_to(:codigo_de_barras) }
|
|
101
|
-
|
|
102
|
-
it "should return the barcode with DAC (barcode digit)" do
|
|
103
|
-
subject.stub(:codigo_de_barras_padrao).and_return('341916670000012345')
|
|
104
|
-
subject.stub(:codigo_de_barras_do_banco).and_return('1101234567880057123457000')
|
|
105
|
-
subject.codigo_de_barras.should eq '34196166700000123451101234567880057123457000'
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe "#codigo_de_barras_padrao" do
|
|
110
|
-
before { subject.should respond_to(:codigo_de_barras_padrao, :valor_documento) }
|
|
111
|
-
|
|
112
|
-
context "barcode positions" do
|
|
113
|
-
let(:boleto) { described_class.new(:valor_documento => 190.99, :data_vencimento => Date.parse('2012-10-20')) }
|
|
114
|
-
|
|
115
|
-
it "should return the first 18 positions of barcode" do
|
|
116
|
-
boleto.stub(:codigo_banco).and_return('341')
|
|
117
|
-
boleto.codigo_de_barras_padrao.should eq '341954920000019099'
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
describe "#digito_codigo_de_barras" do
|
|
123
|
-
before { subject.should respond_to(:digito_codigo_de_barras) }
|
|
124
|
-
|
|
125
|
-
context "using the Itau docs example" do
|
|
126
|
-
it "should calculate the digit using the modulo 11 factors 2 until 9" do
|
|
127
|
-
subject.stub(:codigo_de_barras_padrao).and_return('341916670000012345')
|
|
128
|
-
subject.stub(:codigo_de_barras_do_banco).and_return('1101234567880057123457000')
|
|
129
|
-
subject.digito_codigo_de_barras.should eq '6'
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
describe "#linha_digitavel" do
|
|
135
|
-
before { subject.should respond_to(:linha_digitavel) }
|
|
136
|
-
|
|
137
|
-
it "should return the digital line" do
|
|
138
|
-
subject.stub(:codigo_de_barras).and_return('39998100100000311551111122222500546666666001')
|
|
139
|
-
subject.linha_digitavel.should eq '39991.11119 22222.500542 66666.660015 8 10010000031155'
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
describe "#fator_de_vencimento" do
|
|
144
|
-
before { subject.should respond_to(:fator_de_vencimento) }
|
|
145
|
-
|
|
146
|
-
it "should calculate the expiration factor" do
|
|
147
|
-
subject.data_vencimento = Date.parse('2002-05-11')
|
|
148
|
-
subject.fator_de_vencimento.should eq '1677'
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require 'bundler/setup'
|
|
2
|
-
Bundler.require(:default, :development)
|
|
3
|
-
|
|
4
|
-
Dir[File.join(File.dirname(__FILE__), 'shared_examples/**/*.rb')].each do |file|
|
|
5
|
-
require(file)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
if ENV['COVERAGE']
|
|
9
|
-
require 'simplecov'
|
|
10
|
-
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
|
11
|
-
SimpleCov.start do
|
|
12
|
-
add_filter "/spec/"
|
|
13
|
-
end
|
|
14
|
-
end
|