cnab240 0.0.6 → 0.0.7
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.
- data/README.md +50 -4
- data/docs/vendor/febraban/subcpadr12_layout_padrao_V86.pdf +0 -0
- data/lib/cnab240/arquivo/arquivo.rb +10 -1
- data/lib/cnab240/arquivo/v40/header.rb +14 -14
- data/lib/cnab240/arquivo/v40/trailer.rb +5 -4
- data/lib/cnab240/arquivo/v86/header.rb +12 -12
- data/lib/cnab240/arquivo/v86/trailer.rb +3 -3
- data/lib/cnab240/ext/bindata.rb +1 -1
- data/lib/cnab240/ext/default_mixin.rb +2 -0
- data/lib/cnab240/ext/filler.rb +13 -0
- data/lib/cnab240/ext/lstring.rb +102 -0
- data/lib/cnab240/helper/pagamento_itau.rb +60 -0
- data/lib/cnab240/pagamentos/v40/header.rb +18 -18
- data/lib/cnab240/pagamentos/v40/trailer.rb +7 -7
- data/lib/cnab240/pagamentos/v86/header.rb +14 -14
- data/lib/cnab240/pagamentos/v86/titulos/header.rb +13 -13
- data/lib/cnab240/pagamentos/v86/titulos/trailer.rb +8 -8
- data/lib/cnab240/pagamentos/v86/trailer.rb +8 -8
- data/lib/cnab240/pagamentos/v86/tributos/header.rb +14 -14
- data/lib/cnab240/pagamentos/v86/tributos/trailer.rb +6 -6
- data/lib/cnab240/segmentos/v40/segmento_a.rb +28 -25
- data/lib/cnab240/segmentos/v86/segmento_a.rb +15 -15
- data/lib/cnab240/segmentos/v86/segmento_b.rb +16 -16
- data/lib/cnab240/segmentos/v86/segmento_c.rb +11 -11
- data/lib/cnab240/segmentos/v86/segmento_j.rb +14 -14
- data/lib/cnab240/segmentos/v86/segmento_j52.rb +11 -11
- data/lib/cnab240/segmentos/v86/segmento_n.rb +7 -7
- data/lib/cnab240/segmentos/v86/segmento_n1.rb +6 -6
- data/lib/cnab240/segmentos/v86/segmento_n2.rb +8 -8
- data/lib/cnab240/segmentos/v86/segmento_n3.rb +8 -8
- data/lib/cnab240/segmentos/v86/segmento_n4.rb +10 -10
- data/lib/cnab240/segmentos/v86/segmento_n5.rb +5 -5
- data/lib/cnab240/segmentos/v86/segmento_n6.rb +5 -5
- data/lib/cnab240/segmentos/v86/segmento_n7.rb +5 -5
- data/lib/cnab240/segmentos/v86/segmento_n8.rb +5 -5
- data/lib/cnab240/segmentos/v86/segmento_o.rb +9 -9
- data/lib/cnab240/segmentos/v86/segmento_w.rb +4 -4
- data/lib/cnab240/segmentos/v86/segmento_z.rb +3 -3
- data/lib/cnab240/version.rb +1 -1
- data/lib/cnab240.rb +7 -1
- data/spec/arquivo/arquivo_spec.rb +10 -0
- data/spec/bindata/bindata_spec.rb +17 -2
- data/spec/helper/pagamento_itau_spec.rb +55 -0
- data/spec/segmentos/v40/segmento_a_spec.rb +18 -13
- metadata +10 -5
- data/lib/cnab240/helper/remessa.rb +0 -29
@@ -5,16 +5,16 @@ module Cnab240::V86
|
|
5
5
|
include Cnab240::SegmentoMixin
|
6
6
|
|
7
7
|
string :receita, :length => 6, :pad_byte => ' '
|
8
|
-
|
9
|
-
|
8
|
+
lstring :tipo_identificacao_contribuinte, :length => 2, :pad_byte => '0'
|
9
|
+
lstring :identificacao_contribuinte, :length => 14, :pad_byte => '0'
|
10
10
|
|
11
11
|
|
12
12
|
string :ie_munic_declar, :length => 8, :pad_byte => ' '
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
lstring :origem, :length => 16, :pad_byte => '0'
|
15
|
+
lstring :valor_principal, :length => 15, :pad_byte => '0'
|
16
16
|
string :atualizacao_monetaria, :length => 15, :pad_byte => ' '
|
17
|
-
|
17
|
+
lstring :valor_mora, :length => 15, :pad_byte => '0'
|
18
18
|
string :valor_multa, :length => 15, :pad_byte => ' '
|
19
19
|
string :data_vencimento, :length => 8, :pad_byte => ' '
|
20
20
|
string :periodo_parcela, :length => 6, :pad_byte => ' '
|
@@ -4,20 +4,20 @@ module Cnab240::V86
|
|
4
4
|
include Cnab240::DefaultMixin
|
5
5
|
include Cnab240::SegmentoMixin
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
lstring :controle_banco, :length => 3, :pad_byte => '0'
|
8
|
+
lstring :controle_lote, :length => 4, :pad_byte => '0'
|
9
9
|
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
lstring :servico_numero_registro, :length => 5, :pad_byte => '0'
|
12
|
+
lstring :servico_codigo_segmento, :length => 1, :initial_value => 'O', :pad_byte => ' '
|
13
|
+
lstring :servico_tipo_movimento, :length => 1, :pad_byte => '0'
|
14
|
+
lstring :servico_codigo_movimento, :length => 2, :pad_byte => '0'
|
15
15
|
|
16
16
|
string :codigo_barras, :length => 44, :pad_byte => ' '
|
17
17
|
string :nome_concessionaria, :length => 30, :pad_byte => ' '
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
lstring :data_vencimento, :length => 8, :pad_byte => '0'
|
19
|
+
lstring :data_pagamento, :length => 8, :pad_byte => '0'
|
20
|
+
lstring :valor_pagamento, :length => 15, :pad_byte => '0'
|
21
21
|
string :seu_numero, :length => 20, :pad_byte => ' '
|
22
22
|
string :nosso_numero, :length => 20, :pad_byte => ' '
|
23
23
|
|
@@ -4,13 +4,13 @@ module Cnab240::V86
|
|
4
4
|
include Cnab240::DefaultMixin
|
5
5
|
include Cnab240::SegmentoMixin
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
lstring :controle_banco, :length => 3, :pad_byte => '0'
|
8
|
+
lstring :controle_lote, :length => 4, :pad_byte => '0'
|
9
9
|
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
10
10
|
|
11
|
-
|
11
|
+
lstring :servico_numero_registro, :length => 5, :pad_byte => '0'
|
12
12
|
string :servico_codigo_segmento, :length => 1, :initial_value => 'W', :pad_byte => ' '
|
13
|
-
|
13
|
+
lstring :complemento, :length => 1, :pad_byte => '0'
|
14
14
|
|
15
15
|
string :uso_informacoes_1_e_2, :length => 1, :pad_byte => ' '
|
16
16
|
string :informacao_1, :length => 80, :pad_byte => ' '
|
@@ -4,11 +4,11 @@ module Cnab240::V86
|
|
4
4
|
include Cnab240::DefaultMixin
|
5
5
|
include Cnab240::SegmentoMixin
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
lstring :controle_banco, :length => 3, :pad_byte => '0'
|
8
|
+
lstring :controle_lote, :length => 4, :pad_byte => '0'
|
9
9
|
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
10
10
|
|
11
|
-
|
11
|
+
lstring :servico_numero_registro, :length => 5, :pad_byte => '0'
|
12
12
|
string :servico_codigo_segmento, :length => 1, :initial_value => 'Z', :pad_byte => ' '
|
13
13
|
|
14
14
|
string :autenticacao, :length => 64, :pad_byte => ' '
|
data/lib/cnab240/version.rb
CHANGED
data/lib/cnab240.rb
CHANGED
@@ -2,10 +2,13 @@ require "cnab240/version"
|
|
2
2
|
|
3
3
|
require 'bindata'
|
4
4
|
|
5
|
+
|
5
6
|
require "cnab240/ext/attribute_accessors"
|
6
7
|
require "cnab240/ext/bindata"
|
8
|
+
require "cnab240/ext/lstring"
|
7
9
|
require "cnab240/ext/default_mixin"
|
8
10
|
require "cnab240/ext/segmento_mixin"
|
11
|
+
require "cnab240/ext/filler"
|
9
12
|
|
10
13
|
require "cnab240/arquivo/lote"
|
11
14
|
|
@@ -48,9 +51,10 @@ require "cnab240/pagamentos/v40/header"
|
|
48
51
|
require "cnab240/pagamentos/v40/trailer"
|
49
52
|
|
50
53
|
require "cnab240/arquivo/estrutura"
|
51
|
-
|
52
54
|
require "cnab240/arquivo/builder"
|
53
55
|
|
56
|
+
require "cnab240/helper/pagamento_itau"
|
57
|
+
|
54
58
|
|
55
59
|
module Cnab240
|
56
60
|
|
@@ -60,6 +64,8 @@ module Cnab240
|
|
60
64
|
mod_attr_accessor :fallback
|
61
65
|
@@fallback = "V86"
|
62
66
|
|
67
|
+
mod_attr_accessor :auto_fill_enabled
|
68
|
+
@@auto_fill_enabled = true
|
63
69
|
|
64
70
|
# Yield self for configuration block:
|
65
71
|
#
|
@@ -72,6 +72,16 @@ describe Arquivo do
|
|
72
72
|
|
73
73
|
end
|
74
74
|
|
75
|
+
it "auto fill do arquivo - soma de registros" do
|
76
|
+
arquivo = Cnab240::Arquivo::Arquivo.new
|
77
|
+
(1..2).each do |n|
|
78
|
+
arquivo << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
79
|
+
end
|
80
|
+
arquivo.auto_fill
|
81
|
+
arquivo.trailer.totais_qtde_lotes.should eq '000002'
|
82
|
+
arquivo.trailer.totais_qtde_registros.should eq '000010'
|
83
|
+
end
|
84
|
+
|
75
85
|
it "deve carregar arquivo grande" do
|
76
86
|
|
77
87
|
# arquivo_read = Cnab240::Arquivo::Arquivo.load_from_file("spec/tmp/B330002984PSL.REM")[0]
|
@@ -21,7 +21,7 @@ describe "Bindata" do
|
|
21
21
|
|
22
22
|
class Dummy2 < BinData::Record
|
23
23
|
string :f1, :length => 3, :pad_byte => '1'
|
24
|
-
string :f2, :value => '0000', :pad_byte => '0'
|
24
|
+
string :f2, :value => '0000', :pad_byte => '0', :read_length => 4
|
25
25
|
string :f3, :length => 9, :pad_byte => 'X'
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,22 @@ describe "Bindata" do
|
|
33
33
|
s2 = StringIO.new
|
34
34
|
d2.write(s2)
|
35
35
|
|
36
|
-
|
36
|
+
s1.string.should eq s2.string
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should pad left" do
|
40
|
+
class Dummy3 < BinData::Record
|
41
|
+
lstring :f2, :length => 4, :pad_byte => '0'
|
42
|
+
end
|
43
|
+
|
44
|
+
d1 = Dummy3.new
|
45
|
+
d1.f2 = '1'
|
46
|
+
s1 = StringIO.new
|
47
|
+
d1.write(s1)
|
48
|
+
|
49
|
+
d2 = Dummy3.read(s1.string)
|
50
|
+
d2.f2.should eq('0001')
|
51
|
+
|
37
52
|
end
|
38
53
|
|
39
54
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe PagamentoItau do
|
6
|
+
|
7
|
+
it "deve criar pagamento" do
|
8
|
+
|
9
|
+
pagamento = PagamentoItau.new({
|
10
|
+
# header de arquivo
|
11
|
+
:empresa_tipo => '1',
|
12
|
+
:empresa_convenio => '1234',
|
13
|
+
:empresa_tipo => '2',
|
14
|
+
:empresa_numero => '01234567891234',
|
15
|
+
:empresa_nome => 'EMPRESA FULANA',
|
16
|
+
:empresa_agencia_codigo => '',
|
17
|
+
:empresa_conta_numero => '',
|
18
|
+
:empresa_agencia_conta_dv => '',
|
19
|
+
:arquivo_sequencia => '1'
|
20
|
+
})
|
21
|
+
|
22
|
+
pagamento.add({
|
23
|
+
# header do lote
|
24
|
+
:empresa_tipo => '2', # tipo empresa creditada
|
25
|
+
:empresa_numero => '999999999999', # cpf cnpj creditado
|
26
|
+
:empresa_convenio => '12345', # convenio junto ao banco
|
27
|
+
:empresa_agencia_codigo => '2290', # agencia creditada
|
28
|
+
:empresa_conta_numero => '33595', # conta creditada
|
29
|
+
:empresa_agencia_conta_dv => '9', # dv conta agencia
|
30
|
+
:empresa_nome => 'ZECA URUBU',
|
31
|
+
:endereco_logradouro => 'AV BRASIL',
|
32
|
+
:endereco_numero => '123',
|
33
|
+
:endereco_cidade => 'RIO DE JANEIRO',
|
34
|
+
:endereco_cep => '12123412',
|
35
|
+
:endereco_estado => 'RJ',
|
36
|
+
# segmento a
|
37
|
+
:favorecido_agencia_codigo => '1234', # agencia do debitado
|
38
|
+
:favorecido_conta_numero => '12345', # conta do debitado
|
39
|
+
:favorecido_agencia_conta_dv => '1', # dv agencia e conta
|
40
|
+
:favorecido_nome => 'EMPRESA X', # nome do debitado
|
41
|
+
:credito_seu_numero => '1234',
|
42
|
+
:data => '30122012',
|
43
|
+
:valor => '100',
|
44
|
+
:numero_inscricao => '12345678901234' # cpf ou cnpj do debitado
|
45
|
+
})
|
46
|
+
|
47
|
+
|
48
|
+
pagamento.arquivo.header.banco_nome.strip.should eq 'BANCO ITAU'
|
49
|
+
|
50
|
+
pagamento.save_to_file("spec/tmp/arquivo_itau.test")
|
51
|
+
|
52
|
+
pagamento.string
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -5,12 +5,12 @@ include Cnab240::V40
|
|
5
5
|
describe SegmentoA do
|
6
6
|
|
7
7
|
it "deve instanciar segmento" do
|
8
|
-
segmento = SegmentoA.new
|
9
|
-
segmento.should be_an_instance_of(SegmentoA)
|
8
|
+
segmento = Cnab240::V40::SegmentoA.new
|
9
|
+
segmento.should be_an_instance_of(Cnab240::V40::SegmentoA)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "deve conter campos" do
|
13
|
-
segmento = SegmentoA.new
|
13
|
+
segmento = Cnab240::V40::SegmentoA.new
|
14
14
|
|
15
15
|
segmento.should respond_to(:controle_banco)
|
16
16
|
segmento.should respond_to(:controle_lote)
|
@@ -18,18 +18,23 @@ describe SegmentoA do
|
|
18
18
|
|
19
19
|
segmento.should respond_to(:servico_numero_registro)
|
20
20
|
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
-
segmento.should respond_to(:servico_tipo_movimento)
|
22
21
|
segmento.should respond_to(:servico_codigo_movimento)
|
23
22
|
|
24
23
|
segmento.should respond_to(:favorecido_camara)
|
25
24
|
segmento.should respond_to(:favorecido_banco)
|
25
|
+
segmento.should respond_to(:brancos_1)
|
26
|
+
|
26
27
|
segmento.should respond_to(:favorecido_agencia_codigo)
|
27
|
-
segmento.should respond_to(:
|
28
|
+
segmento.should respond_to(:brancos_2)
|
29
|
+
segmento.should respond_to(:brancos_3)
|
30
|
+
|
28
31
|
segmento.should respond_to(:favorecido_conta_numero)
|
29
|
-
segmento.should respond_to(:
|
32
|
+
segmento.should respond_to(:brancos_4)
|
33
|
+
segmento.should respond_to(:favorecido_agencia_conta_dv)
|
30
34
|
segmento.should respond_to(:favorecido_nome)
|
31
35
|
|
32
36
|
segmento.should respond_to(:credito_seu_numero)
|
37
|
+
segmento.should respond_to(:brancos_5)
|
33
38
|
segmento.should respond_to(:credito_data_pagamento)
|
34
39
|
segmento.should respond_to(:credito_moeda_tipo)
|
35
40
|
segmento.should respond_to(:credito_moeda_quantidade)
|
@@ -38,18 +43,18 @@ describe SegmentoA do
|
|
38
43
|
segmento.should respond_to(:credito_data_real)
|
39
44
|
segmento.should respond_to(:credito_valor_real)
|
40
45
|
|
41
|
-
segmento.should respond_to(:
|
46
|
+
segmento.should respond_to(:tipo_mora)
|
47
|
+
segmento.should respond_to(:valor_mora)
|
48
|
+
|
49
|
+
segmento.should respond_to(:complemento)
|
50
|
+
segmento.should respond_to(:brancos_6)
|
51
|
+
segmento.should respond_to(:numero_inscricao)
|
42
52
|
|
43
|
-
segmento.should respond_to(:codigo_finalidade_doc)
|
44
|
-
segmento.should respond_to(:codigo_finalidade_ted)
|
45
|
-
segmento.should respond_to(:codigo_finalidade_complementar)
|
46
|
-
segmento.should respond_to(:cnab_g004_1)
|
47
|
-
segmento.should respond_to(:aviso)
|
48
53
|
segmento.should respond_to(:ocorrencias)
|
49
54
|
end
|
50
55
|
|
51
56
|
it "deve ter 240 caracteres" do
|
52
|
-
segmento = SegmentoA.new
|
57
|
+
segmento = Cnab240::V40::SegmentoA.new
|
53
58
|
segmento.linha.length.should be(240)
|
54
59
|
end
|
55
60
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnab240
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eduardo Mourao
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-23 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- cnab240.gemspec
|
67
|
+
- docs/vendor/febraban/subcpadr12_layout_padrao_V86.pdf
|
67
68
|
- docs/vendor/itau/sisdeb_cnab_240.pdf
|
68
69
|
- lib/cnab240.rb
|
69
70
|
- lib/cnab240/arquivo/arquivo.rb
|
@@ -77,8 +78,10 @@ files:
|
|
77
78
|
- lib/cnab240/ext/attribute_accessors.rb
|
78
79
|
- lib/cnab240/ext/bindata.rb
|
79
80
|
- lib/cnab240/ext/default_mixin.rb
|
81
|
+
- lib/cnab240/ext/filler.rb
|
82
|
+
- lib/cnab240/ext/lstring.rb
|
80
83
|
- lib/cnab240/ext/segmento_mixin.rb
|
81
|
-
- lib/cnab240/helper/
|
84
|
+
- lib/cnab240/helper/pagamento_itau.rb
|
82
85
|
- lib/cnab240/pagamentos/v40/header.rb
|
83
86
|
- lib/cnab240/pagamentos/v40/trailer.rb
|
84
87
|
- lib/cnab240/pagamentos/v86/header.rb
|
@@ -114,6 +117,7 @@ files:
|
|
114
117
|
- spec/arquivo/v86/trailer_spec.rb
|
115
118
|
- spec/bindata/bindata_spec.rb
|
116
119
|
- spec/cnab240_spec.rb
|
120
|
+
- spec/helper/pagamento_itau_spec.rb
|
117
121
|
- spec/pagamentos/v40/header_spec.rb
|
118
122
|
- spec/pagamentos/v40/lote_spec.rb
|
119
123
|
- spec/pagamentos/v40/trailer_spec.rb
|
@@ -189,6 +193,7 @@ test_files:
|
|
189
193
|
- spec/arquivo/v86/trailer_spec.rb
|
190
194
|
- spec/bindata/bindata_spec.rb
|
191
195
|
- spec/cnab240_spec.rb
|
196
|
+
- spec/helper/pagamento_itau_spec.rb
|
192
197
|
- spec/pagamentos/v40/header_spec.rb
|
193
198
|
- spec/pagamentos/v40/lote_spec.rb
|
194
199
|
- spec/pagamentos/v40/trailer_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Cnab240
|
2
|
-
class Remessa
|
3
|
-
|
4
|
-
attr_accessor :arquivo
|
5
|
-
|
6
|
-
def initialize(campos = {})
|
7
|
-
@arquivo = Cnab240::Arquivo::Arquivo.new
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
def add(operacao, campos = {})
|
12
|
-
raise "Operacao invalida" if ESTRUTURA[:operacao].nil?
|
13
|
-
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => campos[:operacao], :tipo => :remessa)
|
14
|
-
campos.each do |k,v|
|
15
|
-
lote.header.send("#{k}=", v) if lote.header.respond_to?("#{k}=")
|
16
|
-
|
17
|
-
lote.trailer.send("#{k}=", v) if lote.trailer.respond_to?("#{k}=")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def string
|
22
|
-
end
|
23
|
-
|
24
|
-
def save_to_file
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|