cnab240 0.0.8 → 0.0.9

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 CHANGED
@@ -68,13 +68,14 @@ Voce pode criar arquivos, e adicionar lotes. A versão é automaticamente a 8.6,
68
68
  arquivo << lote
69
69
  arquivo.save_to_file("arquivo.test")
70
70
  ```
71
- Quando um lote é criado, os segmento obrigatórios e métodos de acesso serão criados automagicamente. Para adicionar mais segmentos utilize o operador << do lote.
71
+ Para adicionar segmentos utilize o operador << do lote.
72
72
 
73
73
  ```ruby
74
74
  arquivo = Arquivo::Arquivo.new('V86')
75
75
  lote = Lote.new(:operacao => :pagamento, :tipo => :remessa)
76
+ lote << :a
76
77
  # preencha os zilhoes de campos
77
- lote.segmento_a.favorecido_banco = '1'
78
+ lote.segmentos[0].favorecido_banco = '1'
78
79
  arquivo << lote
79
80
  arquivo.save_to_file("arquivo.test")
80
81
  ```
@@ -91,45 +92,39 @@ Ler do arquivo:
91
92
  Voce pode usar os helpers que vao preencher os campos automaticamente, se possivel:
92
93
 
93
94
  ```ruby
94
- debito = DebitoItau.new({
95
- # header de arquivo
96
- :empresa_tipo => '1',
97
- :empresa_convenio => '1234',
98
- :empresa_tipo => '2',
99
- :empresa_numero => '01234567891234',
100
- :empresa_nome => 'EMPRESA FULANA',
101
- :empresa_agencia_codigo => '',
102
- :empresa_conta_numero => '',
103
- :empresa_agencia_conta_dv => '',
104
- :arquivo_sequencia => '1'
105
- })
106
-
107
- debito.add({
108
- # header do lote
109
- :empresa_tipo => '2', # tipo empresa creditada
110
- :empresa_numero => '999999999999', # cpf cnpj creditado
111
- :empresa_convenio => '12345', # convenio junto ao banco
112
- :empresa_agencia_codigo => '2290', # agencia creditada
113
- :empresa_conta_numero => '33595', # conta creditada
114
- :empresa_agencia_conta_dv => '9', # dv conta agencia
115
- :empresa_nome => 'ZECA URUBU',
116
- :endereco_logradouro => 'AV BRASIL',
117
- :endereco_numero => '123',
118
- :endereco_cidade => 'RIO DE JANEIRO',
119
- :endereco_cep => '12123412',
120
- :endereco_estado => 'RJ',
121
- # segmento a
122
- :favorecido_agencia_codigo => '1234', # agencia do debitado
123
- :favorecido_conta_numero => '12345', # conta do debitado
124
- :favorecido_agencia_conta_dv => '1', # dv agencia e conta
125
- :favorecido_nome => 'EMPRESA X', # nome do debitado
95
+ pagamento = PagamentoItau.new({
96
+ :empresa_tipo => '2',
97
+ :empresa_convenio => '1234',
98
+ :empresa_tipo => '2',
99
+ :empresa_numero => '01234567891234',
100
+ :empresa_nome => 'EMPRESA FULANA',
101
+ :empresa_agencia_codigo => '',
102
+ :empresa_conta_numero => '',
103
+ :empresa_agencia_conta_dv => '',
104
+ :arquivo_sequencia => '1',
105
+
106
+ :endereco_logradouro => 'AV BRASIL',
107
+ :endereco_numero => '123',
108
+ :endereco_cidade => 'RIO DE JANEIRO',
109
+ :endereco_cep => '12123412',
110
+ :endereco_estado => 'RJ',
111
+ :servico_tipo => '98', # pagamentos - diversos
112
+ :servico_forma => '03', # doc, ted, etc
113
+ })
114
+
115
+ pagamento << { :favorecido_banco => '001',
116
+ :favorecido_agencia_conta => '2290124',
126
117
  :credito_seu_numero => '1234',
127
- :data => '30122012',
128
- :valor => '100',
129
- :numero_inscricao => '12345678901234' # cpf ou cnpj do debitado
130
- })
118
+ :credito_data_pagamento => '31122012',
119
+ :credito_valor_pagamento => '100',
120
+ :numero_inscricao => '12312312312312',
121
+ :favorecido_nome => 'EMPRESA X',
122
+ :credito_seu_numero => '1234',
123
+ :credito_data_pagamento => '30122012',
124
+ :credito_valor_pagamento => '100'
125
+ }
131
126
 
