cnab240 0.0.4 → 0.0.5
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/lib/cnab240/arquivo/arquivo.rb +34 -9
- data/lib/cnab240/arquivo/estrutura.rb +1 -0
- data/lib/cnab240/arquivo/header.rb +5 -5
- data/lib/cnab240/arquivo/lote.rb +15 -4
- data/lib/cnab240/arquivo/trailer.rb +2 -2
- data/lib/cnab240/{core_ext → ext}/bindata.rb +1 -1
- data/lib/cnab240/{core_ext → ext}/default_mixin.rb +1 -0
- data/lib/cnab240/ext/segmento_mixin.rb +7 -0
- data/lib/cnab240/pagamentos/header.rb +2 -2
- data/lib/cnab240/pagamentos/titulos/header.rb +2 -2
- data/lib/cnab240/pagamentos/titulos/trailer.rb +1 -1
- data/lib/cnab240/pagamentos/trailer.rb +1 -1
- data/lib/cnab240/pagamentos/tributos/header.rb +2 -2
- data/lib/cnab240/pagamentos/tributos/trailer.rb +1 -1
- data/lib/cnab240/segmentos/segmento_a.rb +2 -1
- data/lib/cnab240/segmentos/segmento_b.rb +2 -1
- data/lib/cnab240/segmentos/segmento_c.rb +2 -1
- data/lib/cnab240/segmentos/segmento_j.rb +2 -1
- data/lib/cnab240/segmentos/segmento_j52.rb +3 -2
- data/lib/cnab240/segmentos/segmento_n.rb +37 -3
- data/lib/cnab240/segmentos/segmento_n1.rb +21 -0
- data/lib/cnab240/segmentos/segmento_n2.rb +23 -0
- data/lib/cnab240/segmentos/segmento_n3.rb +23 -0
- data/lib/cnab240/segmentos/segmento_n4.rb +25 -0
- data/lib/cnab240/segmentos/segmento_n5.rb +23 -0
- data/lib/cnab240/segmentos/segmento_n6.rb +23 -0
- data/lib/cnab240/segmentos/segmento_n7.rb +23 -0
- data/lib/cnab240/segmentos/segmento_n8.rb +25 -0
- data/lib/cnab240/segmentos/segmento_o.rb +2 -1
- data/lib/cnab240/segmentos/segmento_w.rb +2 -1
- data/lib/cnab240/segmentos/segmento_w1.rb +1 -0
- data/lib/cnab240/segmentos/segmento_z.rb +2 -1
- data/lib/cnab240/version.rb +1 -1
- data/lib/cnab240.rb +12 -3
- data/spec/arquivo/arquivo_spec.rb +29 -2
- data/spec/arquivo/header_spec.rb +43 -0
- data/spec/bindata/bindata_spec.rb +40 -0
- data/spec/segmentos/segmento_a_spec.rb +9 -0
- data/spec/segmentos/segmento_b_spec.rb +9 -0
- data/spec/segmentos/segmento_c_spec.rb +9 -0
- data/spec/segmentos/segmento_j52_spec.rb +9 -0
- data/spec/segmentos/segmento_j_spec.rb +9 -0
- data/spec/segmentos/segmento_n1_spec.rb +43 -0
- data/spec/segmentos/segmento_n2_spec.rb +46 -0
- data/spec/segmentos/segmento_n3_spec.rb +45 -0
- data/spec/segmentos/segmento_n4_spec.rb +47 -0
- data/spec/segmentos/segmento_n5_spec.rb +45 -0
- data/spec/segmentos/segmento_n6_spec.rb +45 -0
- data/spec/segmentos/segmento_n7_spec.rb +46 -0
- data/spec/segmentos/segmento_n8_spec.rb +45 -0
- data/spec/segmentos/segmento_n_spec.rb +34 -1
- data/spec/segmentos/segmento_o_spec.rb +9 -0
- data/spec/segmentos/segmento_spec.rb +12 -0
- data/spec/segmentos/segmento_w_spec.rb +9 -0
- data/spec/segmentos/segmento_z_spec.rb +9 -0
- metadata +36 -7
- /data/lib/cnab240/{core_ext → ext}/attribute_accessors.rb +0 -0
@@ -2,13 +2,14 @@ module Cnab240
|
|
2
2
|
class SegmentoZ < BinData::Record
|
3
3
|
|
4
4
|
include Cnab240::DefaultMixin
|
5
|
+
include Cnab240::SegmentoMixin
|
5
6
|
|
6
7
|
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
8
|
string :controle_lote, :length => 4, :pad_byte => '0'
|
8
9
|
string :controle_registro, :length => 1, :initial_value => '3', :pad_byte => '0'
|
9
10
|
|
10
11
|
string :servico_numero_registro, :length => 5, :pad_byte => '0'
|
11
|
-
string :servico_codigo_segmento, :
|
12
|
+
string :servico_codigo_segmento, :length => 1, :initial_value => 'Z', :pad_byte => ' '
|
12
13
|
|
13
14
|
string :autenticacao, :length => 64, :pad_byte => ' '
|
14
15
|
string :controle_bancario, :length => 25, :pad_byte => ' '
|
data/lib/cnab240/version.rb
CHANGED
data/lib/cnab240.rb
CHANGED
@@ -2,9 +2,10 @@ require "cnab240/version"
|
|
2
2
|
|
3
3
|
require 'bindata'
|
4
4
|
|
5
|
-
require "cnab240/
|
6
|
-
require "cnab240/
|
7
|
-
require "cnab240/
|
5
|
+
require "cnab240/ext/attribute_accessors"
|
6
|
+
require "cnab240/ext/bindata"
|
7
|
+
require "cnab240/ext/default_mixin"
|
8
|
+
require "cnab240/ext/segmento_mixin"
|
8
9
|
|
9
10
|
require "cnab240/arquivo/lote"
|
10
11
|
|
@@ -14,6 +15,14 @@ require "cnab240/segmentos/segmento_c"
|
|
14
15
|
require "cnab240/segmentos/segmento_j"
|
15
16
|
require "cnab240/segmentos/segmento_j52"
|
16
17
|
require "cnab240/segmentos/segmento_o"
|
18
|
+
require "cnab240/segmentos/segmento_n8"
|
19
|
+
require "cnab240/segmentos/segmento_n7"
|
20
|
+
require "cnab240/segmentos/segmento_n6"
|
21
|
+
require "cnab240/segmentos/segmento_n5"
|
22
|
+
require "cnab240/segmentos/segmento_n4"
|
23
|
+
require "cnab240/segmentos/segmento_n3"
|
24
|
+
require "cnab240/segmentos/segmento_n2"
|
25
|
+
require "cnab240/segmentos/segmento_n1"
|
17
26
|
require "cnab240/segmentos/segmento_n"
|
18
27
|
require "cnab240/segmentos/segmento_w1"
|
19
28
|
require "cnab240/segmentos/segmento_w"
|
@@ -37,13 +37,40 @@ describe Arquivo do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it "deve ler e escrever
|
40
|
+
it "deve ler e escrever, mantendo classe de lote" do
|
41
41
|
arquivo = Cnab240::Arquivo::Arquivo.new
|
42
42
|
(1..10).each do |n|
|
43
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
|
+
|
47
|
+
arquivo_read = Cnab240::Arquivo::Arquivo.load_from_file("spec/tmp/arquivo.test")[0]
|
48
|
+
|
49
|
+
arquivo_read.lotes.length.should be 10
|
50
|
+
|
51
|
+
arquivo_read.lotes.each_with_index do |lote_read, i|
|
52
|
+
lote_read.header.servico_operacao.should eq arquivo.lotes[i].header.servico_operacao
|
53
|
+
lote_read.should be_an_instance_of(arquivo.lotes[i].class)
|
54
|
+
lote_read.segmentos.length.should be arquivo.lotes[i].segmentos.length
|
55
|
+
end
|
47
56
|
end
|
48
57
|
|
58
|
+
it "arquivos devem ser identicos" do
|
59
|
+
arquivo = Cnab240::Arquivo::Arquivo.new
|
60
|
+
(1..10).each do |n|
|
61
|
+
arquivo.lotes << Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa)
|
62
|
+
end
|
63
|
+
arquivo.save_to_file("spec/tmp/arquivo.test")
|
64
|
+
|
65
|
+
arquivo_read = Cnab240::Arquivo::Arquivo.load_from_file("spec/tmp/arquivo.test")[0]
|
66
|
+
|
67
|
+
header_r = arquivo_read.header
|
68
|
+
header = arquivo.header
|
69
|
+
|
70
|
+
arquivo_read.header.linha.should eq arquivo.header.linha
|
71
|
+
arquivo_read.trailer.linha.should eq arquivo.trailer.linha
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
49
76
|
end
|
data/spec/arquivo/header_spec.rb
CHANGED
@@ -43,4 +43,47 @@ describe Cnab240::Arquivo::Header do
|
|
43
43
|
header = Cnab240::Arquivo::Header.new
|
44
44
|
header.linha.length.should be(240)
|
45
45
|
end
|
46
|
+
|
47
|
+
it "conversao deve manter consistencia" do
|
48
|
+
header = Cnab240::Arquivo::Header.new
|
49
|
+
|
50
|
+
header.controle_banco= "8"
|
51
|
+
header.controle_lote= "8"
|
52
|
+
header.controle_registro= "8"
|
53
|
+
|
54
|
+
header.cnab_g004_1= "8"
|
55
|
+
|
56
|
+
header.empresa_tipo= "8"
|
57
|
+
header.empresa_numero= "8"
|
58
|
+
header.empresa_convenio= "8"
|
59
|
+
header.empresa_agencia_codigo= "8"
|
60
|
+
header.empresa_agencia_dv= "8"
|
61
|
+
header.empresa_conta_numero= "8"
|
62
|
+
header.empresa_conta_dv= "8"
|
63
|
+
header.empresa_agencia_conta_dv= "8"
|
64
|
+
header.empresa_nome= "8"
|
65
|
+
|
66
|
+
header.banco_nome= "8"
|
67
|
+
|
68
|
+
header.cnab_g004_2= "8"
|
69
|
+
|
70
|
+
header.arquivo_codigo= "8"
|
71
|
+
header.arquivo_data_geracao= "8"
|
72
|
+
header.arquivo_hora_geracao= "8"
|
73
|
+
header.arquivo_sequencia= "8"
|
74
|
+
header.arquivo_layout= "8"
|
75
|
+
header.arquivo_densidade= "8"
|
76
|
+
|
77
|
+
header.reservado_banco= "8"
|
78
|
+
header.reservado_empresa= "8"
|
79
|
+
|
80
|
+
header.cnab_g004_3= "8"
|
81
|
+
|
82
|
+
linha1 = header.linha
|
83
|
+
|
84
|
+
header2 = Cnab240::Arquivo::Header.read(linha1)
|
85
|
+
linha2 = header2.linha
|
86
|
+
|
87
|
+
linha1.should eq linha2
|
88
|
+
end
|
46
89
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Bindata" do
|
4
|
+
|
5
|
+
it "should work" do
|
6
|
+
class Dummy < BinData::Record
|
7
|
+
string :f1, :length => 3, :pad_byte => '1'
|
8
|
+
string :f2, :length => 4, :initial_value => '0000', :pad_byte => '0'
|
9
|
+
string :f3, :length => 9, :pad_byte => 'X'
|
10
|
+
end
|
11
|
+
|
12
|
+
d1 = Dummy.new
|
13
|
+
s1 = StringIO.new
|
14
|
+
d1.write(s1)
|
15
|
+
|
16
|
+
d2 = Dummy.read(s1.string)
|
17
|
+
s2 = StringIO.new
|
18
|
+
d2.write(s2)
|
19
|
+
|
20
|
+
s1.string.should eq s2.string
|
21
|
+
|
22
|
+
class Dummy2 < BinData::Record
|
23
|
+
string :f1, :length => 3, :pad_byte => '1'
|
24
|
+
string :f2, :value => '0000', :pad_byte => '0'
|
25
|
+
string :f3, :length => 9, :pad_byte => 'X'
|
26
|
+
end
|
27
|
+
|
28
|
+
d1 = Dummy2.new
|
29
|
+
s1 = StringIO.new
|
30
|
+
d1.write(s1)
|
31
|
+
|
32
|
+
d2 = Dummy2.read(s1.string)
|
33
|
+
s2 = StringIO.new
|
34
|
+
d2.write(s2)
|
35
|
+
|
36
|
+
# s1.string.should eq s2.string # TODO: Fix bindata
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
@@ -53,4 +53,13 @@ describe SegmentoA do
|
|
53
53
|
segmento.linha.length.should be(240)
|
54
54
|
end
|
55
55
|
|
56
|
+
it "deve manter coesao" do
|
57
|
+
c = Cnab240::SegmentoA
|
58
|
+
obj = c.new
|
59
|
+
linha1 = obj.linha
|
60
|
+
obj2 = c.read(linha1)
|
61
|
+
linha2 = obj2.linha
|
62
|
+
linha1.should eq linha2
|
63
|
+
end
|
64
|
+
|
56
65
|
end
|
@@ -55,4 +55,13 @@ describe SegmentoB do
|
|
55
55
|
segmento.linha.length.should be(240)
|
56
56
|
end
|
57
57
|
|
58
|
+
it "deve manter coesao" do
|
59
|
+
c = Cnab240::SegmentoB
|
60
|
+
obj = c.new
|
61
|
+
linha1 = obj.linha
|
62
|
+
obj2 = c.read(linha1)
|
63
|
+
linha2 = obj2.linha
|
64
|
+
linha1.should eq linha2
|
65
|
+
end
|
66
|
+
|
58
67
|
end
|
@@ -39,4 +39,13 @@ describe SegmentoC do
|
|
39
39
|
segmento.linha.length.should be(240)
|
40
40
|
end
|
41
41
|
|
42
|
+
it "deve manter coesao" do
|
43
|
+
c = Cnab240::SegmentoC
|
44
|
+
obj = c.new
|
45
|
+
linha1 = obj.linha
|
46
|
+
obj2 = c.read(linha1)
|
47
|
+
linha2 = obj2.linha
|
48
|
+
linha1.should eq linha2
|
49
|
+
end
|
50
|
+
|
42
51
|
end
|
@@ -43,4 +43,13 @@ describe SegmentoJ52 do
|
|
43
43
|
segmento.linha.length.should be(240)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "deve manter coesao" do
|
47
|
+
c = Cnab240::SegmentoJ52
|
48
|
+
obj = c.new
|
49
|
+
linha1 = obj.linha
|
50
|
+
obj2 = c.read(linha1)
|
51
|
+
linha2 = obj2.linha
|
52
|
+
linha1.should eq linha2
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
@@ -43,4 +43,13 @@ describe SegmentoJ do
|
|
43
43
|
segmento.linha.length.should be(240)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "deve manter coesao" do
|
47
|
+
c = Cnab240::SegmentoJ
|
48
|
+
obj = c.new
|
49
|
+
linha1 = obj.linha
|
50
|
+
obj2 = c.read(linha1)
|
51
|
+
linha2 = obj2.linha
|
52
|
+
linha1.should eq linha2
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN1 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN1.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN1)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN1.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:mes_ano_competencia)
|
21
|
+
segmento.should respond_to(:valor_tributo)
|
22
|
+
segmento.should respond_to(:valor_outras_entidades)
|
23
|
+
segmento.should respond_to(:atualizacao_monetaria)
|
24
|
+
|
25
|
+
segmento.should respond_to(:cnab)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
it "deve ter 120 caracteres" do
|
30
|
+
segmento = SegmentoN1.new
|
31
|
+
segmento.linha.length.should be(120)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "deve manter coesao" do
|
35
|
+
c = Cnab240::SegmentoN1
|
36
|
+
obj = c.new
|
37
|
+
linha1 = obj.linha
|
38
|
+
obj2 = c.read(linha1)
|
39
|
+
linha2 = obj2.linha
|
40
|
+
linha1.should eq linha2
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN2 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN2.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN2)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN2.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:periodo_apuracao)
|
21
|
+
segmento.should respond_to(:numero_referencia)
|
22
|
+
segmento.should respond_to(:valor_principal)
|
23
|
+
segmento.should respond_to(:valor_multa)
|
24
|
+
segmento.should respond_to(:valor_juros_encargos)
|
25
|
+
segmento.should respond_to(:data_vencimento)
|
26
|
+
|
27
|
+
|
28
|
+
segmento.should respond_to(:cnab)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "deve ter 120 caracteres" do
|
33
|
+
segmento = SegmentoN2.new
|
34
|
+
segmento.linha.length.should be(120)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deve manter coesao" do
|
38
|
+
c = Cnab240::SegmentoN2
|
39
|
+
obj = c.new
|
40
|
+
linha1 = obj.linha
|
41
|
+
obj2 = c.read(linha1)
|
42
|
+
linha2 = obj2.linha
|
43
|
+
linha1.should eq linha2
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN3 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN3.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN3)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN3.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:periodo_apuracao)
|
21
|
+
segmento.should respond_to(:receita_bruta)
|
22
|
+
segmento.should respond_to(:percentual)
|
23
|
+
segmento.should respond_to(:valor_principal)
|
24
|
+
segmento.should respond_to(:valor_multa)
|
25
|
+
segmento.should respond_to(:valor_juros_encargos)
|
26
|
+
|
27
|
+
segmento.should respond_to(:cnab)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "deve ter 120 caracteres" do
|
32
|
+
segmento = SegmentoN3.new
|
33
|
+
segmento.linha.length.should be(120)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "deve manter coesao" do
|
37
|
+
c = Cnab240::SegmentoN3
|
38
|
+
obj = c.new
|
39
|
+
linha1 = obj.linha
|
40
|
+
obj2 = c.read(linha1)
|
41
|
+
linha2 = obj2.linha
|
42
|
+
linha1.should eq linha2
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN4 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN4.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN4)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN4.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:vencimento)
|
21
|
+
segmento.should respond_to(:ie_munic_declar)
|
22
|
+
segmento.should respond_to(:divida_ativa_etiqueta)
|
23
|
+
segmento.should respond_to(:periodo_referencia)
|
24
|
+
segmento.should respond_to(:numero_parcela_notificacao)
|
25
|
+
segmento.should respond_to(:valor_receita)
|
26
|
+
segmento.should respond_to(:valor_juros_encargos)
|
27
|
+
segmento.should respond_to(:valor_multa)
|
28
|
+
|
29
|
+
segmento.should respond_to(:cnab)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it "deve ter 120 caracteres" do
|
34
|
+
segmento = SegmentoN4.new
|
35
|
+
segmento.linha.length.should be(120)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "deve manter coesao" do
|
39
|
+
c = Cnab240::SegmentoN4
|
40
|
+
obj = c.new
|
41
|
+
linha1 = obj.linha
|
42
|
+
obj2 = c.read(linha1)
|
43
|
+
linha2 = obj2.linha
|
44
|
+
linha1.should eq linha2
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN5 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN5.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN5)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN5.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:exercicio)
|
21
|
+
segmento.should respond_to(:renavam)
|
22
|
+
segmento.should respond_to(:uf)
|
23
|
+
segmento.should respond_to(:municipio)
|
24
|
+
segmento.should respond_to(:placa)
|
25
|
+
segmento.should respond_to(:opcao_pagamento)
|
26
|
+
|
27
|
+
segmento.should respond_to(:cnab)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "deve ter 120 caracteres" do
|
32
|
+
segmento = SegmentoN5.new
|
33
|
+
segmento.linha.length.should be(120)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "deve manter coesao" do
|
37
|
+
c = Cnab240::SegmentoN5
|
38
|
+
obj = c.new
|
39
|
+
linha1 = obj.linha
|
40
|
+
obj2 = c.read(linha1)
|
41
|
+
linha2 = obj2.linha
|
42
|
+
linha1.should eq linha2
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN6 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN6.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN6)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN6.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:exercicio)
|
21
|
+
segmento.should respond_to(:renavam)
|
22
|
+
segmento.should respond_to(:uf)
|
23
|
+
segmento.should respond_to(:municipio)
|
24
|
+
segmento.should respond_to(:placa)
|
25
|
+
segmento.should respond_to(:opcao_pagamento)
|
26
|
+
|
27
|
+
segmento.should respond_to(:cnab)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "deve ter 120 caracteres" do
|
32
|
+
segmento = SegmentoN6.new
|
33
|
+
segmento.linha.length.should be(120)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "deve manter coesao" do
|
37
|
+
c = Cnab240::SegmentoN6
|
38
|
+
obj = c.new
|
39
|
+
linha1 = obj.linha
|
40
|
+
obj2 = c.read(linha1)
|
41
|
+
linha2 = obj2.linha
|
42
|
+
linha1.should eq linha2
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN7 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN7.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN7)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN7.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
segmento.should respond_to(:identificacao_tributo)
|
19
|
+
|
20
|
+
segmento.should respond_to(:exercicio)
|
21
|
+
segmento.should respond_to(:renavam)
|
22
|
+
segmento.should respond_to(:uf)
|
23
|
+
segmento.should respond_to(:municipio)
|
24
|
+
segmento.should respond_to(:placa)
|
25
|
+
segmento.should respond_to(:opcao_pagamento)
|
26
|
+
segmento.should respond_to(:opcao_retirada)
|
27
|
+
|
28
|
+
segmento.should respond_to(:cnab)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "deve ter 120 caracteres" do
|
33
|
+
segmento = SegmentoN7.new
|
34
|
+
segmento.linha.length.should be(120)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deve manter coesao" do
|
38
|
+
c = Cnab240::SegmentoN7
|
39
|
+
obj = c.new
|
40
|
+
linha1 = obj.linha
|
41
|
+
obj2 = c.read(linha1)
|
42
|
+
linha2 = obj2.linha
|
43
|
+
linha1.should eq linha2
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Cnab240
|
4
|
+
|
5
|
+
describe SegmentoN8 do
|
6
|
+
|
7
|
+
it "deve instanciar segmento" do
|
8
|
+
segmento = SegmentoN8.new
|
9
|
+
segmento.should be_an_instance_of(SegmentoN8)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "deve conter campos" do
|
13
|
+
segmento = SegmentoN8.new
|
14
|
+
|
15
|
+
segmento.should respond_to(:receita)
|
16
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
17
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
18
|
+
|
19
|
+
segmento.should respond_to(:ie_munic_declar)
|
20
|
+
|
21
|
+
segmento.should respond_to(:origem)
|
22
|
+
segmento.should respond_to(:valor_principal)
|
23
|
+
segmento.should respond_to(:atualizacao_monetaria)
|
24
|
+
segmento.should respond_to(:valor_mora)
|
25
|
+
segmento.should respond_to(:valor_multa)
|
26
|
+
segmento.should respond_to(:data_vencimento)
|
27
|
+
segmento.should respond_to(:periodo_parcela)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "deve ter 120 caracteres" do
|
32
|
+
segmento = SegmentoN8.new
|
33
|
+
segmento.linha.length.should be(120)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "deve manter coesao" do
|
37
|
+
c = Cnab240::SegmentoN8
|
38
|
+
obj = c.new
|
39
|
+
linha1 = obj.linha
|
40
|
+
obj2 = c.read(linha1)
|
41
|
+
linha2 = obj2.linha
|
42
|
+
linha1.should eq linha2
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -26,7 +26,7 @@ describe SegmentoN do
|
|
26
26
|
segmento.should respond_to(:data_pagamento)
|
27
27
|
segmento.should respond_to(:valor_pagamento)
|
28
28
|
|
29
|
-
segmento.should respond_to(:
|
29
|
+
segmento.should respond_to(:n_complemento)
|
30
30
|
|
31
31
|
segmento.should respond_to(:ocorrencias)
|
32
32
|
end
|
@@ -36,4 +36,37 @@ describe SegmentoN do
|
|
36
36
|
segmento.linha.length.should be(240)
|
37
37
|
end
|
38
38
|
|
39
|
+
it "n_complemento deve respeitar choice header (N5)" do
|
40
|
+
lote = Cnab240::Lote.new(:operacao => :pagamento_titulo_tributos, :tipo => :remessa) do |l|
|
41
|
+
l.header.servico_forma = '25'
|
42
|
+
end
|
43
|
+
lote.segmento_n.should be_an_instance_of(Cnab240::SegmentoN)
|
44
|
+
|
45
|
+
segmento = lote.segmento_n.n_complemento
|
46
|
+
|
47
|
+
segmento.should respond_to(:receita)
|
48
|
+
segmento.should respond_to(:tipo_identificacao_contribuinte)
|
49
|
+
segmento.should respond_to(:identificacao_contribuinte)
|
50
|
+
segmento.should respond_to(:identificacao_tributo)
|
51
|
+
|
52
|
+
segmento.should respond_to(:exercicio)
|
53
|
+
segmento.should respond_to(:renavam)
|
54
|
+
segmento.should respond_to(:uf)
|
55
|
+
segmento.should respond_to(:municipio)
|
56
|
+
segmento.should respond_to(:placa)
|
57
|
+
segmento.should respond_to(:opcao_pagamento)
|
58
|
+
|
59
|
+
segmento.should respond_to(:cnab)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
it "deve manter coesao" do
|
64
|
+
c = Cnab240::SegmentoN
|
65
|
+
obj = c.new
|
66
|
+
linha1 = obj.linha
|
67
|
+
obj2 = c.read(linha1)
|
68
|
+
linha2 = obj2.linha
|
69
|
+
linha1.should eq linha2
|
70
|
+
end
|
71
|
+
|
39
72
|
end
|
@@ -38,4 +38,13 @@ describe SegmentoO do
|
|
38
38
|
segmento.linha.length.should be(240)
|
39
39
|
end
|
40
40
|
|
41
|
+
it "deve manter coesao" do
|
42
|
+
c = Cnab240::SegmentoO
|
43
|
+
obj = c.new
|
44
|
+
linha1 = obj.linha
|
45
|
+
obj2 = c.read(linha1)
|
46
|
+
linha2 = obj2.linha
|
47
|
+
linha1.should eq linha2
|
48
|
+
end
|
49
|
+
|
41
50
|
end
|