formatos-febraban 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/base/format_section.rb +79 -0
- data/base/position.rb +88 -0
- data/base/section.rb +41 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/formatos-febraban.gemspec +24 -0
- data/formats/febraban150/febraban_150.rb +505 -0
- data/formats/febraban150/febraban_150_a.rb +210 -0
- data/formats/febraban150/febraban_150_b.rb +132 -0
- data/formats/febraban150/febraban_150_c.rb +149 -0
- data/formats/febraban150/febraban_150_d.rb +149 -0
- data/formats/febraban150/febraban_150_e.rb +226 -0
- data/formats/febraban150/febraban_150_f.rb +271 -0
- data/formats/febraban150/febraban_150_h.rb +149 -0
- data/formats/febraban150/febraban_150_i.rb +151 -0
- data/formats/febraban150/febraban_150_j.rb +130 -0
- data/formats/febraban150/febraban_150_k.rb +188 -0
- data/formats/febraban150/febraban_150_l.rb +114 -0
- data/formats/febraban150/febraban_150_t.rb +74 -0
- data/formats/febraban150/febraban_150_x.rb +214 -0
- data/formats/febraban150/febraban_150_z.rb +74 -0
- data/lib/formatos/febraban.rb +7 -0
- data/lib/formatos/febraban/version.rb +5 -0
- metadata +103 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Header - Empresa e Banco
|
5
|
+
class Febraban150A < FormatSection
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
def initialize master
|
9
|
+
super(master, true, true, false)
|
10
|
+
|
11
|
+
@section = Section.new({
|
12
|
+
0 => Position.new(1, 1, false, "A", true), # Código do Registro
|
13
|
+
1 => Position.new(2, 1, true), # Código Remessa (1-Remessa, 2-Retorno)
|
14
|
+
2 => Position.new(3, 20, false), # Código de ID enviado pelo Banco
|
15
|
+
3 => Position.new(4, 20, false), # Nome da Empresa
|
16
|
+
4 => Position.new(5, 3, true), # Código do Banco
|
17
|
+
5 => Position.new(6, 20, false), # Nome do Banco
|
18
|
+
6 => Position.new(7, 8, true), # Data de Geração de Arquivo
|
19
|
+
7 => Position.new(8, 6, true), # Número Sequencial do Arquivo
|
20
|
+
8 => Position.new(9, 2, true, 5), # Versão do Layout (5, desde 05.05.2008)
|
21
|
+
9 => Position.new(10, 17, false, "DÉBITO AUTOMÁTICO"), # Identificação ("DÉBITO AUTOMÁTICO")
|
22
|
+
10 => Position.new(11, 52, false), # Reservado pelo Sistema
|
23
|
+
})
|
24
|
+
end
|
25
|
+
|
26
|
+
#-------------------------------------------------------------------
|
27
|
+
#-------------------------------------------------------------------
|
28
|
+
# Gerais
|
29
|
+
def process_section file
|
30
|
+
self.set_codigo_remessa file[1..1]
|
31
|
+
self.set_codigo_convenio file[2..21]
|
32
|
+
self.set_nome_empresa file[22..41]
|
33
|
+
self.set_codigo_banco file[42..44]
|
34
|
+
self.set_nome_banco file[45..64]
|
35
|
+
self.set_data_geracao file[65..72]
|
36
|
+
self.set_numero_sequencial file[73..78]
|
37
|
+
self.set_versao_layout file[79..80]
|
38
|
+
self.set_identificacao_servico file[81..99]
|
39
|
+
self.set_reservado file[98..149]
|
40
|
+
end
|
41
|
+
|
42
|
+
#-------------------------------------------------------------------
|
43
|
+
#-------------------------------------------------------------------
|
44
|
+
# Validações
|
45
|
+
def is_valid?
|
46
|
+
result = (self.get_codigo_remessa > 0 and
|
47
|
+
self.get_codigo_convenio.length > 0 and
|
48
|
+
self.get_nome_empresa.length > 0 and
|
49
|
+
self.get_codigo_banco > 0 and
|
50
|
+
self.get_nome_banco.length > 0 and
|
51
|
+
!self.get_data_geracao.nil? and
|
52
|
+
self.get_numero_sequencial > 0 and
|
53
|
+
self.get_versao_layout > 0 and
|
54
|
+
self.get_identificacao_servico.length > 0)
|
55
|
+
end
|
56
|
+
|
57
|
+
#-------------------------------------------------------------------
|
58
|
+
#-------------------------------------------------------------------
|
59
|
+
# Getters
|
60
|
+
def get_codigo_remessa
|
61
|
+
self.get_section_value(1).to_i
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_codigo_convenio
|
65
|
+
self.get_section_value(2)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_nome_empresa
|
69
|
+
self.get_section_value(3)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_codigo_banco
|
73
|
+
self.get_section_value(4).to_i
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_nome_banco
|
77
|
+
self.get_section_value(5)
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_data_geracao
|
81
|
+
data = self.get_section_value(6)
|
82
|
+
Date.new(data[0..3].to_i, data[4..5].to_i, data[6..7].to_i)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_numero_sequencial
|
86
|
+
data = self.get_section_value(7).to_i
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_versao_layout
|
90
|
+
data = self.get_section_value(8).to_i
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_identificacao_servico
|
94
|
+
data = self.get_section_value(9)
|
95
|
+
end
|
96
|
+
|
97
|
+
#-------------------------------------------------------------------
|
98
|
+
#-------------------------------------------------------------------
|
99
|
+
# Setters
|
100
|
+
def set_codigo_remessa code
|
101
|
+
code = code.to_i
|
102
|
+
|
103
|
+
if code == 1 or code == 2
|
104
|
+
self.set_section_value(1, code)
|
105
|
+
else
|
106
|
+
raise "#{get_id}: 1 = Remessa - Enviado pela Empresa para o Banco
|
107
|
+
2 = Retorno - Enviado pelo Banco para a Empresa
|
108
|
+
Valor: #{code}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def set_codigo_convenio code
|
113
|
+
code = code.to_s
|
114
|
+
|
115
|
+
if !code.nil? and
|
116
|
+
(code.length > 0 and code.length <= 20)
|
117
|
+
|
118
|
+
self.set_section_value(2, code)
|
119
|
+
else
|
120
|
+
raise "#{get_id}: Código atribuído pelo Banco, para seu controle interno.
|
121
|
+
Este código será informado à Empresa, pelo Banco, antes
|
122
|
+
da implantação do serviço de débito automático.
|
123
|
+
Valor: #{code}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_nome_empresa nome
|
128
|
+
nome = nome.to_s
|
129
|
+
|
130
|
+
if nome.to_s.length > 0
|
131
|
+
self.set_section_value(3, nome)
|
132
|
+
else
|
133
|
+
raise "#{get_id}: Nome da Empresa não pode estar vazio"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def set_codigo_banco codigo
|
138
|
+
codigo = codigo.to_i
|
139
|
+
|
140
|
+
if codigo > 0
|
141
|
+
self.set_section_value(4, codigo)
|
142
|
+
else
|
143
|
+
raise "#{get_id}: Código do Banco não pode estar vazio"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def set_nome_banco nome
|
148
|
+
nome = nome.to_s
|
149
|
+
|
150
|
+
if nome.to_s.length > 0
|
151
|
+
self.set_section_value(5, nome)
|
152
|
+
else
|
153
|
+
raise "#{get_id}: Nome do Banco não pode estar vazio"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def set_data_geracao data
|
158
|
+
begin
|
159
|
+
real_data = data.to_s
|
160
|
+
|
161
|
+
if data.length == 8
|
162
|
+
self.set_section_value(6, real_data)
|
163
|
+
else
|
164
|
+
raise
|
165
|
+
end
|
166
|
+
|
167
|
+
rescue
|
168
|
+
raise "#{get_id}: Data de Geração Inválida
|
169
|
+
Valor: #{data}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def set_numero_sequencial numero
|
174
|
+
numero = numero.to_i
|
175
|
+
|
176
|
+
if numero > 0
|
177
|
+
self.set_section_value(7, numero)
|
178
|
+
else
|
179
|
+
raise "#{get_id}: Número Sequencial deve ser positivo e maior que 0
|
180
|
+
Valor: #{numero}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def set_versao_layout versao
|
185
|
+
versao = versao.to_i
|
186
|
+
|
187
|
+
if versao > 0
|
188
|
+
self.set_section_value(8, versao)
|
189
|
+
else
|
190
|
+
raise "#{get_id}: Versão deve ser 05 (a partir de 05.05.2008)
|
191
|
+
Valor: #{versao}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def set_identificacao_servico identificacao
|
196
|
+
identificacao = identificacao.to_s
|
197
|
+
|
198
|
+
if identificacao.length > 0
|
199
|
+
self.set_section_value(9, identificacao)
|
200
|
+
else
|
201
|
+
raise "#{get_id}: Deve ser Débito Automático
|
202
|
+
Valor: #{identificacao}"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def set_reservado reservado
|
207
|
+
reservado = reservado.to_s
|
208
|
+
self.set_section_value(10, reservado)
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Cadastro Débito Automático - Banco
|
5
|
+
class Febraban150B < FormatSection
|
6
|
+
def initialize master
|
7
|
+
super(master, true, false)
|
8
|
+
|
9
|
+
@section = Section.new({
|
10
|
+
0 => Position.new(1, 1, false, "B", true), # Código do Registro
|
11
|
+
1 => Position.new(2, 25, false), # Identificação do Cliente Empresa
|
12
|
+
2 => Position.new(3, 4, false), # Agência para Débito
|
13
|
+
3 => Position.new(4, 14, false), # Identificação Cliente Banco
|
14
|
+
4 => Position.new(5, 8, true), # Data da Opção/Exclusão
|
15
|
+
5 => Position.new(6, 97, false), # Reservado pelo Sistema
|
16
|
+
6 => Position.new(7, 1, true) # Código de Movimento (1-Excluir, 2-Incluir)
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
#-------------------------------------------------------------------
|
21
|
+
#-------------------------------------------------------------------
|
22
|
+
# Gerais
|
23
|
+
def process_section file
|
24
|
+
self.set_id_cliente_empresa file[1..25]
|
25
|
+
self.set_agencia_debito file[26..29]
|
26
|
+
self.set_id_cliente_banco file[30..43]
|
27
|
+
self.set_data_opcao_exclusao file[44..51]
|
28
|
+
self.set_reservado file[52..148]
|
29
|
+
self.set_cod_movimento file[149..149]
|
30
|
+
end
|
31
|
+
|
32
|
+
#-------------------------------------------------------------------
|
33
|
+
#-------------------------------------------------------------------
|
34
|
+
# Validações
|
35
|
+
def is_valid?
|
36
|
+
result = (self.get_id_cliente_empresa.length > 0 and
|
37
|
+
self.get_agencia_debito.length > 0 and
|
38
|
+
self.get_nome_empresa.length > 0 and
|
39
|
+
!self.get_data_opcao_exclusao.nil? and
|
40
|
+
(self.get_cod_movimento == 0 or
|
41
|
+
self.get_cod_movimento == 1))
|
42
|
+
end
|
43
|
+
|
44
|
+
#-------------------------------------------------------------------
|
45
|
+
#-------------------------------------------------------------------
|
46
|
+
# Getters
|
47
|
+
def get_id_cliente_empresa
|
48
|
+
self.get_section_value(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_agencia_debito
|
52
|
+
self.get_section_value(2)
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_id_cliente_banco
|
56
|
+
self.get_section_value(3)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_data_opcao_exclusao
|
60
|
+
data = self.get_section_value(4)
|
61
|
+
Date.new(data[0..3].to_i, data[4..5].to_i, data[6..7].to_i)
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_cod_movimento
|
65
|
+
self.get_section_value(6).to_i
|
66
|
+
end
|
67
|
+
|
68
|
+
#-------------------------------------------------------------------
|
69
|
+
#-------------------------------------------------------------------
|
70
|
+
# Setters
|
71
|
+
def set_id_cliente_empresa id_cliente_empresa
|
72
|
+
id_cliente_empresa = id_cliente_empresa.to_s
|
73
|
+
|
74
|
+
if id_cliente_empresa.length > 0
|
75
|
+
self.set_section_value(1, id_cliente_empresa)
|
76
|
+
else
|
77
|
+
raise "#{self.get_id}: Identificação do Cliente da Empresa não pode estar vazio
|
78
|
+
Valor: #{id_cliente_empresa}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def set_agencia_debito agencia_debito
|
83
|
+
agencia_debito = agencia_debito.to_s
|
84
|
+
|
85
|
+
if agencia_debito.length > 0
|
86
|
+
self.set_section_value(2, agencia_debito)
|
87
|
+
else
|
88
|
+
raise "#{self.get_id}: Agência do Débito não pode estar vazia
|
89
|
+
Valor: #{agencia_debito}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_id_cliente_banco id_cliente_banco
|
94
|
+
id_cliente_banco = id_cliente_banco.to_s
|
95
|
+
|
96
|
+
if id_cliente_banco.length > 0
|
97
|
+
self.set_section_value(3, id_cliente_banco)
|
98
|
+
else
|
99
|
+
raise "#{self.get_id}: Identificação do Cliente do Banco não pode estar vazio
|
100
|
+
Valor: #{id_cliente_banco}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def set_data_opcao_exclusao data_opcao_exclusao
|
105
|
+
data_opcao_exclusao = data_opcao_exclusao.to_i
|
106
|
+
|
107
|
+
if data_opcao_exclusao > 0
|
108
|
+
self.set_section_value(4, data_opcao_exclusao)
|
109
|
+
else
|
110
|
+
raise "#{self.get_id}: Data de Opção/Exclusão não pode estar vazia
|
111
|
+
Valor: #{data_opcao_exclusao}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def set_reservado reservado
|
116
|
+
reservado = reservado.to_s
|
117
|
+
self.set_section_value(5, reservado)
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_cod_movimento cod_movimento
|
121
|
+
cod_movimento = cod_movimento.to_i
|
122
|
+
|
123
|
+
if cod_movimento == 0 or cod_movimento == 1
|
124
|
+
self.set_section_value(6, cod_movimento)
|
125
|
+
else
|
126
|
+
raise "#{self.get_id}: Código de Movimentação deve ser de Exclusão ou Inclusão:
|
127
|
+
1 = Exclusão de optante pelo débito automático
|
128
|
+
2 = Inclusão de optante pelo débito automático
|
129
|
+
Valor: #{cod_movimento}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Ocorrências - Empresa
|
5
|
+
class Febraban150C < FormatSection
|
6
|
+
def initialize master
|
7
|
+
super(master, false, true)
|
8
|
+
|
9
|
+
@section = Section.new({
|
10
|
+
0 => Position.new(1, 1, false, "C", true), # Código do Registro
|
11
|
+
1 => Position.new(2, 25, false), # Identificação do Cliente Empresa
|
12
|
+
2 => Position.new(3, 4, false), # Agência para Débito
|
13
|
+
3 => Position.new(4, 14, false), # Identificação Cliente Banco
|
14
|
+
4 => Position.new(5, 40, false), # Ocorrência 1 - Motivo Recusa
|
15
|
+
5 => Position.new(6, 40, false), # Ocorrência 2 - Complemento
|
16
|
+
6 => Position.new(7, 25, false), # Reservado pelo Sistema
|
17
|
+
7 => Position.new(8, 1, true) # Código de Movimento (Seção B)
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
#-------------------------------------------------------------------
|
22
|
+
#-------------------------------------------------------------------
|
23
|
+
# Gerais
|
24
|
+
def process_section file
|
25
|
+
self.set_id_cliente_empresa file[1..25]
|
26
|
+
self.set_agencia_debito file[26..29]
|
27
|
+
self.set_id_cliente_banco file[30..43]
|
28
|
+
self.set_ocorrencia_1 file[44..83]
|
29
|
+
self.set_ocorrencia_2 file[84..123]
|
30
|
+
self.set_reservado file[124..148]
|
31
|
+
self.set_cod_movimento file[149..149]
|
32
|
+
end
|
33
|
+
|
34
|
+
#-------------------------------------------------------------------
|
35
|
+
#-------------------------------------------------------------------
|
36
|
+
# Validações
|
37
|
+
def is_valid?
|
38
|
+
result = (self.get_id_cliente_empresa.length > 0 and
|
39
|
+
self.get_agencia_debito.length > 0 and
|
40
|
+
self.get_id_cliente_banco.length > 0 and
|
41
|
+
self.get_ocorrencia_1.length > 0 and
|
42
|
+
self.get_ocorrencia_2.length > 0 and
|
43
|
+
(self.get_cod_movimento == 0 or
|
44
|
+
self.get_cod_movimento == 1))
|
45
|
+
end
|
46
|
+
|
47
|
+
#-------------------------------------------------------------------
|
48
|
+
#-------------------------------------------------------------------
|
49
|
+
# Getters
|
50
|
+
def get_id_cliente_empresa
|
51
|
+
self.get_section_value(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_agencia_debito
|
55
|
+
self.get_section_value(2)
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_id_cliente_banco
|
59
|
+
self.get_section_value(3)
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_ocorrencia_1
|
63
|
+
self.get_section_value(4)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_ocorrencia_2
|
67
|
+
self.get_section_value(5)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_cod_movimento
|
71
|
+
self.get_section_value(7).to_i
|
72
|
+
end
|
73
|
+
|
74
|
+
#-------------------------------------------------------------------
|
75
|
+
#-------------------------------------------------------------------
|
76
|
+
# Setters
|
77
|
+
def set_id_cliente_empresa id_cliente_empresa
|
78
|
+
id_cliente_empresa = id_cliente_empresa.to_s
|
79
|
+
|
80
|
+
if id_cliente_empresa.length > 0
|
81
|
+
self.set_section_value(1, id_cliente_empresa)
|
82
|
+
else
|
83
|
+
raise "#{self.get_id}: Identificação do Cliente da Empresa não pode estar vazio
|
84
|
+
Valor: #{id_cliente_empresa}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def set_agencia_debito agencia_debito
|
89
|
+
agencia_debito = agencia_debito.to_s
|
90
|
+
|
91
|
+
if agencia_debito.length > 0
|
92
|
+
self.set_section_value(2, agencia_debito)
|
93
|
+
else
|
94
|
+
raise "#{self.get_id}: Agência do Débito não pode estar vazia
|
95
|
+
Valor: #{agencia_debito}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def set_id_cliente_banco id_cliente_banco
|
100
|
+
id_cliente_banco = id_cliente_banco.to_s
|
101
|
+
|
102
|
+
if id_cliente_banco.length > 0
|
103
|
+
self.set_section_value(3, id_cliente_banco)
|
104
|
+
else
|
105
|
+
raise "#{self.get_id}: Identificação do Cliente do Banco não pode estar vazio
|
106
|
+
Valor: #{id_cliente_banco}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_ocorrencia_1 ocorrencia
|
111
|
+
ocorrencia = ocorrencia.to_s
|
112
|
+
|
113
|
+
if ocorrencia.length > 0
|
114
|
+
self.set_section_value(4, ocorrencia)
|
115
|
+
else
|
116
|
+
raise "#{self.get_id}: Motivo de Recusa não pode estar vazio
|
117
|
+
Valor: #{ocorrencia}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def set_ocorrencia_2 ocorrencia
|
122
|
+
ocorrencia = ocorrencia.to_s
|
123
|
+
|
124
|
+
if ocorrencia.length > 0
|
125
|
+
self.set_section_value(5, ocorrencia)
|
126
|
+
else
|
127
|
+
raise "#{self.get_id}: Motivo de Recusa não pode estar vazio
|
128
|
+
Valor: #{ocorrencia}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def set_reservado reservado
|
133
|
+
reservado = reservado.to_s
|
134
|
+
self.set_section_value(6, reservado)
|
135
|
+
end
|
136
|
+
|
137
|
+
def set_cod_movimento cod_movimento
|
138
|
+
cod_movimento = cod_movimento.to_i
|
139
|
+
|
140
|
+
if cod_movimento == 0 or cod_movimento == 1
|
141
|
+
self.set_section_value(7, cod_movimento)
|
142
|
+
else
|
143
|
+
raise "#{self.get_id}: Código de Movimentação deve ser de Exclusão ou Inclusão:
|
144
|
+
1 = Exclusão de optante pelo débito automático
|
145
|
+
2 = Inclusão de optante pelo débito automático
|
146
|
+
Valor: #{cod_movimento}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|