132
- debito.save_to_file("spec/tmp/arquivo_itau.test")
127
+ pagamento.string
133
128
  ```
134
129
 
135
130
  ## Considerações
@@ -9,7 +9,7 @@ module Cnab240
9
9
  attr_accessor :arquivo
10
10
 
11
11
  def initialize(options = {})
12
- @segmentos = {}
12
+ @segmentos = []
13
13
 
14
14
  @operacao ||= options[:operacao]
15
15
  @tipo ||= options[:tipo]
@@ -25,36 +25,27 @@ module Cnab240
25
25
  @trailer = estrutura[:trailer].new
26
26
 
27
27
  yield self if block_given?
28
-
29
- if tipo != :none
30
- estrutura[:segmentos].each do |s|
31
- raise "Tipo nao suportado: [#{s}][#{tipo}]" if (estrutura[s][tipo].nil?) && tipo != :any
32
- self << s if (tipo == :any) || (estrutura[s][tipo] == true)
33
- end
34
- end
35
28
  end
36
29
 
37
30
  def read_segmento(s, line)
38
- segmento = self << s
39
- segmentos[s] = segmento.read(line)
31
+ segmentos << segmento.read(line)
40
32
  end
41
33
 
42
34
  def <<(s)
43
35
  versao = arquivo.versao unless arquivo.nil?
44
36
  versao ||= @versao
45
37
 
46
- segmentos[s] = eval("Cnab240::#{versao}::Segmento#{s.to_s.upcase}.new")
47
- segmentos[s].lote = self
48
- add_segmento_accessors(s)
49
- segmentos[s]
38
+ segmentos << seg = eval("Cnab240::#{versao}::Segmento#{s.to_s.upcase}.new")
39
+ seg.lote = self
40
+ seg
50
41
  end
51
42
 
52
43
  def linhas
53
44
  seg_array = Array.new
54
45
  estrutura = ESTRUTURA[@versao][operacao]
55
46
  seg_array << @header.linha
56
- estrutura[:segmentos].each do |s|
57
- seg_array << @segmentos[s].linha unless @segmentos[s].nil?
47
+ segmentos.each do |s|
48
+ seg_array << s.linha
58
49
  end
59
50
  seg_array << @trailer.linha
60
51
  seg_array
@@ -64,18 +55,5 @@ module Cnab240
64
55
  linhas.join("\n")
65
56
  end
66
57
 
67
- private
68
-
69
- def add_segmento_accessors(segmento)
70
- instance_eval <<-RUBY, __FILE__, __LINE__ + 1
71
- def segmento_#{segmento.to_s.downcase}
72
- segmentos[:#{segmento.to_s.downcase}]
73
- end
74
- def segmento_#{segmento.to_s.downcase}=(s)
75
- segmentos[:#{segmento.to_s.downcase}] = s
76
- end
77
- RUBY
78
- end
79
-
80
58
  end
81
59
  end
@@ -7,7 +7,8 @@ module Cnab240
7
7
 
8
8
  def initialize(campos = {})
9
9
  @arquivo = Cnab240::Arquivo::Arquivo.new('V80')
10
- # header e trailer arquivo
10
+ @arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
11
+
11
12
  campos[:controle_banco] ||= '341'
12
13
  campos[:arquivo_codigo] ||= '1'
13
14
  campos[:banco_nome] ||= 'BANCO ITAU'
@@ -15,30 +16,26 @@ module Cnab240
15
16
  campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
16
17
 
17
18
  fill campos, arquivo.header, arquivo.trailer
18
- end
19
19
 
20
+ campos[:servico_operacao] ||= 'C'
21
+ campos[:controle_lote] ||= '0001'
20
22
 
21
- def add(campos = {})
22
- @arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
23
+ fill campos, lote.header, lote.trailer
23
24
 
24
- campos[:header] ||= {}
25
- campos[:trailer] ||= {}
26
- campos[:segmento_a] ||= {}
25
+ end
27
26
 
28
- campos[:header][:controle_banco] ||= '341'
29
- campos[:header][:servico_operacao] ||= 'C'
30
- campos[:header][:controle_lote] ||= @arquivo.lotes.length.to_s
31
27
 
32
- campos[:segmento_a][:controle_banco] ||= '341'
33
- campos[:segmento_a][:controle_lote] ||= @arquivo.lotes.length.to_s
34
- campos[:segmento_a][:servico_numero_registro] ||= '1'
35
- campos[:segmento_a][:servico_tipo_movimento] ||= '000'
36
- campos[:segmento_a][:credito_moeda_tipo] ||= 'REA'
37
- campos[:trailer][:totais_qtde_registros] ||= '000003'
28
+ def <<(campos)
29
+ lote = @arquivo.lotes.last
30
+ lote << :a
31
+ campos[:controle_banco] ||= '341'
32
+ campos[:controle_lote] ||= @arquivo.lotes.length.to_s
33
+ campos[:servico_numero_registro] ||= lote.segmentos.length.to_s
34
+ campos[:servico_tipo_movimento] ||= '000'
35
+ campos[:credito_moeda_tipo] ||= 'REA'
36
+ campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s
38
37
 
39
- fill! campos[:header], lote.header
40
- fill! campos[:segmento_a], lote.segmento_a
41
- fill! campos[:trailer], lote.trailer
38
+ fill campos, lote.segmentos.last
42
39
  end
43
40
 
44
41
  def string
@@ -3,7 +3,7 @@ module Cnab240::V80::Pagamentos
3
3
 
4
4
  include Cnab240::DefaultMixin
5
5
 
6
- lstring :controle_banco, :length => 3, :pad_byte => '0'
6
+ lstring :controle_banco, :length => 3, :pad_byte => '0'
7
7
  lstring :controle_lote, :length => 4, :pad_byte => '0'
8
8
  lstring :controle_registro, :length => 1, :initial_value => '5', :pad_byte => '0'
9
9
 
@@ -4,7 +4,7 @@ module Cnab240::V80
4
4
  include Cnab240::DefaultMixin
5
5
  include Cnab240::SegmentoMixin
6
6
 
7
- lstring :controle_banco, :length => 3, :pad_byte => '0'
7
+ lstring :controle_banco, :length => 3, :pad_byte => '0'
8
8
  lstring :controle_lote, :length => 4, :pad_byte => '0'
9
9
  string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
10
10
 
@@ -1,4 +1,4 @@
1
1
  module Cnab240
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
4
4
 
data/lib/cnab240.rb CHANGED
@@ -59,7 +59,6 @@ require "cnab240/pagamentos/v40/trailer"
59
59
  require "cnab240/arquivo/estrutura"
60
60
  require "cnab240/arquivo/builder"
61
61
 
62
- require "cnab240/helper/debito_itau"
63
62
  require "cnab240/helper/pagamento_itau"
64
63
 
65
64
 
@@ -75,11 +75,12 @@ describe Arquivo do
75
75
  it "auto fill do arquivo - soma de registros" do
76
76
  arquivo = Cnab240::Arquivo::Arquivo.new
77
77
  (1..2).each do |n|
78
- arquivo << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
78
+ arquivo << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
79
+ lote << :a
79
80
  end
80
81
  arquivo.auto_fill
81
82
  arquivo.trailer.totais_qtde_lotes.should eq '000002'
82
- arquivo.trailer.totais_qtde_registros.should eq '000010'
83
+ arquivo.trailer.totais_qtde_registros.should eq '000008'
83
84
  end
84
85
 
85
86
  it "deve carregar arquivo grande" do
@@ -7,8 +7,7 @@ describe PagamentoItau do
7
7
  it "deve criar pagamento" do
8
8
 
9
9
  pagamento = PagamentoItau.new({
10
- # header de arquivo
11
- :empresa_tipo => '1',
10
+ :empresa_tipo => '2',
12
11
  :empresa_convenio => '1234',
13
12
  :empresa_tipo => '2',
14
13
  :empresa_numero => '01234567891234',
@@ -16,30 +15,18 @@ describe PagamentoItau do
16
15
  :empresa_agencia_codigo => '',
17
16
  :empresa_conta_numero => '',
18
17
  :empresa_agencia_conta_dv => '',
19
- :arquivo_sequencia => '1'
18
+ :arquivo_sequencia => '1',
19
+
20
+ :endereco_logradouro => 'AV BRASIL',
21
+ :endereco_numero => '123',
22
+ :endereco_cidade => 'RIO DE JANEIRO',
23
+ :endereco_cep => '12123412',
24
+ :endereco_estado => 'RJ',
25
+ :servico_tipo => '98', # pagamentos - diversos
26
+ :servico_forma => '03', # doc, ted, etc
20
27
  })
21
28
 
22
- pagamento.add({
23
- :header => {
24
- :empresa_tipo => '2', # tipo empresa creditada
25
- :empresa_numero => '999999999999', # cpf cnpj creditado
26
- :empresa_agencia_codigo => '2290', # agencia creditada
27
- :empresa_conta_numero => '33595', # conta creditada
28
- :empresa_agencia_conta_dv => '9', # dv conta agencia
29
- :empresa_nome => 'ZECA URUBU',
30
- :endereco_logradouro => 'AV BRASIL',
31
- :endereco_numero => '123',
32
- :endereco_cidade => 'RIO DE JANEIRO',
33
- :endereco_cep => '12123412',
34
- :endereco_estado => 'RJ',
35
- :servico_tipo => '98', # pagamentos - diversos
36
- :servico_forma => '03', # doc, ted, etc
37
- },
38
-
39
- :trailer => {},
40
-
41
- :segmento_a => {
42
- :favorecido_banco => '001',
29
+ pagamento << { :favorecido_banco => '001',
43
30
  :favorecido_agencia_conta => '2290124',
44
31
  :credito_seu_numero => '1234',
45
32
  :credito_data_pagamento => '31122012',
@@ -48,9 +35,20 @@ describe PagamentoItau do
48
35
  :favorecido_nome => 'EMPRESA X',
49
36
  :credito_seu_numero => '1234',
50
37
  :credito_data_pagamento => '30122012',
38
+ :credito_valor_pagamento => '100'
39
+ }
40
+
41
+ pagamento << { :favorecido_banco => '001',
42
+ :favorecido_agencia_conta => '2290124',
43
+ :credito_seu_numero => '1234',
44
+ :credito_data_pagamento => '31122012',
51
45
  :credito_valor_pagamento => '100',
46
+ :numero_inscricao => '12312312312312',
47
+ :favorecido_nome => 'EMPRESA X',
48
+ :credito_seu_numero => '1234',
49
+ :credito_data_pagamento => '30122012',
50
+ :credito_valor_pagamento => '100'
52
51
  }
53
- })
54
52
 
55
53
 
56
54
  pagamento.arquivo.header.banco_nome.strip.should eq 'BANCO ITAU'
@@ -10,7 +10,8 @@ describe Cnab240::Lote do
10
10
 
11
11
  it "deve conter segmento a" do
12
12
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V40')
13
- lote.segmento_a.should be_an_instance_of(Cnab240::V40::SegmentoA)
13
+ lote << :a
14
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V40::SegmentoA)
14
15
  end
15
16
 
16
17
  it "linhas devem ter 240" do
@@ -10,7 +10,8 @@ describe Cnab240::Lote do
10
10
 
11
11
  it "deve conter segmento a" do
12
12
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
13
- lote.segmento_a.should be_an_instance_of(Cnab240::V80::SegmentoA)
13
+ lote << :a
14
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V80::SegmentoA)
14
15
  end
15
16
 
16
17
  it "linhas devem ter 240" do
@@ -10,22 +10,25 @@ describe Cnab240::Lote do
10
10
 
11
11
  it "deve conter segmento a" do
12
12
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
13
- lote.segmento_a.should be_an_instance_of(Cnab240::V86::SegmentoA)
13
+ lote << :a
14
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoA)
14
15
  end
15
16
 
16
17
  it "deve conter segmento b" do
17
18
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
18
- lote.segmento_b.should be_an_instance_of(Cnab240::V86::SegmentoB)
19
+ lote << :b
20
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoB)
19
21
  end
20
22
 
21
23
  it "pode conter segmento c" do
22
24
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
23
25
  lote << :c
24
- lote.should respond_to(:segmento_c)
26
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoC)
25
27
  end
26
28
 
27
29
  it "linhas devem ter 240" do
28
30
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
31
+ lote << :a
29
32
  lote.linhas.each do |linha|
30
33
  linha.length.should be(240)
31
34
  end
@@ -10,18 +10,20 @@ describe Cnab240::Lote do
10
10
 
11
11
  it "deve conter segmento a" do
12
12
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
13
- lote.segmento_a.should be_an_instance_of(Cnab240::V86::SegmentoA)
13
+ lote << :a
14
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoA)
14
15
  end
15
16
 
16
17
  it "deve conter segmento b" do
17
18
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
18
- lote.segmento_b.should be_an_instance_of(Cnab240::V86::SegmentoB)
19
+ lote << :b
20
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoB)
19
21
  end
20
22
 
21
23
  it "pode conter segmento c" do
22
24
  lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
23
25
  lote << :c
24
- lote.should respond_to(:segmento_c)
26
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoC)
25
27
  end
26
28
 
27
29
  it "linhas devem ter 240" do
@@ -10,24 +10,26 @@ describe Cnab240::Lote do
10
10
 
11
11
  it "deve conter segmento o" do
12
12
  lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
13
- lote.segmento_o.should be_an_instance_of(Cnab240::V86::SegmentoO)
13
+ lote << :o
14
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoO)
14
15
  end
15
16
 
16
17
  it "deve conter segmento n" do
17
18
  lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
18
- lote.segmento_n.should be_an_instance_of(Cnab240::V86::SegmentoN)
19
+ lote << :n
20
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoN)
19
21
  end
20
22
 
21
23
  it "pode conter segmento w" do
22
24
  lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
23
25
  lote << :w
24
- lote.should respond_to(:segmento_w)
26
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoW)
25
27
  end
26
28
 
27
29
  it "pode conter segmento z" do
28
30
  lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
29
31
  lote << :z
30
- lote.should respond_to(:segmento_z)
32
+ lote.segmentos[0].should be_an_instance_of(Cnab240::V86::SegmentoZ)
31
33
  end
32
34
 
33
35
  it "linhas devem ter 240" do
@@ -40,9 +40,10 @@ describe SegmentoN do
40
40
  lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa) do |l|
41
41
  l.header.servico_forma = '25'
42
42
  end
43
- lote.segmento_n.should be_an_instance_of(SegmentoN)
43
+ lote << :n
44
+ lote.segmentos[0].should be_an_instance_of(SegmentoN)
44
45
 
45
- segmento = lote.segmento_n.n_complemento
46
+ segmento = lote.segmentos[0].n_complemento
46
47
 
47
48
  segmento.should respond_to(:receita)
48
49
  segmento.should respond_to(:tipo_identificacao_contribuinte)
metadata CHANGED
@@ -1,55 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cnab240
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.8
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 9
10
+ version: 0.0.9
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Eduardo Mourao
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
+
18
+ date: 2012-07-24 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ requirement: *id001
23
32
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
33
+ name: rspec
34
+ type: :development
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
25
37
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ requirement: *id002
46
+ prerelease: false
31
47
  name: bindata
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
48
  type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
49
  description: Formato CNAB 240.
47
- email:
50
+ email:
48
51
  - eduardo.a20@gmail.com
49
52
  executables: []
53
+
50
54
  extensions: []
55
+
51
56
  extra_rdoc_files: []
52
- files:
57
+
58
+ files:
53
59
  - .gitignore
54
60
  - .rspec
55
61
  - .travis.yml
@@ -78,7 +84,6 @@ files:
78
84
  - lib/cnab240/ext/filler.rb
79
85
  - lib/cnab240/ext/lstring.rb
80
86
  - lib/cnab240/ext/segmento_mixin.rb
81
- - lib/cnab240/helper/debito_itau.rb
82
87
  - lib/cnab240/helper/pagamento_itau.rb
83
88
  - lib/cnab240/pagamentos/v40/header.rb
84
89
  - lib/cnab240/pagamentos/v40/trailer.rb
@@ -120,7 +125,6 @@ files:
120
125
  - spec/arquivo/v86/trailer_spec.rb
121
126
  - spec/bindata/bindata_spec.rb
122
127
  - spec/cnab240_spec.rb
123
- - spec/helper/debito_itau_spec.rb
124
128
  - spec/helper/pagamento_itau_spec.rb
125
129
  - spec/pagamentos/v40/header_spec.rb
126
130
  - spec/pagamentos/v40/lote_spec.rb
@@ -159,37 +163,41 @@ files:
159
163
  - spec/segmentos/v86/segmento_z_spec.rb
160
164
  - spec/spec_helper.rb
161
165
  - spec/tmp/.gitkeep
162
- homepage: ''
166
+ has_rdoc: true
167
+ homepage: ""
163
168
  licenses: []
169
+
164
170
  post_install_message:
165
171
  rdoc_options: []
166
- require_paths:
172
+
173
+ require_paths:
167
174
  - lib
168
- required_ruby_version: !ruby/object:Gem::Requirement
175
+ required_ruby_version: !ruby/object:Gem::Requirement
169
176
  none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- segments:
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ hash: 3
181
+ segments:
175
182
  - 0
176
- hash: 544104447877304933
177
- required_rubygems_version: !ruby/object:Gem::Requirement
183
+ version: "0"
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
185
  none: false
179
- requirements:
180
- - - ! '>='
181
- - !ruby/object:Gem::Version
182
- version: '0'
183
- segments:
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ hash: 3
190
+ segments:
184
191
  - 0
185
- hash: 544104447877304933
192
+ version: "0"
186
193
  requirements: []
194
+
187
195
  rubyforge_project: cnab240
188
- rubygems_version: 1.8.24
196
+ rubygems_version: 1.5.3
189
197
  signing_key:
190
198
  specification_version: 3
191
199
  summary: Formato CNAB 240.
192
- test_files:
200
+ test_files:
193
201
  - spec/arquivo/arquivo_spec.rb
194
202
  - spec/arquivo/v40/header_spec.rb
195
203
  - spec/arquivo/v40/trailer_spec.rb
@@ -199,7 +207,6 @@ test_files:
199
207
  - spec/arquivo/v86/trailer_spec.rb
200
208
  - spec/bindata/bindata_spec.rb
201
209
  - spec/cnab240_spec.rb
202
- - spec/helper/debito_itau_spec.rb
203
210
  - spec/helper/pagamento_itau_spec.rb
204
211
  - spec/pagamentos/v40/header_spec.rb
205
212
  - spec/pagamentos/v40/lote_spec.rb
@@ -1,56 +0,0 @@
1
- module Cnab240
2
- class DebitoItau
3
-
4
- include Cnab240::Filler
5
-
6
- attr_accessor :arquivo
7
-
8
- def initialize(campos = {})
9
- @arquivo = Cnab240::Arquivo::Arquivo.new('V40')
10
- # header e trailer arquivo
11
- campos[:controle_banco] ||= '341'
12
- campos[:banco_nome] ||= 'BANCO ITAU'
13
- campos[:arquivo_codigo] ||= '1'
14
- campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
15
- campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
16
-
17
- fill campos, arquivo.header, arquivo.trailer
18
- end
19
-
20
-
21
- def add(campos = {})
22
- @arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V40')
23
-
24
- campos[:controle_banco] ||= '341'
25
- campos[:servico_operacao] ||= 'D'
26
- campos[:servico_tipo] ||= '05'
27
- campos[:servico_forma] ||= '50'
28
- campos[:servico_codigo_movimento] ||= '000'
29
- campos[:servico_numero_registro] ||= '00001'
30
- campos[:credito_moeda_tipo] ||= 'REA'
31
- campos[:totais_qtde_registros] ||= '000003'
32
-
33
- campos[:controle_lote] ||= @arquivo.lotes.length.to_s
34
-
35
- if campos[:valor]
36
- campos[:credito_valor_pagamento] ||= campos[:valor]
37
- end
38
-
39
- if campos[:data]
40
- campos[:credito_data_pagamento] ||= campos[:data]
41
- end
42
-
43
- fill campos, lote.header, lote.trailer, lote.segmento_a
44
- end
45
-
46
- def string
47
- arquivo.string
48
- end
49
-
50
- def save_to_file(filename)
51
- arquivo.save_to_file(filename)
52
- end
53
-
54
- end
55
-
56
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Cnab240
4
-
5
- describe DebitoItau do
6
-
7
- it "deve criar debito" do
8
-
9
- debito = DebitoItau.new({
10
- # header de arquivo
11
- :empresa_convenio => '1234',
12
- :empresa_tipo => '2',
13
- :empresa_numero => '01234567891234',
14
- :empresa_nome => 'EMPRESA FULANA',
15
- :empresa_agencia_codigo => '',
16
- :empresa_conta_numero => '',
17
- :empresa_agencia_conta_dv => '',
18
- :arquivo_sequencia => '1'
19
- })
20
-
21
- debito.add({
22
- # header do lote
23
- :empresa_tipo => '2', # tipo empresa creditada
24
- :empresa_numero => '999999999999', # cpf cnpj creditado
25
- :empresa_convenio => '12345', # convenio junto ao banco
26
- :empresa_agencia_codigo => '2290', # agencia creditada
27
- :empresa_conta_numero => '33595', # conta creditada
28
- :empresa_agencia_conta_dv => '9', # dv conta agencia
29
- :empresa_nome => 'ZECA URUBU',
30
- :endereco_logradouro => 'AV BRASIL',
31
- :endereco_numero => '123',
32
- :endereco_cidade => 'RIO DE JANEIRO',
33
- :endereco_cep => '12123412',
34
- :endereco_estado => 'RJ',
35
- # segmento a
36
- :favorecido_agencia_codigo => '1234', # agencia do debitado
37
- :favorecido_conta_numero => '12345', # conta do debitado
38
- :favorecido_agencia_conta_dv => '1', # dv agencia e conta
39
- :favorecido_nome => 'EMPRESA X', # nome do debitado
40
- :credito_seu_numero => '1234',
41
- :data => '30122012',
42
- :valor => '100',
43
- :numero_inscricao => '12345678901234' # cpf ou cnpj do debitado
44
- })
45
-
46
-
47
- debito.arquivo.header.banco_nome.strip.should eq 'BANCO ITAU'
48
-
49
- debito.save_to_file("spec/tmp/arquivo_itau.test")
50
-
51
- debito.string
52
- end
53
-
54
- end