cnab240 0.0.17 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/cnab240.gemspec +2 -1
- data/lib/cnab240/arquivo/arquivo.rb +89 -60
- data/lib/cnab240/arquivo/builder.rb +162 -154
- data/lib/cnab240/arquivo/estrutura.rb +159 -95
- data/lib/cnab240/arquivo/lote.rb +57 -57
- data/lib/cnab240/arquivo/v40/header.rb +30 -30
- data/lib/cnab240/arquivo/v40/trailer.rb +11 -11
- data/lib/cnab240/arquivo/v80/header.rb +28 -27
- data/lib/cnab240/arquivo/v80/trailer.rb +11 -11
- data/lib/cnab240/arquivo/v83/header.rb +38 -0
- data/lib/cnab240/arquivo/v83/trailer.rb +17 -0
- data/lib/cnab240/arquivo/v86/header.rb +27 -28
- data/lib/cnab240/arquivo/v86/trailer.rb +12 -12
- data/lib/cnab240/arquivo/v87/header.rb +38 -0
- data/lib/cnab240/arquivo/v87/trailer.rb +18 -0
- data/lib/cnab240/ext/attribute_accessors.rb +2 -2
- data/lib/cnab240/ext/bindata.rb +9 -9
- data/lib/cnab240/ext/default_mixin.rb +11 -12
- data/lib/cnab240/ext/filler.rb +16 -16
- data/lib/cnab240/ext/lstring.rb +5 -5
- data/lib/cnab240/ext/segmento_mixin.rb +4 -4
- data/lib/cnab240/helper/helper.rb +15 -0
- data/lib/cnab240/helper/pagamento_bb.rb +51 -0
- data/lib/cnab240/helper/pagamento_bradesco.rb +49 -0
- data/lib/cnab240/helper/pagamento_itau.rb +34 -49
- data/lib/cnab240/helper/pagamento_sicoob.rb +55 -0
- data/lib/cnab240/pagamentos/v40/header.rb +35 -37
- data/lib/cnab240/pagamentos/v40/trailer.rb +13 -13
- data/lib/cnab240/pagamentos/v80/header.rb +45 -45
- data/lib/cnab240/pagamentos/v80/trailer.rb +13 -13
- data/lib/cnab240/pagamentos/v83/header.rb +45 -0
- data/lib/cnab240/pagamentos/v83/trailer.rb +18 -0
- data/lib/cnab240/pagamentos/v86/header.rb +44 -44
- data/lib/cnab240/pagamentos/v86/titulos/header.rb +44 -44
- data/lib/cnab240/pagamentos/v86/titulos/trailer.rb +14 -14
- data/lib/cnab240/pagamentos/v86/trailer.rb +14 -14
- data/lib/cnab240/pagamentos/v86/tributos/header.rb +45 -45
- data/lib/cnab240/pagamentos/v86/tributos/trailer.rb +12 -12
- data/lib/cnab240/pagamentos/v87/header.rb +46 -0
- data/lib/cnab240/pagamentos/v87/titulos/header.rb +46 -0
- data/lib/cnab240/pagamentos/v87/titulos/trailer.rb +18 -0
- data/lib/cnab240/pagamentos/v87/trailer.rb +18 -0
- data/lib/cnab240/pagamentos/v87/tributos/header.rb +47 -0
- data/lib/cnab240/pagamentos/v87/tributos/trailer.rb +17 -0
- data/lib/cnab240/segmentos/v40/segmento_a.rb +45 -48
- data/lib/cnab240/segmentos/v80/agencia_itau.rb +11 -12
- data/lib/cnab240/segmentos/v80/agencia_outros.rb +9 -10
- data/lib/cnab240/segmentos/v80/segmento_a.rb +59 -61
- data/lib/cnab240/segmentos/v83/segmento_a.rb +42 -0
- data/lib/cnab240/segmentos/v83/segmento_b.rb +40 -0
- data/lib/cnab240/segmentos/v83/segmento_j.rb +33 -0
- data/lib/cnab240/segmentos/v83/segmento_z.rb +19 -0
- data/lib/cnab240/segmentos/v86/segmento_a.rb +42 -45
- data/lib/cnab240/segmentos/v86/segmento_b.rb +38 -39
- data/lib/cnab240/segmentos/v86/segmento_c.rb +23 -24
- data/lib/cnab240/segmentos/v86/segmento_j.rb +25 -26
- data/lib/cnab240/segmentos/v86/segmento_j52.rb +22 -24
- data/lib/cnab240/segmentos/v86/segmento_n.rb +50 -51
- data/lib/cnab240/segmentos/v86/segmento_n1.rb +13 -15
- data/lib/cnab240/segmentos/v86/segmento_n2.rb +15 -17
- data/lib/cnab240/segmentos/v86/segmento_n3.rb +15 -17
- data/lib/cnab240/segmentos/v86/segmento_n4.rb +17 -19
- data/lib/cnab240/segmentos/v86/segmento_n5.rb +15 -17
- data/lib/cnab240/segmentos/v86/segmento_n6.rb +15 -17
- data/lib/cnab240/segmentos/v86/segmento_n7.rb +16 -18
- data/lib/cnab240/segmentos/v86/segmento_n8.rb +15 -18
- data/lib/cnab240/segmentos/v86/segmento_o.rb +20 -21
- data/lib/cnab240/segmentos/v86/segmento_w.rb +16 -17
- data/lib/cnab240/segmentos/v86/segmento_w1.rb +12 -13
- data/lib/cnab240/segmentos/v86/segmento_z.rb +14 -14
- data/lib/cnab240/segmentos/v87/segmento_a.rb +44 -0
- data/lib/cnab240/segmentos/v87/segmento_b.rb +40 -0
- data/lib/cnab240/segmentos/v87/segmento_c.rb +32 -0
- data/lib/cnab240/segmentos/v87/segmento_j.rb +33 -0
- data/lib/cnab240/segmentos/v87/segmento_j52.rb +32 -0
- data/lib/cnab240/segmentos/v87/segmento_n.rb +59 -0
- data/lib/cnab240/segmentos/v87/segmento_n1.rb +19 -0
- data/lib/cnab240/segmentos/v87/segmento_n2.rb +21 -0
- data/lib/cnab240/segmentos/v87/segmento_n3.rb +21 -0
- data/lib/cnab240/segmentos/v87/segmento_n4.rb +23 -0
- data/lib/cnab240/segmentos/v87/segmento_n5.rb +21 -0
- data/lib/cnab240/segmentos/v87/segmento_n6.rb +21 -0
- data/lib/cnab240/segmentos/v87/segmento_n7.rb +21 -0
- data/lib/cnab240/segmentos/v87/segmento_n8.rb +22 -0
- data/lib/cnab240/segmentos/v87/segmento_o.rb +27 -0
- data/lib/cnab240/segmentos/v87/segmento_w.rb +24 -0
- data/lib/cnab240/segmentos/v87/segmento_w1.rb +16 -0
- data/lib/cnab240/segmentos/v87/segmento_z.rb +19 -0
- data/lib/cnab240/version.rb +1 -2
- data/lib/cnab240.rb +54 -24
- metadata +64 -133
- data/.gitignore +0 -19
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/Gemfile +0 -6
- data/LICENSE +0 -22
- data/README.md +0 -135
- data/docs/vendor/febraban/subcpadr12_layout_padrao_V86.pdf +0 -0
- data/docs/vendor/itau/SISPAG_CNAB_240.pdf +0 -0
- data/docs/vendor/itau/sisdeb_cnab_240.pdf +0 -0
- data/spec/arquivo/arquivo_spec.rb +0 -95
- data/spec/arquivo/v40/header_spec.rb +0 -68
- data/spec/arquivo/v40/trailer_spec.rb +0 -25
- data/spec/arquivo/v80/header_spec.rb +0 -60
- data/spec/arquivo/v80/trailer_spec.rb +0 -26
- data/spec/arquivo/v86/header_spec.rb +0 -89
- data/spec/arquivo/v86/trailer_spec.rb +0 -27
- data/spec/bindata/bindata_spec.rb +0 -55
- data/spec/cnab240_spec.rb +0 -22
- data/spec/helper/pagamento_itau_spec.rb +0 -83
- data/spec/hom/hom_spec.rb +0 -65
- data/spec/hom/retorno/SB22112AIT.RET +0 -5
- data/spec/hom/retorno/SB23112AIT.RET +0 -5
- data/spec/pagamentos/v40/header_spec.rb +0 -59
- data/spec/pagamentos/v40/lote_spec.rb +0 -25
- data/spec/pagamentos/v40/trailer_spec.rb +0 -28
- data/spec/pagamentos/v80/header_spec.rb +0 -52
- data/spec/pagamentos/v80/lote_spec.rb +0 -25
- data/spec/pagamentos/v80/trailer_spec.rb +0 -28
- data/spec/pagamentos/v86/header_spec.rb +0 -53
- data/spec/pagamentos/v86/lote_spec.rb +0 -38
- data/spec/pagamentos/v86/titulos/header_spec.rb +0 -51
- data/spec/pagamentos/v86/titulos/lote_spec.rb +0 -37
- data/spec/pagamentos/v86/titulos/trailer_spec.rb +0 -30
- data/spec/pagamentos/v86/trailer_spec.rb +0 -30
- data/spec/pagamentos/v86/tributos/header_spec.rb +0 -53
- data/spec/pagamentos/v86/tributos/lote_spec.rb +0 -43
- data/spec/pagamentos/v86/tributos/trailer_spec.rb +0 -27
- data/spec/segmentos/v40/segmento_a_spec.rb +0 -70
- data/spec/segmentos/v80/segmento_a_spec.rb +0 -70
- data/spec/segmentos/v86/segmento_a_spec.rb +0 -65
- data/spec/segmentos/v86/segmento_b_spec.rb +0 -67
- data/spec/segmentos/v86/segmento_c_spec.rb +0 -51
- data/spec/segmentos/v86/segmento_j52_spec.rb +0 -55
- data/spec/segmentos/v86/segmento_j_spec.rb +0 -55
- data/spec/segmentos/v86/segmento_n1_spec.rb +0 -43
- data/spec/segmentos/v86/segmento_n2_spec.rb +0 -46
- data/spec/segmentos/v86/segmento_n3_spec.rb +0 -45
- data/spec/segmentos/v86/segmento_n4_spec.rb +0 -47
- data/spec/segmentos/v86/segmento_n5_spec.rb +0 -45
- data/spec/segmentos/v86/segmento_n6_spec.rb +0 -45
- data/spec/segmentos/v86/segmento_n7_spec.rb +0 -46
- data/spec/segmentos/v86/segmento_n8_spec.rb +0 -45
- data/spec/segmentos/v86/segmento_n_spec.rb +0 -73
- data/spec/segmentos/v86/segmento_o_spec.rb +0 -50
- data/spec/segmentos/v86/segmento_spec.rb +0 -12
- data/spec/segmentos/v86/segmento_w_spec.rb +0 -51
- data/spec/segmentos/v86/segmento_z_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -10
- data/spec/tmp/.gitkeep +0 -0
@@ -1,39 +1,38 @@
|
|
1
1
|
module Cnab240::V86::Arquivo
|
2
|
-
|
3
|
-
|
4
|
-
include Cnab240::DefaultMixin
|
2
|
+
class Header < BinData::Record
|
5
3
|
|
6
|
-
|
7
|
-
lstring :controle_lote, :length => 4, :initial_value => '0000', :pad_byte => '0'
|
8
|
-
lstring :controle_registro, :length => 1, :initial_value => '0', :pad_byte => '0'
|
4
|
+
include Cnab240::DefaultMixin
|
9
5
|
|
10
|
-
|
6
|
+
lstring :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
lstring :controle_lote, :length => 4, :initial_value => '0000', :pad_byte => '0'
|
8
|
+
lstring :controle_registro, :length => 1, :initial_value => '0', :pad_byte => '0'
|
11
9
|
|
12
|
-
|
13
|
-
lstring :empresa_numero, :length => 14, :pad_byte => '0'
|
14
|
-
string :empresa_convenio, :length => 20, :pad_byte => ' '
|
15
|
-
lstring :empresa_agencia_codigo, :length => 5, :pad_byte => '0'
|
16
|
-
string :empresa_agencia_dv, :length => 1, :pad_byte => ' '
|
17
|
-
lstring :empresa_conta_numero, :length => 12, :pad_byte => '0'
|
18
|
-
string :empresa_conta_dv, :length => 1, :pad_byte => ' '
|
19
|
-
string :empresa_agencia_conta_dv, :length => 1, :pad_byte => '0'
|
20
|
-
string :empresa_nome, :length => 30, :pad_byte => ' '
|
10
|
+
string :cnab_g004_1, :length => 9, :initial_value => ' ', :pad_byte => ' '
|
21
11
|
|
22
|
-
|
12
|
+
lstring :empresa_tipo, :length => 1, :pad_byte => '0'
|
13
|
+
lstring :empresa_numero, :length => 14, :pad_byte => '0'
|
14
|
+
string :empresa_convenio, :length => 20, :pad_byte => ' '
|
15
|
+
lstring :empresa_agencia_codigo, :length => 5, :pad_byte => '0'
|
16
|
+
string :empresa_agencia_dv, :length => 1, :pad_byte => ' '
|
17
|
+
lstring :empresa_conta_numero, :length => 12, :pad_byte => '0'
|
18
|
+
string :empresa_conta_dv, :length => 1, :pad_byte => ' '
|
19
|
+
string :empresa_agencia_conta_dv, :length => 1, :pad_byte => '0'
|
20
|
+
string :empresa_nome, :length => 30, :pad_byte => ' '
|
23
21
|
|
24
|
-
|
22
|
+
string :banco_nome, :length => 30, :pad_byte => ' '
|
25
23
|
|
26
|
-
|
27
|
-
lstring :arquivo_data_geracao, :length => 8, :pad_byte => '0'
|
28
|
-
lstring :arquivo_hora_geracao,:length => 6, :pad_byte => '0'
|
29
|
-
lstring :arquivo_sequencia, :length => 6, :pad_byte => '0'
|
30
|
-
string :arquivo_layout, :length => 3, :initial_value => '085'
|
31
|
-
lstring :arquivo_densidade, :length => 5, :pad_byte => '0'
|
24
|
+
string :cnab_g004_2, :length => 10, :pad_byte => ' '
|
32
25
|
|
33
|
-
|
34
|
-
|
26
|
+
lstring :arquivo_codigo, :length => 1, :pad_byte => '0'
|
27
|
+
lstring :arquivo_data_geracao, :length => 8, :pad_byte => '0'
|
28
|
+
lstring :arquivo_hora_geracao, :length => 6, :pad_byte => '0'
|
29
|
+
lstring :arquivo_sequencia, :length => 6, :pad_byte => '0'
|
30
|
+
string :arquivo_layout, :length => 3, :initial_value => '085'
|
31
|
+
lstring :arquivo_densidade, :length => 5, :pad_byte => '0'
|
35
32
|
|
36
|
-
|
33
|
+
string :reservado_banco, :length => 20, :pad_byte => ' '
|
34
|
+
string :reservado_empresa, :length => 20, :pad_byte => ' '
|
37
35
|
|
38
|
-
|
36
|
+
string :cnab_g004_3, :length => 29, :pad_byte => ' '
|
37
|
+
end
|
39
38
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Cnab240::V86::Arquivo
|
2
|
-
|
3
|
-
|
4
|
-
include Cnab240::DefaultMixin
|
2
|
+
class Trailer < BinData::Record
|
5
3
|
|
6
|
-
|
7
|
-
string :controle_lote, :length => 4, :initial_value => '9999', :pad_byte => '0'
|
8
|
-
string :controle_registro, :length => 1, :initial_value => '9', :pad_byte => '0'
|
4
|
+
include Cnab240::DefaultMixin
|
9
5
|
|
10
|
-
|
6
|
+
string :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
string :controle_lote, :length => 4, :initial_value => '9999', :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '9', :pad_byte => '0'
|
11
9
|
|
12
|
-
|
13
|
-
lstring :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
14
|
-
lstring :totais_qtde_contas_concil, :length => 6, :pad_byte => '0'
|
10
|
+
string :cnab_g004_1, :length => 9, :pad_byte => ' '
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
lstring :totais_qtde_lotes, :length => 6, :pad_byte => '0'
|
13
|
+
lstring :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
14
|
+
lstring :totais_qtde_contas_concil, :length => 6, :pad_byte => '0'
|
15
|
+
|
16
|
+
string :cnab_g004_2, :length => 205, :pad_byte => ' '
|
17
|
+
end
|
18
18
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Cnab240::V87::Arquivo
|
2
|
+
class Header < BinData::Record
|
3
|
+
|
4
|
+
include Cnab240::DefaultMixin
|
5
|
+
|
6
|
+
lstring :controle_banco, :length => 3, :pad_byte => '0'
|
7
|
+
lstring :controle_lote, :length => 4, :initial_value => '0000', :pad_byte => '0'
|
8
|
+
lstring :controle_registro, :length => 1, :initial_value => '0', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :cnab_g004_1, :length => 9, :initial_value => ' ', :pad_byte => ' '
|
11
|
+
|
12
|
+
lstring :empresa_tipo, :length => 1, :pad_byte => '0'
|
13
|
+
lstring :empresa_numero, :length => 14, :pad_byte => '0'
|
14
|
+
string :empresa_convenio, :length => 20, :pad_byte => ' '
|
15
|
+
lstring :empresa_agencia_codigo, :length => 5, :pad_byte => '0'
|
16
|
+
string :empresa_agencia_dv, :length => 1, :pad_byte => ' '
|
17
|
+
lstring :empresa_conta_numero, :length => 12, :pad_byte => '0'
|
18
|
+
string :empresa_conta_dv, :length => 1, :pad_byte => ' '
|
19
|
+
string :empresa_agencia_conta_dv, :length => 1, :pad_byte => '0'
|
20
|
+
string :empresa_nome, :length => 30, :pad_byte => ' '
|
21
|
+
|
22
|
+
string :banco_nome, :length => 30, :pad_byte => ' '
|
23
|
+
|
24
|
+
string :cnab_g004_2, :length => 10, :pad_byte => ' '
|
25
|
+
|
26
|
+
lstring :arquivo_codigo, :length => 1, :pad_byte => '0'
|
27
|
+
lstring :arquivo_data_geracao, :length => 8, :pad_byte => '0'
|
28
|
+
lstring :arquivo_hora_geracao, :length => 6, :pad_byte => '0'
|
29
|
+
lstring :arquivo_sequencia, :length => 6, :pad_byte => '0'
|
30
|
+
string :arquivo_layout, :length => 3, :initial_value => '087'
|
31
|
+
lstring :arquivo_densidade, :length => 5, :pad_byte => '0'
|
32
|
+
|
33
|
+
string :reservado_banco, :length => 20, :pad_byte => ' '
|
34
|
+
string :reservado_empresa, :length => 20, :pad_byte => ' '
|
35
|
+
|
36
|
+
string :cnab_g004_3, :length => 29, :pad_byte => ' '
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cnab240::V87::Arquivo
|
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, :initial_value => '9999', :pad_byte => '0'
|
8
|
+
string :controle_registro, :length => 1, :initial_value => '9', :pad_byte => '0'
|
9
|
+
|
10
|
+
string :cnab_g004_1, :length => 9, :pad_byte => ' '
|
11
|
+
|
12
|
+
lstring :totais_qtde_lotes, :length => 6, :pad_byte => '0'
|
13
|
+
lstring :totais_qtde_registros, :length => 6, :pad_byte => '0'
|
14
|
+
lstring :totais_qtde_contas_concil, :length => 6, :pad_byte => '0'
|
15
|
+
|
16
|
+
string :cnab_g004_2, :length => 205, :pad_byte => ' '
|
17
|
+
end
|
18
|
+
end
|
@@ -18,7 +18,7 @@ class Module
|
|
18
18
|
EOS
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def mod_attr_writer(*syms)
|
23
23
|
options = syms
|
24
24
|
syms.each do |sym|
|
@@ -39,7 +39,7 @@ class Module
|
|
39
39
|
EOS
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def mod_attr_accessor(*syms)
|
44
44
|
mod_attr_reader(*syms)
|
45
45
|
mod_attr_writer(*syms)
|
data/lib/cnab240/ext/bindata.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module BinData
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class Record < BinData::Struct
|
3
|
+
def linha # lulz
|
4
|
+
self.auto_fill if self.respond_to?(:auto_fill) && Cnab240.auto_fill_enabled
|
5
|
+
s = StringIO.new
|
6
|
+
self.write(s)
|
7
|
+
raise "Invalid line length #{s.string.length}" unless (s.string.length == 240) || self.respond_to?(:lote)
|
8
|
+
s.string
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module Cnab240
|
2
|
-
|
2
|
+
module DefaultMixin
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
def initialize_instance
|
5
|
+
super
|
6
|
+
Cnab240.defaults.each do |k, v|
|
7
|
+
if self.respond_to?("#{k}=")
|
8
|
+
self.send("#{k}=", v)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
yield self if block_given?
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
end
|
14
|
+
end
|
16
15
|
end
|
data/lib/cnab240/ext/filler.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module Cnab240
|
2
|
-
|
2
|
+
module Filler
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
def fill(hash, *objects)
|
5
|
+
objects.each do |object|
|
6
|
+
hash.each do |k, v|
|
7
|
+
object.send("#{k}=", v) if object.respond_to?("#{k}=")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
def fill!(hash, *objects)
|
13
|
+
objects.each do |object|
|
14
|
+
hash.each do |k, v|
|
15
|
+
object.send("#{k}=", v)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
19
|
|
20
|
-
|
20
|
+
end
|
21
21
|
end
|
data/lib/cnab240/ext/lstring.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require "bindata/base_primitive"
|
2
2
|
|
3
3
|
module BinData
|
4
|
-
|
4
|
+
|
5
5
|
# I didn't want to monkey patch bindata's String primitive.
|
6
6
|
class Lstring < BinData::BasePrimitive
|
7
7
|
|
8
8
|
optional_parameters :read_length, :length, :trim_padding
|
9
|
-
default_parameters
|
9
|
+
default_parameters :pad_byte => "\0"
|
10
10
|
mutually_exclusive_parameters :read_length, :length
|
11
11
|
mutually_exclusive_parameters :length, :value
|
12
12
|
|
@@ -36,7 +36,7 @@ module BinData
|
|
36
36
|
|
37
37
|
def byte_string(str)
|
38
38
|
if RUBY_VERSION >= "1.9"
|
39
|
-
str.force_encoding(Encoding::BINARY)
|
39
|
+
str.force_encoding(Encoding::BINARY)
|
40
40
|
else
|
41
41
|
str
|
42
42
|
end
|
@@ -63,7 +63,7 @@ module BinData
|
|
63
63
|
|
64
64
|
def byte_string(str)
|
65
65
|
if RUBY_VERSION >= "1.9"
|
66
|
-
str.force_encoding(Encoding::BINARY)
|
66
|
+
str.force_encoding(Encoding::BINARY)
|
67
67
|
else
|
68
68
|
str
|
69
69
|
end
|
@@ -78,7 +78,7 @@ module BinData
|
|
78
78
|
elsif str.length > len
|
79
79
|
str.slice(0, len)
|
80
80
|
else
|
81
|
-
(eval_parameter(:pad_byte) * (len - str.length)) + str
|
81
|
+
(eval_parameter(:pad_byte) * (len - str.length)) + str
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class PagamentoBb < Helper
|
3
|
+
|
4
|
+
def initialize(campos = {})
|
5
|
+
campos[:controle_banco] ||= '001'
|
6
|
+
campos[:banco_nome] ||= 'BANCO DO BRASIL S.A.'
|
7
|
+
campos[:empresa_tipo] ||= '2'
|
8
|
+
campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
|
9
|
+
campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
|
10
|
+
campos[:arquivo_codigo] ||= '1'
|
11
|
+
|
12
|
+
@arquivo = Cnab240::Arquivo::Arquivo.new('V86')
|
13
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V86')
|
14
|
+
|
15
|
+
fill campos, arquivo.header, arquivo.trailer
|
16
|
+
|
17
|
+
campos[:servico_operacao] ||= 'C'
|
18
|
+
campos[:controle_lote] ||= '0001'
|
19
|
+
|
20
|
+
fill campos, lote.header, lote.trailer
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_lote(campos = {})
|
24
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V86')
|
25
|
+
|
26
|
+
campos[:servico_operacao] ||= 'C'
|
27
|
+
campos[:controle_lote] ||= '0001'
|
28
|
+
|
29
|
+
fill campos, lote.header
|
30
|
+
end
|
31
|
+
|
32
|
+
def <<(campos)
|
33
|
+
lote = @arquivo.lotes.last
|
34
|
+
|
35
|
+
campos[:controle_banco] ||= '001'
|
36
|
+
campos[:controle_lote] ||= @arquivo.lotes.length.to_s
|
37
|
+
campos[:servico_numero_registro] ||= (lote.segmentos.length+1).to_s
|
38
|
+
# 000 para inclusao e 999 para exclusao
|
39
|
+
campos[:servico_tipo_movimento] ||= '000'
|
40
|
+
campos[:credito_moeda_tipo] ||= 'BRL'
|
41
|
+
campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s
|
42
|
+
|
43
|
+
segmento_a = Cnab240::V86::SegmentoA.new
|
44
|
+
fill campos, segmento_a
|
45
|
+
#fill campos, segmento_a.favorecido_agencia_conta
|
46
|
+
|
47
|
+
lote << segmento_a
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class PagamentoBradesco < Helper
|
3
|
+
|
4
|
+
def initialize(campos = {})
|
5
|
+
campos[:controle_banco] ||= '237'
|
6
|
+
campos[:arquivo_codigo] ||= '1'
|
7
|
+
campos[:banco_nome] ||= 'BANCO BRADESCO'
|
8
|
+
campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
|
9
|
+
campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
|
10
|
+
|
11
|
+
@arquivo = Cnab240::Arquivo::Arquivo.new('V80')
|
12
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
|
13
|
+
|
14
|
+
fill campos, arquivo.header, arquivo.trailer
|
15
|
+
|
16
|
+
campos[:servico_operacao] ||= 'C'
|
17
|
+
campos[:controle_lote] ||= '0001'
|
18
|
+
|
19
|
+
fill campos, lote.header, lote.trailer
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_lote(campos = {})
|
23
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
|
24
|
+
|
25
|
+
campos[:servico_operacao] ||= 'C'
|
26
|
+
campos[:controle_lote] ||= '0001'
|
27
|
+
|
28
|
+
fill campos, lote.header
|
29
|
+
end
|
30
|
+
|
31
|
+
def <<(campos)
|
32
|
+
lote = @arquivo.lotes.last
|
33
|
+
|
34
|
+
campos[:controle_banco] ||= '237'
|
35
|
+
campos[:controle_lote] ||= @arquivo.lotes.length.to_s
|
36
|
+
campos[:servico_numero_registro] ||= (lote.segmentos.length+1).to_s
|
37
|
+
campos[:servico_tipo_movimento] ||= '000'
|
38
|
+
campos[:credito_moeda_tipo] ||= 'REA'
|
39
|
+
campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s
|
40
|
+
|
41
|
+
segmento_a = Cnab240::V80::SegmentoA.new
|
42
|
+
fill campos, segmento_a
|
43
|
+
fill campos, segmento_a.favorecido_agencia_conta
|
44
|
+
|
45
|
+
lote << segmento_a
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -1,64 +1,49 @@
|
|
1
1
|
module Cnab240
|
2
|
-
|
2
|
+
class PagamentoItau < Helper
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def initialize(campos = {})
|
5
|
+
campos[:controle_banco] ||= '341'
|
6
|
+
campos[:arquivo_codigo] ||= '1'
|
7
|
+
campos[:banco_nome] ||= 'BANCO ITAU'
|
8
|
+
campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
|
9
|
+
campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
|
7
10
|
|
8
|
-
|
11
|
+
@arquivo = Cnab240::Arquivo::Arquivo.new('V80')
|
12
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
|
9
13
|
|
10
|
-
|
11
|
-
campos[:arquivo_codigo] ||= '1'
|
12
|
-
campos[:banco_nome] ||= 'BANCO ITAU'
|
13
|
-
campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
|
14
|
-
campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
|
14
|
+
fill campos, arquivo.header, arquivo.trailer
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
campos[:servico_operacao] ||= 'C'
|
17
|
+
campos[:controle_lote] ||= '0001'
|
18
18
|
|
19
|
-
|
19
|
+
fill campos, lote.header, lote.trailer
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
def add_lote(campos = {})
|
23
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V80')
|
23
24
|
|
24
|
-
|
25
|
+
campos[:servico_operacao] ||= 'C'
|
26
|
+
campos[:controle_lote] ||= '0001'
|
25
27
|
|
26
|
-
|
28
|
+
fill campos, lote.header
|
29
|
+
end
|
27
30
|
|
28
|
-
|
29
|
-
|
31
|
+
def <<(campos)
|
32
|
+
lote = @arquivo.lotes.last
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
campos[:controle_banco] ||= '341'
|
35
|
+
campos[:controle_lote] ||= @arquivo.lotes.length.to_s
|
36
|
+
campos[:servico_numero_registro] ||= (lote.segmentos.length+1).to_s
|
37
|
+
campos[:servico_tipo_movimento] ||= '000'
|
38
|
+
campos[:credito_moeda_tipo] ||= 'REA'
|
39
|
+
campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
segmento_a = Cnab240::V80::SegmentoA.new
|
42
|
+
fill campos, segmento_a
|
43
|
+
fill campos, segmento_a.favorecido_agencia_conta
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
campos[:controle_banco] ||= '341'
|
41
|
-
campos[:controle_lote] ||= @arquivo.lotes.length.to_s
|
42
|
-
campos[:servico_numero_registro] ||= (lote.segmentos.length+1).to_s
|
43
|
-
campos[:servico_tipo_movimento] ||= '000'
|
44
|
-
campos[:credito_moeda_tipo] ||= 'REA'
|
45
|
-
campos[:totais_qtde_registros] ||= (lote.segmentos.length + 2).to_s
|
46
|
-
|
47
|
-
segmento_a = Cnab240::V80::SegmentoA.new
|
48
|
-
fill campos, segmento_a
|
49
|
-
fill campos, segmento_a.favorecido_agencia_conta
|
50
|
-
|
51
|
-
lote << segmento_a
|
52
|
-
end
|
53
|
-
|
54
|
-
def string
|
55
|
-
arquivo.string
|
56
|
-
end
|
57
|
-
|
58
|
-
def save_to_file(filename)
|
59
|
-
arquivo.save_to_file(filename)
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
45
|
+
lote << segmento_a
|
46
|
+
end
|
63
47
|
|
48
|
+
end
|
64
49
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Cnab240
|
2
|
+
class PagamentoSicoob < Helper
|
3
|
+
|
4
|
+
def initialize(campos = {})
|
5
|
+
campos[:controle_banco] ||= '756'
|
6
|
+
campos[:banco_nome] ||= 'BANCO COOPERATIVO DO BRASIL S.A.'
|
7
|
+
campos[:empresa_tipo] ||= '2'
|
8
|
+
campos[:arquivo_data_geracao] ||= Time.now.strftime("%d%m%Y")
|
9
|
+
campos[:arquivo_hora_geracao] ||= Time.now.strftime("%H%M")
|
10
|
+
campos[:arquivo_codigo] ||= '1'
|
11
|
+
|
12
|
+
@arquivo = Cnab240::Arquivo::Arquivo.new('V87')
|
13
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V87')
|
14
|
+
|
15
|
+
fill campos, arquivo.header, arquivo.trailer
|
16
|
+
|
17
|
+
campos[:servico_operacao] ||= 'C'
|
18
|
+
campos[:controle_lote] ||= '0001'
|
19
|
+
|
20
|
+
fill campos, lote.header, lote.trailer
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_lote(campos = {})
|
24
|
+
@arquivo.lotes << lote = Cnab240::Lote.new(:operacao => :pagamento, :tipo => :remessa, :versao => 'V87')
|
25
|
+
|
26
|
+
campos[:servico_operacao] ||= 'C'
|
27
|
+
campos[:controle_lote] = (@arquivo.lotes.length).to_s
|
28
|
+
|
29
|
+
fill campos, lote.header, lote.trailer
|
30
|
+
end
|
31
|
+
|
32
|
+
def <<(campos)
|
33
|
+
lote = @arquivo.lotes.last
|
34
|
+
|
35
|
+
campos[:controle_banco] ||= '756'
|
36
|
+
campos[:controle_lote] = @arquivo.lotes.length.to_s
|
37
|
+
campos[:servico_numero_registro] = (lote.segmentos.length+1).to_s
|
38
|
+
# 000 para inclusao e 999 para exclusao
|
39
|
+
campos[:servico_tipo_movimento] ||= '000'
|
40
|
+
campos[:credito_moeda_tipo] ||= 'BRL'
|
41
|
+
|
42
|
+
segmento_a = Cnab240::V87::SegmentoA.new
|
43
|
+
fill campos, segmento_a
|
44
|
+
lote << segmento_a
|
45
|
+
|
46
|
+
campos[:controle_lote] = @arquivo.lotes.length.to_s
|
47
|
+
campos[:servico_numero_registro] = (lote.segmentos.length+1).to_s
|
48
|
+
|
49
|
+
segmento_b = Cnab240::V87::SegmentoB.new
|
50
|
+
fill campos, segmento_b
|
51
|
+
lote << segmento_b
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|