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,149 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Alteração da Identificação Cliente/Empresa - Empresa
|
5
|
+
class Febraban150D < FormatSection
|
6
|
+
def initialize master
|
7
|
+
super(master, false, true)
|
8
|
+
|
9
|
+
@section = Section.new({
|
10
|
+
0 => Position.new(1, 1, false, "D", true), # Código do Registro
|
11
|
+
1 => Position.new(2, 25, false), # Identificação do Cliente Empresa Old
|
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, 25, false), # Identificação do Cliente Empresa New
|
15
|
+
5 => Position.new(6, 60, false), # Ocorrência
|
16
|
+
6 => Position.new(7, 20, false), # Reservado pelo Sistema
|
17
|
+
7 => Position.new(8, 1, true) # Código de Movimento (0-Alteração, 1-Cancelar)
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
#-------------------------------------------------------------------
|
22
|
+
#-------------------------------------------------------------------
|
23
|
+
# Gerais
|
24
|
+
def process_section file
|
25
|
+
self.set_id_cliente_empresa_old file[1..25]
|
26
|
+
self.set_agencia_debito file[26..29]
|
27
|
+
self.set_id_cliente_banco file[30..43]
|
28
|
+
self.set_id_cliente_empresa_new file[44..68]
|
29
|
+
self.set_ocorrencia file[69..128]
|
30
|
+
self.set_reservado file[129..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_old.length > 0 and
|
39
|
+
self.get_agencia_debito.length > 0 and
|
40
|
+
self.get_id_cliente_banco.length > 0 and
|
41
|
+
self.get_id_cliente_empresa_new.length > 0 and
|
42
|
+
self.get_ocorrencia.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_old
|
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_id_cliente_empresa_new
|
63
|
+
self.get_section_value(4)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_ocorrencia
|
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_old 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 Anterior 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_id_cliente_empresa_new id_cliente_empresa
|
111
|
+
id_cliente_empresa = id_cliente_empresa.to_s
|
112
|
+
|
113
|
+
if id_cliente_empresa.length > 0
|
114
|
+
self.set_section_value(4, id_cliente_empresa)
|
115
|
+
else
|
116
|
+
raise "#{self.get_id}: Identificação do Cliente da Empresa Novo não pode estar vazio
|
117
|
+
Valor: #{id_cliente_empresa}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def set_ocorrencia 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 Alteração 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
|
+
0 = Alteração da Identificação do Cliente na Empresa
|
145
|
+
1 = Exclusão de optante do Débito Automático, solicitado pela Empresa
|
146
|
+
Valor: #{cod_movimento}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Débito em Conta - Empresa
|
5
|
+
class Febraban150E < FormatSection
|
6
|
+
def initialize master
|
7
|
+
super(master, false, true)
|
8
|
+
|
9
|
+
@section = Section.new({
|
10
|
+
0 => Position.new(1, 1, false, "E", 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 do Vencimento
|
15
|
+
5 => Position.new(6, 15, true), # Valor do Débito
|
16
|
+
6 => Position.new(7, 2, false), # Código da Moeda (01-UFIR, 03-REAL)
|
17
|
+
7 => Position.new(8, 60, false), # Uso da Empresa, sem processamento
|
18
|
+
8 => Position.new(9, 1, true), # Tipo de Identificação (1-CPF, 2-CNPJ)
|
19
|
+
9 => Position.new(10, 15, true), # Identificação
|
20
|
+
10 => Position.new(11, 4, false), # Reservado pelo Sistema
|
21
|
+
11 => Position.new(12, 1, true) # Código de Movimento (0-Normal, 1-Cancelar)
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
#-------------------------------------------------------------------
|
26
|
+
#-------------------------------------------------------------------
|
27
|
+
# Gerais
|
28
|
+
def process_section file
|
29
|
+
self.set_id_cliente_empresa file[1..25]
|
30
|
+
self.set_agencia_debito file[26..29]
|
31
|
+
self.set_id_cliente_banco file[30..43]
|
32
|
+
self.set_data_vencimento file[44..51]
|
33
|
+
self.set_valor_debito file[52..66]
|
34
|
+
self.set_codigo_moeda file[67..68]
|
35
|
+
self.set_obs_empresa file[69..128]
|
36
|
+
self.set_tipo_id_cliente file[129..129]
|
37
|
+
self.set_id_cliente file[130..144]
|
38
|
+
self.set_reservado file[145..148]
|
39
|
+
self.set_cod_movimento file[149..149]
|
40
|
+
end
|
41
|
+
|
42
|
+
#-------------------------------------------------------------------
|
43
|
+
#-------------------------------------------------------------------
|
44
|
+
# Validações
|
45
|
+
def is_valid?
|
46
|
+
result = (self.get_id_cliente_empresa.length > 0 and
|
47
|
+
self.get_id_cliente_banco.length > 0 and
|
48
|
+
!self.get_data_vencimento.nil? and
|
49
|
+
self.get_valor_debito > 0 and
|
50
|
+
self.get_codigo_moeda.length > 0 and
|
51
|
+
self.get_obs_empresa.length > 0 and
|
52
|
+
(self.get_tipo_id_cliente == 1 or
|
53
|
+
self.get_tipo_id_cliente == 2) and
|
54
|
+
self.get_id_cliente.length == 15 and
|
55
|
+
(self.get_cod_movimento == 0 or
|
56
|
+
self.get_cod_movimento == 1))
|
57
|
+
end
|
58
|
+
|
59
|
+
#-------------------------------------------------------------------
|
60
|
+
#-------------------------------------------------------------------
|
61
|
+
# Getters
|
62
|
+
def get_id_cliente_empresa
|
63
|
+
self.get_section_value(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_agencia_debito
|
67
|
+
self.get_section_value(2)
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_id_cliente_banco
|
71
|
+
self.get_section_value(3)
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_data_vencimento
|
75
|
+
data = self.get_section_value(4)
|
76
|
+
Date.new(data[0..3].to_i, data[4..5].to_i, data[6..7].to_i)
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_valor_debito
|
80
|
+
self.get_section_value(5).to_i
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_codigo_moeda
|
84
|
+
self.get_section_value(6)
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_obs_empresa
|
88
|
+
self.get_section_value(7)
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_tipo_id_cliente
|
92
|
+
self.get_section_value(8).to_i
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_id_cliente
|
96
|
+
self.get_section_value(9).to_i
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_cod_movimento
|
100
|
+
self.get_section_value(11).to_i
|
101
|
+
end
|
102
|
+
|
103
|
+
#-------------------------------------------------------------------
|
104
|
+
#-------------------------------------------------------------------
|
105
|
+
# Setters
|
106
|
+
def set_id_cliente_empresa id_cliente_empresa
|
107
|
+
id_cliente_empresa = id_cliente_empresa.to_s
|
108
|
+
|
109
|
+
if id_cliente_empresa.length > 0
|
110
|
+
self.set_section_value(1, id_cliente_empresa)
|
111
|
+
else
|
112
|
+
raise "#{self.get_id}: Identificação do Cliente da Empresa não pode estar vazio
|
113
|
+
Valor: #{id_cliente_empresa}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def set_agencia_debito agencia_debito
|
118
|
+
agencia_debito = agencia_debito.to_s
|
119
|
+
|
120
|
+
if agencia_debito.length > 0
|
121
|
+
self.set_section_value(2, agencia_debito)
|
122
|
+
else
|
123
|
+
raise "#{self.get_id}: Agência do Débito não pode estar vazia
|
124
|
+
Valor: #{agencia_debito}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def set_id_cliente_banco id_cliente_banco
|
129
|
+
id_cliente_banco = id_cliente_banco.to_s
|
130
|
+
|
131
|
+
if id_cliente_banco.length > 0
|
132
|
+
self.set_section_value(3, id_cliente_banco)
|
133
|
+
else
|
134
|
+
raise "#{self.get_id}: Identificação do Cliente do Banco não pode estar vazio
|
135
|
+
Valor: #{id_cliente_banco}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def set_data_vencimento data_vencimento
|
140
|
+
data_vencimento = data_vencimento.to_i
|
141
|
+
|
142
|
+
if data_vencimento > 0
|
143
|
+
self.set_section_value(4, data_vencimento)
|
144
|
+
else
|
145
|
+
raise "#{self.get_id}: Data de Vencimento não pode estar vazia
|
146
|
+
Valor: #{data_vencimento}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def set_valor_debito valor_debito
|
151
|
+
valor_debito = valor_debito.to_i
|
152
|
+
|
153
|
+
if valor_debito > 0
|
154
|
+
self.set_section_value(5, valor_debito)
|
155
|
+
else
|
156
|
+
raise "#{self.get_id}: Valor do Débito deve ser positivo e maior que 0
|
157
|
+
Valor: #{valor_debito}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def set_codigo_moeda codigo_moeda
|
162
|
+
codigo_moeda = codigo_moeda.to_s
|
163
|
+
|
164
|
+
if codigo_moeda.length > 0
|
165
|
+
self.set_section_value(6, codigo_moeda)
|
166
|
+
else
|
167
|
+
raise "#{self.get_id}: Código da Moeda não pode estar vazio
|
168
|
+
Valor: #{codigo_moeda}"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def set_obs_empresa obs_empresa
|
173
|
+
obs_empresa = obs_empresa.to_s
|
174
|
+
|
175
|
+
if obs_empresa.length > 0
|
176
|
+
self.set_section_value(7, obs_empresa)
|
177
|
+
else
|
178
|
+
raise "#{self.get_id}: Observação da Empresa não pode estar vazia
|
179
|
+
Valor: #{obs_empresa}"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def set_tipo_id_cliente tipo_id_cliente
|
184
|
+
tipo_id_cliente = tipo_id_cliente.to_i
|
185
|
+
|
186
|
+
if tipo_id_cliente == 1 or tipo_id_cliente == 2 or tipo_id_cliente.to_s.length == 0
|
187
|
+
self.set_section_value(8, tipo_id_cliente)
|
188
|
+
else
|
189
|
+
raise "#{self.get_id}: Tipo de Identificação do Cliente deve ser:
|
190
|
+
1 - CNPJ; 2 - CPF
|
191
|
+
Valor: #{tipo_id_cliente}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def set_id_cliente id_cliente
|
196
|
+
id_cliente = id_cliente.to_s
|
197
|
+
id_cliente.to_i
|
198
|
+
|
199
|
+
if id_cliente.length == 15 or id_cliente.length == 0
|
200
|
+
self.set_section_value(9, id_cliente)
|
201
|
+
else
|
202
|
+
raise "#{self.get_id}: Identificação do Cliente deve ser CPF ou CNPJ:
|
203
|
+
CNPJ: 999999999 = Número, 9999 = Filial, e 99 = DV
|
204
|
+
CPF: 0000999999999 = Número, 99 = DV
|
205
|
+
Valor: #{id_cliente}"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def set_reservado reservado
|
210
|
+
reservado = reservado.to_s
|
211
|
+
self.set_section_value(10, reservado)
|
212
|
+
end
|
213
|
+
|
214
|
+
def set_cod_movimento cod_movimento
|
215
|
+
cod_movimento = cod_movimento.to_i
|
216
|
+
|
217
|
+
if cod_movimento == 0 or cod_movimento == 1
|
218
|
+
self.set_section_value(11, cod_movimento)
|
219
|
+
else
|
220
|
+
raise "#{self.get_id}: Código de Movimentação deve ser de Débito Nacional ou Cnacelamento:
|
221
|
+
0 = Débito Normal
|
222
|
+
1 = Cancelamento (exclusão) de lançamento enviado anteriormente para o Banco
|
223
|
+
Valor: #{cod_movimento}"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
|
2
|
+
#-------------------------------------------------------------------
|
3
|
+
#-------------------------------------------------------------------
|
4
|
+
# Retorno do Débito Automático - Banco
|
5
|
+
class Febraban150F < FormatSection
|
6
|
+
def initialize master
|
7
|
+
super(master, true, false)
|
8
|
+
|
9
|
+
@section = Section.new({
|
10
|
+
0 => Position.new(1, 1, false, "F", 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 Vencimento/Débito
|
15
|
+
5 => Position.new(6, 15, true), # Valor Original/Debitado
|
16
|
+
6 => Position.new(7, 2, false), # Código de Retorno
|
17
|
+
7 => Position.new(8, 60, false), # Uso da Empresa (Seção E)
|
18
|
+
8 => Position.new(9, 1, true), # Tipo de Identificação (1-CPF, 2-CNPJ)
|
19
|
+
9 => Position.new(10, 15, true), # Identificação
|
20
|
+
10 => Position.new(11, 4, false), # Reservado pelo Sistema
|
21
|
+
11 => Position.new(12, 1, true) # Código de movimento (Seção E)
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
#-------------------------------------------------------------------
|
26
|
+
#-------------------------------------------------------------------
|
27
|
+
# Gerais
|
28
|
+
def process_section file
|
29
|
+
self.set_id_cliente_empresa file[1..25]
|
30
|
+
self.set_agencia_debito file[26..29]
|
31
|
+
self.set_id_cliente_banco file[30..43]
|
32
|
+
self.set_data_vencimento_debito file[44..51]
|
33
|
+
self.set_valor file[52..66]
|
34
|
+
self.set_codigo_retorno file[67..68]
|
35
|
+
self.set_obs_empresa file[69..128]
|
36
|
+
self.set_tipo_id_cliente file[129..129]
|
37
|
+
self.set_id_cliente file[130..144]
|
38
|
+
self.set_reservado file[145..148]
|
39
|
+
self.set_cod_movimento file[149..149]
|
40
|
+
end
|
41
|
+
|
42
|
+
#-------------------------------------------------------------------
|
43
|
+
#-------------------------------------------------------------------
|
44
|
+
# Validações
|
45
|
+
def is_valid?
|
46
|
+
result = (self.get_id_cliente_empresa.length > 0 and
|
47
|
+
self.get_id_cliente_banco.length > 0 and
|
48
|
+
self.get_agencia_debito.length > 0 and
|
49
|
+
!self.get_data_vencimento_debito.nil? and
|
50
|
+
self.get_valor > 0 and
|
51
|
+
(self.get_codigo_retorno >= 0 or
|
52
|
+
self.get_codigo_retorno <= 99) and
|
53
|
+
self.get_obs_empresa.length > 0 and
|
54
|
+
(self.get_tipo_id_cliente == 1 or
|
55
|
+
self.get_tipo_id_cliente == 2) and
|
56
|
+
self.get_id_cliente.to_s.length > 0 and
|
57
|
+
(self.get_cod_movimento == 0 or
|
58
|
+
self.get_cod_movimento == 1))
|
59
|
+
end
|
60
|
+
|
61
|
+
#-------------------------------------------------------------------
|
62
|
+
#-------------------------------------------------------------------
|
63
|
+
# Getters
|
64
|
+
def get_id_cliente_empresa
|
65
|
+
self.get_section_value(1)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_agencia_debito
|
69
|
+
self.get_section_value(2)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_id_cliente_banco
|
73
|
+
self.get_section_value(3)
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_data_vencimento_debito
|
77
|
+
data = self.get_section_value(4)
|
78
|
+
Date.new(data[0..3].to_i, data[4..5].to_i, data[6..7].to_i)
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_valor
|
82
|
+
self.get_section_value(5).to_i
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_codigo_retorno
|
86
|
+
self.get_section_value(6).to_i
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_obs_empresa
|
90
|
+
self.get_section_value(7)
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_tipo_id_cliente
|
94
|
+
self.get_section_value(8).to_i
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_id_cliente
|
98
|
+
self.get_section_value(9).to_i
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_cod_movimento
|
102
|
+
self.get_section_value(11).to_i
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_mensagem_retorno
|
106
|
+
case self.get_codigo_retorno
|
107
|
+
when 0
|
108
|
+
"Débito efetuado"
|
109
|
+
when 1
|
110
|
+
"Débito não efetuado - Insuficiência de fundos"
|
111
|
+
when 2
|
112
|
+
"Débito não efetuado - Conta não cadastrada"
|
113
|
+
when 4
|
114
|
+
"Débito não efetuado - Outras restrições"
|
115
|
+
when 5
|
116
|
+
"Débito não efetuado – valor do débito excede valor limite aprovado"
|
117
|
+
when 10
|
118
|
+
"Débito não efetuado - Agência em regime de encerramento"
|
119
|
+
when 12
|
120
|
+
"Débito não efetuado - Valor inválido"
|
121
|
+
when 13
|
122
|
+
"Débito não efetuado - Data de lançamento inválida"
|
123
|
+
when 14
|
124
|
+
"Débito não efetuado - Agência inválida"
|
125
|
+
when 15
|
126
|
+
"Débito não efetuado - conta inválida"
|
127
|
+
when 18
|
128
|
+
"Débito não efetuado - Data do débito anterior à do processamento"
|
129
|
+
when 19
|
130
|
+
"Débito não efetuado – Agência/Conta não pertence ao CPF/CNPJ informado"
|
131
|
+
when 20
|
132
|
+
"Débito não efetuado – conta conjunta não solidária"
|
133
|
+
when 30
|
134
|
+
"Débito não efetuado - Sem contrato de débito automático"
|
135
|
+
when 31
|
136
|
+
"Débito efetuado em data diferente da data informada – feriado na praça de débito"
|
137
|
+
when 96
|
138
|
+
"Manutenção do Cadastro"
|
139
|
+
when 97
|
140
|
+
"Cancelamento - Não encontrado"
|
141
|
+
when 98
|
142
|
+
"Cancelamento - Não efetuado, fora do tempo hábil"
|
143
|
+
when 99
|
144
|
+
"Cancelamento - cancelado conforme solicitação"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
#-------------------------------------------------------------------
|
149
|
+
#-------------------------------------------------------------------
|
150
|
+
# Setters
|
151
|
+
def set_id_cliente_empresa id_cliente_empresa
|
152
|
+
id_cliente_empresa = id_cliente_empresa.to_s
|
153
|
+
|
154
|
+
if id_cliente_empresa.length > 0
|
155
|
+
self.set_section_value(1, id_cliente_empresa)
|
156
|
+
else
|
157
|
+
raise "#{self.get_id}: Identificação do Cliente da Empresa não pode estar vazio
|
158
|
+
Valor: #{id_cliente_empresa}"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def set_agencia_debito agencia_debito
|
163
|
+
agencia_debito = agencia_debito.to_s
|
164
|
+
|
165
|
+
if agencia_debito.length > 0
|
166
|
+
self.set_section_value(2, agencia_debito)
|
167
|
+
else
|
168
|
+
raise "#{self.get_id}: Agência do Débito não pode estar vazia
|
169
|
+
Valor: #{agencia_debito}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def set_id_cliente_banco id_cliente_banco
|
174
|
+
id_cliente_banco = id_cliente_banco.to_s
|
175
|
+
|
176
|
+
if id_cliente_banco.length > 0
|
177
|
+
self.set_section_value(3, id_cliente_banco)
|
178
|
+
else
|
179
|
+
raise "#{self.get_id}: Identificação do Cliente do Banco não pode estar vazio
|
180
|
+
Valor: #{id_cliente_banco}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def set_data_vencimento_debito data_vencimento
|
185
|
+
data_vencimento = data_vencimento.to_i
|
186
|
+
|
187
|
+
if data_vencimento > 0
|
188
|
+
self.set_section_value(4, data_vencimento)
|
189
|
+
else
|
190
|
+
raise "#{self.get_id}: Data de Vencimento não pode estar vazia
|
191
|
+
Valor: #{data_vencimento}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def set_valor valor
|
196
|
+
valor = valor.to_i
|
197
|
+
|
198
|
+
if valor > 0
|
199
|
+
self.set_section_value(5, valor)
|
200
|
+
else
|
201
|
+
raise "#{self.get_id}: Valor deve ser positivo e maior que 0
|
202
|
+
Valor: #{valor}"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def set_codigo_retorno codigo
|
207
|
+
numero = codigo.to_i
|
208
|
+
|
209
|
+
if numero >= 0 and numero <= 99
|
210
|
+
self.set_section_value(6, codigo)
|
211
|
+
else
|
212
|
+
raise "#{self.get_id}: Valor deve ser positivo e maior que 0
|
213
|
+
Valor: #{valor}"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def set_obs_empresa obs_empresa
|
218
|
+
obs_empresa = obs_empresa.to_s
|
219
|
+
|
220
|
+
if obs_empresa.length > 0
|
221
|
+
self.set_section_value(7, obs_empresa)
|
222
|
+
else
|
223
|
+
raise "#{self.get_id}: Observação da Empresa não pode estar vazia
|
224
|
+
Valor: #{obs_empresa}"
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def set_tipo_id_cliente tipo_id_cliente
|
229
|
+
tipo_id_cliente = tipo_id_cliente.to_i
|
230
|
+
|
231
|
+
if tipo_id_cliente == 1 or tipo_id_cliente == 2
|
232
|
+
self.set_section_value(8, tipo_id_cliente)
|
233
|
+
else
|
234
|
+
raise "#{self.get_id}: Tipo de Identificação do Cliente deve ser:
|
235
|
+
1 - CNPJ; 2 - CPF
|
236
|
+
Valor: #{tipo_id_cliente}"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def set_id_cliente id_cliente
|
241
|
+
id_cliente = id_cliente.to_s
|
242
|
+
id_cliente.to_i
|
243
|
+
|
244
|
+
if id_cliente.length == 15
|
245
|
+
self.set_section_value(9, id_cliente)
|
246
|
+
else
|
247
|
+
raise "#{self.get_id}: Identificação do Cliente deve ser CPF ou CNPJ:
|
248
|
+
CNPJ: 999999999 = Número, 9999 = Filial, e 99 = DV
|
249
|
+
CPF: 0000999999999 = Número, 99 = DV
|
250
|
+
Valor: #{id_cliente}"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def set_reservado reservado
|
255
|
+
reservado = reservado.to_s
|
256
|
+
self.set_section_value(10, reservado)
|
257
|
+
end
|
258
|
+
|
259
|
+
def set_cod_movimento cod_movimento
|
260
|
+
cod_movimento = cod_movimento.to_i
|
261
|
+
|
262
|
+
if cod_movimento == 0 or cod_movimento == 1
|
263
|
+
self.set_section_value(11, cod_movimento)
|
264
|
+
else
|
265
|
+
raise "#{self.get_id}: Código de Movimentação deve ser de Débito Nacional ou Cnacelamento:
|
266
|
+
0 = Débito Normal
|
267
|
+
1 = Cancelamento (exclusão) de lançamento enviado anteriormente para o Banco
|
268
|
+
Valor: #{cod_movimento}"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|