cnab240 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/lib/cnab240/arquivo/arquivo.rb +11 -3
- data/lib/cnab240/arquivo/estrutura.rb +60 -0
- data/lib/cnab240/arquivo/lote.rb +12 -7
- data/lib/cnab240/pagamentos/titulos/header.rb +46 -0
- data/lib/cnab240/pagamentos/titulos/trailer.rb +18 -0
- data/lib/cnab240/pagamentos/trailer.rb +10 -10
- data/lib/cnab240/pagamentos/tributos/header.rb +47 -0
- data/lib/cnab240/pagamentos/tributos/trailer.rb +17 -0
- data/lib/cnab240/segmentos/segmento_j.rb +33 -0
- data/lib/cnab240/segmentos/segmento_j52.rb +33 -0
- data/lib/cnab240/segmentos/segmento_n.rb +26 -0
- data/lib/cnab240/segmentos/segmento_o.rb +27 -0
- data/lib/cnab240/segmentos/segmento_w.rb +24 -0
- data/lib/cnab240/segmentos/segmento_w1.rb +16 -0
- data/lib/cnab240/segmentos/segmento_z.rb +18 -0
- data/lib/cnab240/version.rb +1 -1
- data/lib/cnab240.rb +13 -8
- data/spec/arquivo/arquivo_spec.rb +3 -3
- data/spec/pagamentos/lote_spec.rb +6 -5
- data/spec/pagamentos/titulos/header_spec.rb +51 -0
- data/spec/pagamentos/titulos/lote_spec.rb +35 -0
- data/spec/pagamentos/titulos/trailer_spec.rb +30 -0
- data/spec/pagamentos/tributos/header_spec.rb +53 -0
- data/spec/pagamentos/tributos/lote_spec.rb +41 -0
- data/spec/pagamentos/tributos/trailer_spec.rb +27 -0
- data/spec/segmentos/segmento_j52_spec.rb +46 -0
- data/spec/segmentos/segmento_j_spec.rb +46 -0
- data/spec/segmentos/segmento_n_spec.rb +39 -0
- data/spec/segmentos/segmento_o_spec.rb +41 -0
- data/spec/segmentos/segmento_w_spec.rb +42 -0
- data/spec/segmentos/segmento_z_spec.rb +33 -0
- data/spec/tmp/.gitkeep +0 -0
- metadata +42 -4
data/.gitignore
CHANGED
@@ -28,7 +28,10 @@ module Cnab240::Arquivo
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def save_to_file(filename)
|
31
|
-
|
31
|
+
begin
|
32
|
+
File.delete(filename) # LoL
|
33
|
+
rescue
|
34
|
+
end
|
32
35
|
File.open(filename, 'w') {|f| f.write(string) }
|
33
36
|
end
|
34
37
|
|
@@ -39,19 +42,24 @@ module Cnab240::Arquivo
|
|
39
42
|
line.gsub!("\n", "")
|
40
43
|
line_number = line_number + 1
|
41
44
|
raise "Invalid line length: #{line.length} expected 240 at line number #{line_number}\n\t Line: [#{line}]" unless line.length == 240
|
42
|
-
case line[7]
|
45
|
+
case line[7..7] # ruby 1.8.7 requires this fuck
|
43
46
|
when '0' # header de arquivo
|
44
47
|
arquivos << Arquivo.new
|
45
48
|
arquivos.last.header = Header.read(line)
|
46
49
|
when '1'
|
50
|
+
# raise NotImplementedError.new("Tipo de registro not implemented")
|
47
51
|
when '2'
|
52
|
+
# raise NotImplementedError.new("Tipo de registro not implemented")
|
48
53
|
when '3'
|
54
|
+
# raise NotImplementedError.new("Tipo de registro not implemented")
|
49
55
|
when '4'
|
56
|
+
# raise NotImplementedError.new("Tipo de registro not implemented")
|
50
57
|
when '5'
|
58
|
+
# raise NotImplementedError.new("Tipo de registro not implemented")
|
51
59
|
when '9'
|
52
60
|
arquivos.last.header = Trailer.read(line)
|
53
61
|
else
|
54
|
-
raise
|
62
|
+
raise "Invalid tipo de registro: #{line[7]} at line #{line_number} \n\t Line: [#{line}]"
|
55
63
|
end
|
56
64
|
end
|
57
65
|
arquivos
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Cnab240
|
2
|
+
|
3
|
+
ESTRUTURA = {
|
4
|
+
:pagamento => {
|
5
|
+
:header => Cnab240::Pagamentos::Header,
|
6
|
+
:trailer => Cnab240::Pagamentos::Trailer,
|
7
|
+
:segmentos => [:a, :b, :c],
|
8
|
+
:a => {
|
9
|
+
:remessa => true,
|
10
|
+
:retorno => true
|
11
|
+
},
|
12
|
+
:b => {
|
13
|
+
:remessa => true,
|
14
|
+
:retorno => true
|
15
|
+
},
|
16
|
+
:c => {
|
17
|
+
:remessa => false,
|
18
|
+
:retorno => false
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
:pagamento_titulo_cobranca => {
|
23
|
+
:header => Cnab240::PagamentosTitulos::Header,
|
24
|
+
:trailer => Cnab240::PagamentosTitulos::Trailer,
|
25
|
+
:segmentos => [:j, :j52],
|
26
|
+
:j => {
|
27
|
+
:remessa => true,
|
28
|
+
:retorno => true
|
29
|
+
},
|
30
|
+
:j52 => {
|
31
|
+
:remessa => false,
|
32
|
+
:retorno => false
|
33
|
+
}
|
34
|
+
},
|
35
|
+
|
36
|
+
:pagamento_titulo_tributos => {
|
37
|
+
:header => Cnab240::PagamentosTributos::Header,
|
38
|
+
:trailer => Cnab240::PagamentosTributos::Trailer,
|
39
|
+
:segmentos => [:o, :n, :w, :z],
|
40
|
+
:o => {
|
41
|
+
:remessa => true,
|
42
|
+
:retorno => true
|
43
|
+
},
|
44
|
+
:n => {
|
45
|
+
:remessa => true,
|
46
|
+
:retorno => true
|
47
|
+
},
|
48
|
+
:w => {
|
49
|
+
:remessa => false,
|
50
|
+
:retorno => false
|
51
|
+
},
|
52
|
+
:z => {
|
53
|
+
:remessa => false,
|
54
|
+
:retorno => false
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
end
|
data/lib/cnab240/arquivo/lote.rb
CHANGED
@@ -4,21 +4,26 @@ module Cnab240
|
|
4
4
|
attr_accessor :segmentos
|
5
5
|
attr_accessor :trailer
|
6
6
|
attr_accessor :operacao
|
7
|
+
attr_accessor :tipo
|
7
8
|
|
8
|
-
def initialize(
|
9
|
+
def initialize(options = {})
|
9
10
|
@segmentos = {}
|
11
|
+
|
12
|
+
@operacao ||= options[:operacao]
|
13
|
+
@tipo ||= options[:tipo]
|
14
|
+
|
15
|
+
raise "Operacao nao suportada: #{operacao}" if ESTRUTURA[operacao].nil?
|
10
16
|
|
11
|
-
unless @operacao = op
|
12
|
-
return
|
13
|
-
end
|
14
|
-
|
15
17
|
estrutura = ESTRUTURA[operacao]
|
16
18
|
|
17
19
|
@header = estrutura[:header].new
|
18
20
|
@trailer = estrutura[:trailer].new
|
19
21
|
|
20
22
|
estrutura[:segmentos].each do |s|
|
21
|
-
|
23
|
+
raise "Tipo nao suportado: [#{s}][#{tipo}]" if estrutura[s][tipo].nil?
|
24
|
+
if estrutura[s][tipo] == true
|
25
|
+
self << s
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
@@ -32,7 +37,7 @@ module Cnab240
|
|
32
37
|
estrutura = ESTRUTURA[operacao]
|
33
38
|
seg_array << @header.linha
|
34
39
|
estrutura[:segmentos].each do |s|
|
35
|
-
seg_array << @segmentos[s].linha
|
40
|
+
seg_array << @segmentos[s].linha unless @segmentos[s].nil?
|
36
41
|
end
|
37
42
|
seg_array << @trailer.linha
|
38
43
|
seg_array
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Cnab240::PagamentosTitulos
|
2
|
+
class Header < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '1', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_operacao, :value => 'C', :pad_byte => ' '
|
11
|
+
string :servico_tipo, :length => 2 , :pad_byte => '0'
|
12
|
+
string :servico_forma, :length => 2, :pad_byte => '0'
|
13
|
+
string :servico_layout, :value => '040', :pad_byte => '0'
|
14
|
+
|
15
|
+
string :cnab_g004_1, :length => 1, :pad_byte => ' '
|
16
|
+
|
17
|
+
string :empresa_tipo, :length => 1, :pad_byte => '0'
|
18
|
+
string :empresa_numero, :length => 14, :pad_byte => '0'
|
19
|
+
string :empresa_convenio, :length => 20, :pad_byte => ' '
|
20
|
+
string :empresa_agencia_codigo, :length => 5, :pad_byte => '0'
|
21
|
+
string :empresa_agencia_dv, :length => 1, :pad_byte => ' '
|
22
|
+
string :empresa_conta_numero, :length => 12, :pad_byte => '0'
|
23
|
+
string :empresa_conta_dv, :length => 1, :pad_byte => ' '
|
24
|
+
string :empresa_agencia_conta_dv, :length => 1, :pad_byte => ' '
|
25
|
+
string :empresa_nome, :length => 30, :pad_byte => ' '
|
26
|
+
|
27
|
+
string :informacao_1, :length => 40, :pad_byte => ' '
|
28
|
+
|
29
|
+
string :endereco_logradouro, :length => 30, :pad_byte => ' '
|
30
|
+
string :endereco_numero, :length => 5, :pad_byte => '0'
|
31
|
+
string :endereco_complemento, :length => 15, :pad_byte => ' '
|
32
|
+
string :endereco_cidade, :length => 20, :pad_byte => ' '
|
33
|
+
string :endereco_cep, :length => 5, :pad_byte => '0'
|
34
|
+
string :endereco_complemento_cep, :length => 3, :pad_byte => '0'
|
35
|
+
string :endereco_estado, :length => 2, :pad_byte => ' '
|
36
|
+
|
37
|
+
string :cnab_g004_2, :length => 8, :pad_byte => ' '
|
38
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def auto_fill
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cnab240::PagamentosTitulos
|
2
|
+
class Trailer < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :value => '5', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :cnab_g004_1, :length => 9, :pad_byte => '0'
|
11
|
+
string :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
12
|
+
string :totais_valor, :length => 18, :pad_byte => '0'
|
13
|
+
string :totais_qtde_moeda, :length => 18, :pad_byte => '0'
|
14
|
+
string :numero_aviso_debito, :length => 6, :pad_byte => '0'
|
15
|
+
string :cnab_g004_2, :length => 165, :pad_byte => ' '
|
16
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
17
|
+
end
|
18
|
+
end
|
@@ -3,16 +3,16 @@ module Cnab240::Pagamentos
|
|
3
3
|
|
4
4
|
include Cnab240::DefaultMixin
|
5
5
|
|
6
|
-
string :controle_banco, :length => 3
|
7
|
-
string :controle_lote, :length => 4
|
8
|
-
string :controle_registro, :value => '5'
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :value => '5', :pad_byte => '0'
|
9
9
|
|
10
|
-
string :cnab_g004_1, :length => 9
|
11
|
-
string :totais_qtde_registros, :length => 6
|
12
|
-
string :totais_valor, :length => 18
|
13
|
-
string :totais_qtde_moeda, :length => 18
|
14
|
-
string :numero_aviso_debito, :length => 6
|
15
|
-
string :cnab_g004_2, :length => 165
|
16
|
-
string :ocorrencias, :length => 10
|
10
|
+
string :cnab_g004_1, :length => 9, :pad_byte => '0'
|
11
|
+
string :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
12
|
+
string :totais_valor, :length => 18, :pad_byte => '0'
|
13
|
+
string :totais_qtde_moeda, :length => 18, :pad_byte => '0'
|
14
|
+
string :numero_aviso_debito, :length => 6, :pad_byte => '0'
|
15
|
+
string :cnab_g004_2, :length => 165, :pad_byte => ' '
|
16
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Cnab240::PagamentosTributos
|
2
|
+
class Header < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '1', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_operacao, :value => 'C', :pad_byte => ' '
|
11
|
+
string :servico_tipo, :length => 2 , :pad_byte => '0'
|
12
|
+
string :servico_forma, :length => 2, :pad_byte => '0'
|
13
|
+
string :servico_layout, :value => '011', :pad_byte => '0'
|
14
|
+
|
15
|
+
string :cnab_g004_1, :length => 1, :pad_byte => ' '
|
16
|
+
|
17
|
+
string :empresa_tipo, :length => 1, :pad_byte => '0'
|
18
|
+
string :empresa_numero, :length => 14, :pad_byte => '0'
|
19
|
+
string :empresa_convenio, :length => 20, :pad_byte => ' '
|
20
|
+
string :empresa_agencia_codigo, :length => 5, :pad_byte => '0'
|
21
|
+
string :empresa_agencia_dv, :length => 1, :pad_byte => ' '
|
22
|
+
string :empresa_conta_numero, :length => 12, :pad_byte => '0'
|
23
|
+
string :empresa_conta_dv, :length => 1, :pad_byte => ' '
|
24
|
+
string :empresa_agencia_conta_dv, :length => 1, :pad_byte => ' '
|
25
|
+
string :empresa_nome, :length => 30, :pad_byte => ' '
|
26
|
+
|
27
|
+
string :informacao_1, :length => 40, :pad_byte => ' '
|
28
|
+
|
29
|
+
string :endereco_logradouro, :length => 30, :pad_byte => ' '
|
30
|
+
string :endereco_numero, :length => 5, :pad_byte => '0'
|
31
|
+
string :endereco_complemento, :length => 15, :pad_byte => ' '
|
32
|
+
string :endereco_cidade, :length => 20, :pad_byte => ' '
|
33
|
+
string :endereco_cep, :length => 5, :pad_byte => '0'
|
34
|
+
string :endereco_complemento_cep, :length => 3, :pad_byte => '0'
|
35
|
+
string :endereco_estado, :length => 2, :pad_byte => ' '
|
36
|
+
|
37
|
+
string :indicativo_forma_pagamento, :length => 2, :pad_byte => '0'
|
38
|
+
string :cnab_g004_2, :length => 6, :pad_byte => ' '
|
39
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def auto_fill
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Cnab240::PagamentosTributos
|
2
|
+
class Trailer < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :value => '5', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :cnab_g004_1, :length => 9, :pad_byte => '0'
|
11
|
+
string :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
12
|
+
string :totais_valor, :length => 18, :pad_byte => '0'
|
13
|
+
|
14
|
+
string :complemento, :length => 189, :pad_byte => ' '
|
15
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoJ < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'J', :pad_byte => ' '
|
12
|
+
string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
|
13
|
+
string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
|
14
|
+
|
15
|
+
string :codigo_barras, :length => 44, :pad_byte => ' '
|
16
|
+
string :nome_cedente, :length => 30, :pad_byte => ' '
|
17
|
+
string :data_vencimento, :length => 8, :pad_byte => '0'
|
18
|
+
string :valor_titulo, :length => 15, :pad_byte => '0'
|
19
|
+
string :valor_desconto_abatimento, :length => 15, :pad_byte => '0'
|
20
|
+
string :valor_mora_juros, :length => 15, :pad_byte => '0'
|
21
|
+
string :data_pagamento, :length => 8, :pad_byte => '0'
|
22
|
+
string :valor_pagamento, :length => 15, :pad_byte => '0'
|
23
|
+
string :quantidade_moeda, :length => 15, :pad_byte => '0'
|
24
|
+
string :referencia_sacado, :length => 20, :pad_byte => ' '
|
25
|
+
|
26
|
+
string :nosso_numero, :length => 20, :pad_byte => ' '
|
27
|
+
string :codigo_moeda, :length => 2, :pad_byte => '0'
|
28
|
+
|
29
|
+
string :cnab_g004_1, :length => 6, :pad_byte => ' '
|
30
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoJ52 < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'J', :pad_byte => ' '
|
12
|
+
string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
|
13
|
+
string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
|
14
|
+
|
15
|
+
string :cod_registro_opcional, :value => '52'
|
16
|
+
|
17
|
+
string :sacado_tipo_inscricao, :length => 1, :pad_byte => '0'
|
18
|
+
string :sacado_numero_inscricao, :length => 15, :pad_byte => '0'
|
19
|
+
string :sacado_nome, :length => 40, :pad_byte => ' '
|
20
|
+
|
21
|
+
string :cedente_tipo_inscricao, :length => 1, :pad_byte => '0'
|
22
|
+
string :cedente_numero_inscricao, :length => 15, :pad_byte => '0'
|
23
|
+
string :cedente_nome, :length => 40, :pad_byte => ' '
|
24
|
+
|
25
|
+
string :sacador_tipo_inscricao, :length => 1, :pad_byte => '0'
|
26
|
+
string :sacador_numero_inscricao, :length => 15, :pad_byte => '0'
|
27
|
+
string :sacador_nome, :length => 40, :pad_byte => ' '
|
28
|
+
|
29
|
+
|
30
|
+
string :cnab_g004_1, :length => 53, :pad_byte => ' '
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoN < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'N', :pad_byte => ' '
|
12
|
+
string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
|
13
|
+
string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
|
14
|
+
|
15
|
+
string :seu_numero, :length => 20, :pad_byte => ' '
|
16
|
+
string :nosso_numero, :length => 20, :pad_byte => ' '
|
17
|
+
string :contribuinte, :length => 30, :pad_byte => ' '
|
18
|
+
string :data_pagamento, :length => 8, :pad_byte => '0'
|
19
|
+
string :valor_pagamento, :length => 15, :pad_byte => '0'
|
20
|
+
|
21
|
+
string :informacoes_complementares, :length => 120, :pad_byte => ' '
|
22
|
+
|
23
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoO < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'O', :pad_byte => ' '
|
12
|
+
string :servico_tipo_movimento, :length => 1, :pad_byte => '0'
|
13
|
+
string :servico_codigo_movimento, :length => 2, :pad_byte => '0'
|
14
|
+
|
15
|
+
string :codigo_barras, :length => 44, :pad_byte => ' '
|
16
|
+
string :nome_concessionaria, :length => 30, :pad_byte => ' '
|
17
|
+
string :data_vencimento, :length => 8, :pad_byte => '0'
|
18
|
+
string :data_pagamento, :length => 8, :pad_byte => '0'
|
19
|
+
string :valor_pagamento, :length => 15, :pad_byte => '0'
|
20
|
+
string :seu_numero, :length => 20, :pad_byte => ' '
|
21
|
+
string :nosso_numero, :length => 20, :pad_byte => ' '
|
22
|
+
|
23
|
+
string :cnab_g004_1, :length => 68, :pad_byte => ' '
|
24
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoW < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'W', :pad_byte => ' '
|
12
|
+
string :complemento, :length => 1, :pad_byte => '0'
|
13
|
+
|
14
|
+
string :uso_informacoes_1_e_2, :length => 1, :pad_byte => ' '
|
15
|
+
string :informacao_1, :length => 80, :pad_byte => ' '
|
16
|
+
string :informacao_2, :length => 80, :pad_byte => ' '
|
17
|
+
|
18
|
+
segmento_w1 :w1
|
19
|
+
|
20
|
+
string :reservado, :length => 2, :pad_byte => ' '
|
21
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoW1 < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :identificador_tributo, :length => 2, :pad_byte => ' '
|
7
|
+
string :receita, :length => 6, :pad_byte => ' '
|
8
|
+
string :tipo_identificacao_contribuinte, :length => 2, :pad_byte => ' '
|
9
|
+
string :identificacao_contribuinte, :length => 14, :pad_byte => ' '
|
10
|
+
string :identificador_fgts, :length => 16, :pad_byte => ' '
|
11
|
+
string :lacre_conectividade, :length => 9, :pad_byte => ' '
|
12
|
+
string :digito_lacre_conectividade, :length => 2, :pad_byte => ' '
|
13
|
+
string :cnab_g004_1, :length => 1, :pad_byte => ' '
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class SegmentoZ < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
+
string :servico_codigo_segmento, :value => 'Z', :pad_byte => ' '
|
12
|
+
|
13
|
+
string :autenticacao, :length => 64, :pad_byte => ' '
|
14
|
+
string :controle_bancario, :length => 25, :pad_byte => ' '
|
15
|
+
string :cnab_g004_1, :length => 127, :pad_byte => ' '
|
16
|
+
string :ocorrencias, :length => 10, :pad_byte => ' '
|
17
|
+
end
|
18
|
+
end
|
data/lib/cnab240/version.rb
CHANGED
data/lib/cnab240.rb
CHANGED
@@ -11,6 +11,13 @@ require "cnab240/arquivo/lote"
|
|
11
11
|
require "cnab240/segmentos/segmento_a"
|
12
12
|
require "cnab240/segmentos/segmento_b"
|
13
13
|
require "cnab240/segmentos/segmento_c"
|
14
|
+
require "cnab240/segmentos/segmento_j"
|
15
|
+
require "cnab240/segmentos/segmento_j52"
|
16
|
+
require "cnab240/segmentos/segmento_o"
|
17
|
+
require "cnab240/segmentos/segmento_n"
|
18
|
+
require "cnab240/segmentos/segmento_w1"
|
19
|
+
require "cnab240/segmentos/segmento_w"
|
20
|
+
require "cnab240/segmentos/segmento_z"
|
14
21
|
|
15
22
|
require "cnab240/arquivo/arquivo"
|
16
23
|
require "cnab240/arquivo/header"
|
@@ -18,17 +25,15 @@ require "cnab240/arquivo/trailer"
|
|
18
25
|
|
19
26
|
require "cnab240/pagamentos/header"
|
20
27
|
require "cnab240/pagamentos/trailer"
|
28
|
+
require "cnab240/pagamentos/titulos/header"
|
29
|
+
require "cnab240/pagamentos/titulos/trailer"
|
30
|
+
require "cnab240/pagamentos/tributos/header"
|
31
|
+
require "cnab240/pagamentos/tributos/trailer"
|
21
32
|
|
33
|
+
require "cnab240/arquivo/estrutura"
|
22
34
|
|
23
|
-
module Cnab240
|
24
35
|
|
25
|
-
|
26
|
-
:pagamento => {
|
27
|
-
:header => Cnab240::Pagamentos::Header,
|
28
|
-
:trailer => Cnab240::Pagamentos::Trailer,
|
29
|
-
:segmentos => [:a, :b, :c]
|
30
|
-
}
|
31
|
-
}
|
36
|
+
module Cnab240
|
32
37
|
|
33
38
|
mod_attr_accessor :defaults
|
34
39
|
@@defaults = {}
|
@@ -15,7 +15,7 @@ describe Arquivo do
|
|
15
15
|
arquivo.should respond_to(:lotes)
|
16
16
|
|
17
17
|
(1..10).each do |n|
|
18
|
-
lote = Cnab240::Lote.new(:pagamento)
|
18
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
19
19
|
lote.should be_an_instance_of(Cnab240::Lote)
|
20
20
|
arquivo.lotes << lote
|
21
21
|
arquivo.lotes.length.should be(n)
|
@@ -27,7 +27,7 @@ describe Arquivo do
|
|
27
27
|
arquivo.should respond_to(:lotes)
|
28
28
|
|
29
29
|
(1..10).each do |n|
|
30
|
-
lote = Cnab240::Lote.new(:pagamento)
|
30
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
31
31
|
lote.should be_an_instance_of(Cnab240::Lote)
|
32
32
|
arquivo.lotes << lote
|
33
33
|
end
|
@@ -40,7 +40,7 @@ describe Arquivo do
|
|
40
40
|
it "deve ler e escrever em arquivo" do
|
41
41
|
arquivo = Cnab240::Arquivo::Arquivo.new
|
42
42
|
(1..10).each do |n|
|
43
|
-
arquivo.lotes << Cnab240::Lote.new(:pagamento)
|
43
|
+
arquivo.lotes << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
44
44
|
end
|
45
45
|
arquivo.save_to_file("spec/tmp/arquivo.test")
|
46
46
|
arquivo = Cnab240::Arquivo::Arquivo.load_from_file("spec/tmp/arquivo.test")
|
@@ -3,28 +3,29 @@ require 'spec_helper'
|
|
3
3
|
describe Cnab240::Lote do
|
4
4
|
|
5
5
|
it "deve conter trailer e header" do
|
6
|
-
lote = Cnab240::Lote.new(:pagamento)
|
6
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
7
7
|
lote.header.should be_an_instance_of(Cnab240::Pagamentos::Header)
|
8
8
|
lote.trailer.should be_an_instance_of(Cnab240::Pagamentos::Trailer)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "deve conter segmento a" do
|
12
|
-
lote = Cnab240::Lote.new(:pagamento)
|
12
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
13
13
|
lote.segmento_a.should be_an_instance_of(Cnab240::SegmentoA)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "deve conter segmento b" do
|
17
|
-
lote = Cnab240::Lote.new(:pagamento)
|
17
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
18
18
|
lote.segmento_b.should be_an_instance_of(Cnab240::SegmentoB)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "pode conter segmento c" do
|
22
|
-
lote = Cnab240::Lote.new(:pagamento)
|
22
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
23
|
+
lote << :c
|
23
24
|
lote.should respond_to(:segmento_c)
|
24
25
|
end
|
25
26
|
|
26
27
|
it "linhas devem ter 240" do
|
27
|
-
lote = Cnab240::Lote.new(:pagamento)
|
28
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
28
29
|
lote.linhas.each do |linha|
|
29
30
|
linha.length.should be(240)
|
30
31
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::PagamentosTitulos::Header do
|
4
|
+
|
5
|
+
it "deve conter campos header" do
|
6
|
+
header = Cnab240::PagamentosTitulos::Header.new
|
7
|
+
|
8
|
+
header.should respond_to(:controle_banco)
|
9
|
+
header.should respond_to(:controle_lote)
|
10
|
+
header.should respond_to(:controle_registro)
|
11
|
+
|
12
|
+
header.should respond_to(:servico_operacao)
|
13
|
+
header.should respond_to(:servico_tipo)
|
14
|
+
header.should respond_to(:servico_forma)
|
15
|
+
header.should respond_to(:servico_layout)
|
16
|
+
|
17
|
+
header.should respond_to(:cnab_g004_1)
|
18
|
+
|
19
|
+
header.should respond_to(:empresa_tipo)
|
20
|
+
header.should respond_to(:empresa_numero)
|
21
|
+
header.should respond_to(:empresa_convenio)
|
22
|
+
header.should respond_to(:empresa_agencia_codigo)
|
23
|
+
header.should respond_to(:empresa_agencia_dv)
|
24
|
+
header.should respond_to(:empresa_conta_numero)
|
25
|
+
header.should respond_to(:empresa_conta_dv)
|
26
|
+
header.should respond_to(:empresa_agencia_conta_dv)
|
27
|
+
header.should respond_to(:empresa_nome)
|
28
|
+
|
29
|
+
header.should respond_to(:informacao_1)
|
30
|
+
|
31
|
+
header.should respond_to(:endereco_logradouro)
|
32
|
+
header.should respond_to(:endereco_numero)
|
33
|
+
header.should respond_to(:endereco_complemento)
|
34
|
+
header.should respond_to(:endereco_cidade)
|
35
|
+
header.should respond_to(:endereco_cep)
|
36
|
+
header.should respond_to(:endereco_complemento_cep)
|
37
|
+
header.should respond_to(:endereco_estado)
|
38
|
+
|
39
|
+
header.should respond_to(:cnab_g004_2)
|
40
|
+
|
41
|
+
header.should respond_to(:ocorrencias)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
it "header deve ter 240 caracteres" do
|
47
|
+
header = Cnab240::PagamentosTitulos::Header.new
|
48
|
+
header.linha.length.should be(240)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::Lote do
|
4
|
+
|
5
|
+
it "deve conter trailer e header" do
|
6
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
7
|
+
lote.header.should be_an_instance_of(Cnab240::Pagamentos::Header)
|
8
|
+
lote.trailer.should be_an_instance_of(Cnab240::Pagamentos::Trailer)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "deve conter segmento a" do
|
12
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
13
|
+
lote.segmento_a.should be_an_instance_of(Cnab240::SegmentoA)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "deve conter segmento b" do
|
17
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
18
|
+
lote.segmento_b.should be_an_instance_of(Cnab240::SegmentoB)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "pode conter segmento c" do
|
22
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
23
|
+
lote << :c
|
24
|
+
lote.should respond_to(:segmento_c)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "linhas devem ter 240" do
|
28
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
29
|
+
lote.linhas.each do |linha|
|
30
|
+
linha.length.should be(240)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::PagamentosTitulos::Trailer do
|
4
|
+
|
5
|
+
it "deve conter campos trailer" do
|
6
|
+
trailer = Cnab240::PagamentosTitulos::Trailer.new
|
7
|
+
|
8
|
+
trailer.should respond_to(:controle_banco)
|
9
|
+
trailer.should respond_to(:controle_lote)
|
10
|
+
trailer.should respond_to(:controle_registro)
|
11
|
+
|
12
|
+
trailer.should respond_to(:cnab_g004_1)
|
13
|
+
|
14
|
+
trailer.should respond_to(:totais_qtde_registros)
|
15
|
+
trailer.should respond_to(:totais_valor)
|
16
|
+
trailer.should respond_to(:totais_qtde_moeda)
|
17
|
+
|
18
|
+
trailer.should respond_to(:numero_aviso_debito)
|
19
|
+
|
20
|
+
trailer.should respond_to(:cnab_g004_2)
|
21
|
+
|
22
|
+
trailer.should respond_to(:ocorrencias)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "trailer deve ter 240 caracteres" do
|
26
|
+
trailer = Cnab240::PagamentosTitulos::Trailer.new
|
27
|
+
trailer.linha.length.should be(240)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::PagamentosTributos::Header do
|
4
|
+
|
5
|
+
it "deve conter campos header" do
|
6
|
+
header = Cnab240::PagamentosTributos::Header.new
|
7
|
+
|
8
|
+
header.should respond_to(:controle_banco)
|
9
|
+
header.should respond_to(:controle_lote)
|
10
|
+
header.should respond_to(:controle_registro)
|
11
|
+
|
12
|
+
header.should respond_to(:servico_operacao)
|
13
|
+
header.should respond_to(:servico_tipo)
|
14
|
+
header.should respond_to(:servico_forma)
|
15
|
+
header.should respond_to(:servico_layout)
|
16
|
+
|
17
|
+
header.should respond_to(:cnab_g004_1)
|
18
|
+
|
19
|
+
header.should respond_to(:empresa_tipo)
|
20
|
+
header.should respond_to(:empresa_numero)
|
21
|
+
header.should respond_to(:empresa_convenio)
|
22
|
+
header.should respond_to(:empresa_agencia_codigo)
|
23
|
+
header.should respond_to(:empresa_agencia_dv)
|
24
|
+
header.should respond_to(:empresa_conta_numero)
|
25
|
+
header.should respond_to(:empresa_conta_dv)
|
26
|
+
header.should respond_to(:empresa_agencia_conta_dv)
|
27
|
+
header.should respond_to(:empresa_nome)
|
28
|
+
|
29
|
+
header.should respond_to(:informacao_1)
|
30
|
+
|
31
|
+
header.should respond_to(:endereco_logradouro)
|
32
|
+
header.should respond_to(:endereco_numero)
|
33
|
+
header.should respond_to(:endereco_complemento)
|
34
|
+
header.should respond_to(:endereco_cidade)
|
35
|
+
header.should respond_to(:endereco_cep)
|
36
|
+
header.should respond_to(:endereco_complemento_cep)
|
37
|
+
header.should respond_to(:endereco_estado)
|
38
|
+
|
39
|
+
header.should respond_to(:indicativo_forma_pagamento)
|
40
|
+
|
41
|
+
header.should respond_to(:cnab_g004_2)
|
42
|
+
|
43
|
+
header.should respond_to(:ocorrencias)
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
it "header deve ter 240 caracteres" do
|
49
|
+
header = Cnab240::PagamentosTributos::Header.new
|
50
|
+
header.linha.length.should be(240)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::Lote do
|
4
|
+
|
5
|
+
it "deve conter trailer e header" do
|
6
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
7
|
+
lote.header.should be_an_instance_of(Cnab240::PagamentosTributos::Header)
|
8
|
+
lote.trailer.should be_an_instance_of(Cnab240::PagamentosTributos::Trailer)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "deve conter segmento o" do
|
12
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
13
|
+
lote.segmento_o.should be_an_instance_of(Cnab240::SegmentoO)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "deve conter segmento n" do
|
17
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
18
|
+
lote.segmento_n.should be_an_instance_of(Cnab240::SegmentoN)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "pode conter segmento w" do
|
22
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
23
|
+
lote << :w
|
24
|
+
lote.should respond_to(:segmento_w)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "pode conter segmento z" do
|
28
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
29
|
+
lote << :z
|
30
|
+
lote.should respond_to(:segmento_z)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "linhas devem ter 240" do
|
34
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa)
|
35
|
+
lote.linhas.each do |linha|
|
36
|
+
linha.length.should be(240)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cnab240::PagamentosTributos::Trailer do
|
4
|
+
|
5
|
+
it "deve conter campos trailer" do
|
6
|
+
trailer = Cnab240::PagamentosTributos::Trailer.new
|
7
|
+
|
8
|
+
trailer.should respond_to(:controle_banco)
|
9
|
+
trailer.should respond_to(:controle_lote)
|
10
|
+
trailer.should respond_to(:controle_registro)
|
11
|
+
|
12
|
+
trailer.should respond_to(:cnab_g004_1)
|
13
|
+
|
14
|
+
trailer.should respond_to(:totais_qtde_registros)
|
15
|
+
trailer.should respond_to(:totais_valor)
|
16
|
+
|
17
|
+
trailer.should respond_to(:complemento)
|
18
|
+
|
19
|
+
trailer.should respond_to(:ocorrencias)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "trailer deve ter 240 caracteres" do
|
23
|
+
trailer = Cnab240::PagamentosTributos::Trailer.new
|
24
|
+
trailer.linha.length.should be(240)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoJ52 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoJ52.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoJ52)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoJ52.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
segmento.should respond_to(:servico_tipo_movimento)
|
22
|
+
segmento.should respond_to(:servico_codigo_movimento)
|
23
|
+
|
24
|
+
segmento.should respond_to(:cod_registro_opcional)
|
25
|
+
|
26
|
+
segmento.should respond_to(:sacado_tipo_inscricao)
|
27
|
+
segmento.should respond_to(:sacado_numero_inscricao)
|
28
|
+
segmento.should respond_to(:sacado_nome)
|
29
|
+
|
30
|
+
segmento.should respond_to(:cedente_tipo_inscricao)
|
31
|
+
segmento.should respond_to(:cedente_numero_inscricao)
|
32
|
+
segmento.should respond_to(:cedente_nome)
|
33
|
+
|
34
|
+
segmento.should respond_to(:sacador_tipo_inscricao)
|
35
|
+
segmento.should respond_to(:sacador_numero_inscricao)
|
36
|
+
segmento.should respond_to(:sacador_nome)
|
37
|
+
|
38
|
+
segmento.should respond_to(:cnab_g004_1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "deve ter 240 caracteres" do
|
42
|
+
segmento = SegmentoJ52.new
|
43
|
+
segmento.linha.length.should be(240)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoJ do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoJ.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoJ)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoJ.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
segmento.should respond_to(:servico_tipo_movimento)
|
22
|
+
segmento.should respond_to(:servico_codigo_movimento)
|
23
|
+
|
24
|
+
segmento.should respond_to(:codigo_barras)
|
25
|
+
segmento.should respond_to(:nome_cedente)
|
26
|
+
segmento.should respond_to(:data_vencimento)
|
27
|
+
segmento.should respond_to(:valor_titulo)
|
28
|
+
segmento.should respond_to(:valor_desconto_abatimento)
|
29
|
+
segmento.should respond_to(:valor_mora_juros)
|
30
|
+
segmento.should respond_to(:data_pagamento)
|
31
|
+
segmento.should respond_to(:quantidade_moeda)
|
32
|
+
segmento.should respond_to(:referencia_sacado)
|
33
|
+
|
34
|
+
segmento.should respond_to(:nosso_numero)
|
35
|
+
segmento.should respond_to(:codigo_moeda)
|
36
|
+
|
37
|
+
segmento.should respond_to(:cnab_g004_1)
|
38
|
+
segmento.should respond_to(:ocorrencias)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "deve ter 240 caracteres" do
|
42
|
+
segmento = SegmentoJ.new
|
43
|
+
segmento.linha.length.should be(240)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
segmento.should respond_to(:servico_tipo_movimento)
|
22
|
+
segmento.should respond_to(:servico_codigo_movimento)
|
23
|
+
|
24
|
+
segmento.should respond_to(:nosso_numero)
|
25
|
+
segmento.should respond_to(:contribuinte)
|
26
|
+
segmento.should respond_to(:data_pagamento)
|
27
|
+
segmento.should respond_to(:valor_pagamento)
|
28
|
+
|
29
|
+
segmento.should respond_to(:informacoes_complementares)
|
30
|
+
|
31
|
+
segmento.should respond_to(:ocorrencias)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "deve ter 240 caracteres" do
|
35
|
+
segmento = SegmentoN.new
|
36
|
+
segmento.linha.length.should be(240)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoO do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoO.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoO)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoO.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
segmento.should respond_to(:servico_tipo_movimento)
|
22
|
+
segmento.should respond_to(:servico_codigo_movimento)
|
23
|
+
|
24
|
+
segmento.should respond_to(:codigo_barras)
|
25
|
+
segmento.should respond_to(:nome_concessionaria)
|
26
|
+
segmento.should respond_to(:data_vencimento)
|
27
|
+
segmento.should respond_to(:data_pagamento)
|
28
|
+
segmento.should respond_to(:valor_pagamento)
|
29
|
+
segmento.should respond_to(:seu_numero)
|
30
|
+
segmento.should respond_to(:nosso_numero)
|
31
|
+
|
32
|
+
segmento.should respond_to(:cnab_g004_1)
|
33
|
+
segmento.should respond_to(:ocorrencias)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "deve ter 240 caracteres" do
|
37
|
+
segmento = SegmentoO.new
|
38
|
+
segmento.linha.length.should be(240)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoW do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoW.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoW)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoW.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
|
22
|
+
|
23
|
+
segmento.should respond_to(:complemento)
|
24
|
+
|
25
|
+
segmento.should respond_to(:uso_informacoes_1_e_2)
|
26
|
+
segmento.should respond_to(:informacao_1)
|
27
|
+
segmento.should respond_to(:informacao_2)
|
28
|
+
|
29
|
+
segmento.should respond_to(:w1)
|
30
|
+
|
31
|
+
segmento.should respond_to(:reservado)
|
32
|
+
segmento.should respond_to(:ocorrencias)
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deve ter 240 caracteres" do
|
38
|
+
segmento = SegmentoW.new
|
39
|
+
segmento.linha.length.should be(240)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoZ do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoZ.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoZ)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoZ.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:controle_banco)
|
16
|
+
segmento.should respond_to(:controle_lote)
|
17
|
+
segmento.should respond_to(:controle_registro)
|
18
|
+
|
19
|
+
segmento.should respond_to(:servico_numero_registro)
|
20
|
+
segmento.should respond_to(:servico_codigo_segmento)
|
21
|
+
|
22
|
+
segmento.should respond_to(:autenticacao)
|
23
|
+
segmento.should respond_to(:controle_bancario)
|
24
|
+
segmento.should respond_to(:cnab_g004_1)
|
25
|
+
segmento.should respond_to(:ocorrencias)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "deve ter 240 caracteres" do
|
29
|
+
segmento = SegmentoZ.new
|
30
|
+
segmento.linha.length.should be(240)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnab240
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- cnab240.gemspec
|
61
61
|
- lib/cnab240.rb
|
62
62
|
- lib/cnab240/arquivo/arquivo.rb
|
63
|
+
- lib/cnab240/arquivo/estrutura.rb
|
63
64
|
- lib/cnab240/arquivo/header.rb
|
64
65
|
- lib/cnab240/arquivo/lote.rb
|
65
66
|
- lib/cnab240/arquivo/trailer.rb
|
@@ -67,10 +68,21 @@ files:
|
|
67
68
|
- lib/cnab240/core_ext/bindata.rb
|
68
69
|
- lib/cnab240/core_ext/default_mixin.rb
|
69
70
|
- lib/cnab240/pagamentos/header.rb
|
71
|
+
- lib/cnab240/pagamentos/titulos/header.rb
|
72
|
+
- lib/cnab240/pagamentos/titulos/trailer.rb
|
70
73
|
- lib/cnab240/pagamentos/trailer.rb
|
74
|
+
- lib/cnab240/pagamentos/tributos/header.rb
|
75
|
+
- lib/cnab240/pagamentos/tributos/trailer.rb
|
71
76
|
- lib/cnab240/segmentos/segmento_a.rb
|
72
77
|
- lib/cnab240/segmentos/segmento_b.rb
|
73
78
|
- lib/cnab240/segmentos/segmento_c.rb
|
79
|
+
- lib/cnab240/segmentos/segmento_j.rb
|
80
|
+
- lib/cnab240/segmentos/segmento_j52.rb
|
81
|
+
- lib/cnab240/segmentos/segmento_n.rb
|
82
|
+
- lib/cnab240/segmentos/segmento_o.rb
|
83
|
+
- lib/cnab240/segmentos/segmento_w.rb
|
84
|
+
- lib/cnab240/segmentos/segmento_w1.rb
|
85
|
+
- lib/cnab240/segmentos/segmento_z.rb
|
74
86
|
- lib/cnab240/version.rb
|
75
87
|
- spec/arquivo/arquivo_spec.rb
|
76
88
|
- spec/arquivo/header_spec.rb
|
@@ -78,11 +90,24 @@ files:
|
|
78
90
|
- spec/cnab240_spec.rb
|
79
91
|
- spec/pagamentos/header_spec.rb
|
80
92
|
- spec/pagamentos/lote_spec.rb
|
93
|
+
- spec/pagamentos/titulos/header_spec.rb
|
94
|
+
- spec/pagamentos/titulos/lote_spec.rb
|
95
|
+
- spec/pagamentos/titulos/trailer_spec.rb
|
81
96
|
- spec/pagamentos/trailer_spec.rb
|
97
|
+
- spec/pagamentos/tributos/header_spec.rb
|
98
|
+
- spec/pagamentos/tributos/lote_spec.rb
|
99
|
+
- spec/pagamentos/tributos/trailer_spec.rb
|
82
100
|
- spec/segmentos/segmento_a_spec.rb
|
83
101
|
- spec/segmentos/segmento_b_spec.rb
|
84
102
|
- spec/segmentos/segmento_c_spec.rb
|
103
|
+
- spec/segmentos/segmento_j52_spec.rb
|
104
|
+
- spec/segmentos/segmento_j_spec.rb
|
105
|
+
- spec/segmentos/segmento_n_spec.rb
|
106
|
+
- spec/segmentos/segmento_o_spec.rb
|
107
|
+
- spec/segmentos/segmento_w_spec.rb
|
108
|
+
- spec/segmentos/segmento_z_spec.rb
|
85
109
|
- spec/spec_helper.rb
|
110
|
+
- spec/tmp/.gitkeep
|
86
111
|
homepage: ''
|
87
112
|
licenses: []
|
88
113
|
post_install_message:
|
@@ -97,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
122
|
version: '0'
|
98
123
|
segments:
|
99
124
|
- 0
|
100
|
-
hash:
|
125
|
+
hash: 997177440327526809
|
101
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
127
|
none: false
|
103
128
|
requirements:
|
@@ -106,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
131
|
version: '0'
|
107
132
|
segments:
|
108
133
|
- 0
|
109
|
-
hash:
|
134
|
+
hash: 997177440327526809
|
110
135
|
requirements: []
|
111
136
|
rubyforge_project: cnab240
|
112
137
|
rubygems_version: 1.8.24
|
@@ -120,8 +145,21 @@ test_files:
|
|
120
145
|
- spec/cnab240_spec.rb
|
121
146
|
- spec/pagamentos/header_spec.rb
|
122
147
|
- spec/pagamentos/lote_spec.rb
|
148
|
+
- spec/pagamentos/titulos/header_spec.rb
|
149
|
+
- spec/pagamentos/titulos/lote_spec.rb
|
150
|
+
- spec/pagamentos/titulos/trailer_spec.rb
|
123
151
|
- spec/pagamentos/trailer_spec.rb
|
152
|
+
- spec/pagamentos/tributos/header_spec.rb
|
153
|
+
- spec/pagamentos/tributos/lote_spec.rb
|
154
|
+
- spec/pagamentos/tributos/trailer_spec.rb
|
124
155
|
- spec/segmentos/segmento_a_spec.rb
|
125
156
|
- spec/segmentos/segmento_b_spec.rb
|
126
157
|
- spec/segmentos/segmento_c_spec.rb
|
158
|
+
- spec/segmentos/segmento_j52_spec.rb
|
159
|
+
- spec/segmentos/segmento_j_spec.rb
|
160
|
+
- spec/segmentos/segmento_n_spec.rb
|
161
|
+
- spec/segmentos/segmento_o_spec.rb
|
162
|
+
- spec/segmentos/segmento_w_spec.rb
|
163
|
+
- spec/segmentos/segmento_z_spec.rb
|
127
164
|
- spec/spec_helper.rb
|
165
|
+
- spec/tmp/.gitkeep
|