formatos-febraban 0.2.24 → 0.2.25
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 +4 -4
- data/lib/formatos/cielo/cielo.rb +38 -11
- data/lib/formatos/cielo/cielo_detalhe.rb +71 -35
- data/lib/formatos/cielo/cielo_header.rb +28 -12
- data/lib/formatos/cielo/cielo_trailler.rb +37 -8
- data/lib/formatos/febraban/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dfe4df7c2f0b4704b79a7da9e5c711913d9e6e
|
4
|
+
data.tar.gz: 1f338f19f0520664f7f9ab530c19340442dffa7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31354ae8e856a1b0fe201c9f9c4e6253220cf956c859f4079c374e19f8b93162c7bbbd257e813fa61b1522ef03529708e24659e155849757ec3420994f41336a
|
7
|
+
data.tar.gz: 0d421331e8718d161ad6edcc306a85817f994e1a95e8736df699d86ff40cf3d4fc536ea4e59c9366efad08a40d46ac5403f0cc06197731c053a8752c92c749c7
|
data/lib/formatos/cielo/cielo.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
class Cielo
|
2
2
|
require 'date'
|
3
3
|
|
4
|
+
SECTION_TYPES = {header: '00', client: "01", trailler: '99'}
|
5
|
+
|
6
|
+
|
4
7
|
VERSAO = "01"
|
5
8
|
|
6
9
|
# Carrega todas as dependências de Layout
|
@@ -52,7 +55,7 @@ class Cielo
|
|
52
55
|
def create_header(params = {})
|
53
56
|
|
54
57
|
if self.get_header.nil?
|
55
|
-
section = self.get_new_section(
|
58
|
+
section = self.get_new_section(:header)
|
56
59
|
|
57
60
|
|
58
61
|
section.set_data_deposito params[:data_deposito]
|
@@ -78,7 +81,7 @@ class Cielo
|
|
78
81
|
|
79
82
|
self.valida_existe_header
|
80
83
|
|
81
|
-
section = self.get_new_section(
|
84
|
+
section = self.get_new_section(:client)
|
82
85
|
|
83
86
|
section.set_sequencial params[:sequencial]
|
84
87
|
section.set_numero_cartao params[:numero_cartao]
|
@@ -115,8 +118,8 @@ class Cielo
|
|
115
118
|
self.valida_existe_header
|
116
119
|
|
117
120
|
if self.get_trailler.nil?
|
118
|
-
if self.get_section(
|
119
|
-
section = self.get_new_section(
|
121
|
+
if self.get_section(SECTION_TYPES[:client]).length > 0
|
122
|
+
section = self.get_new_section(:trailler)
|
120
123
|
section.set_total_registros self.sections.length + 1
|
121
124
|
section.set_valor_total self.calculate_valor_total
|
122
125
|
section.set_valor_aceito
|
@@ -151,11 +154,11 @@ class Cielo
|
|
151
154
|
protected
|
152
155
|
def get_new_section section_type
|
153
156
|
case section_type
|
154
|
-
when
|
157
|
+
when :header
|
155
158
|
CieloHeader.new(self)
|
156
|
-
when
|
159
|
+
when :client
|
157
160
|
CieloDetalhe.new(self)
|
158
|
-
when
|
161
|
+
when :trailler
|
159
162
|
CieloTrailler.new(self)
|
160
163
|
end
|
161
164
|
end
|
@@ -176,7 +179,7 @@ class Cielo
|
|
176
179
|
self.sections.select {|c| c.is_section?(section) == true }
|
177
180
|
end
|
178
181
|
|
179
|
-
def
|
182
|
+
def is_valid?
|
180
183
|
self.sections.select {|b| b.is_valid? == false }.length == 0
|
181
184
|
end
|
182
185
|
|
@@ -185,11 +188,11 @@ class Cielo
|
|
185
188
|
end
|
186
189
|
|
187
190
|
def get_header
|
188
|
-
self.get_section(
|
191
|
+
self.get_section(SECTION_TYPES[:header]).first()
|
189
192
|
end
|
190
193
|
|
191
194
|
def get_trailler
|
192
|
-
self.get_section(
|
195
|
+
self.get_section(SECTION_TYPES[:trailler]).first()
|
193
196
|
end
|
194
197
|
|
195
198
|
#--------------------------------------------------------------------------------------
|
@@ -198,8 +201,32 @@ class Cielo
|
|
198
201
|
|
199
202
|
protected
|
200
203
|
def calculate_valor_total
|
201
|
-
self.get_section(
|
204
|
+
self.get_section(SECTION_TYPES[:client]).inject(0) do |sum, section|
|
202
205
|
sum += section.get_valor
|
203
206
|
end
|
204
207
|
end
|
208
|
+
|
209
|
+
#--------------------------------------------------------------------------------------
|
210
|
+
#--------------------------------------------------------------------------------------
|
211
|
+
# Carregamento de Arquivo
|
212
|
+
protected
|
213
|
+
def process_file location
|
214
|
+
file = File.new(location, "r")
|
215
|
+
|
216
|
+
while (line = file.gets)
|
217
|
+
process_string line
|
218
|
+
end
|
219
|
+
|
220
|
+
file.close
|
221
|
+
end
|
222
|
+
|
223
|
+
def process_string file
|
224
|
+
section_type = file[0,2]
|
225
|
+
|
226
|
+
section = get_new_section SECTION_TYPES.key(section_type)
|
227
|
+
section.process_section(file)
|
228
|
+
|
229
|
+
self.add_section section
|
230
|
+
end
|
231
|
+
|
205
232
|
end
|
@@ -8,7 +8,7 @@ class CieloDetalhe < FormatSection
|
|
8
8
|
0 => Position.new(1, 2, false, "01", true), # Tipo do Registro
|
9
9
|
1 => Position.new(2, 7, true), # Numero Sequencial
|
10
10
|
2 => Position.new(3, 19, true), # Numero do Cartao
|
11
|
-
3 => Position.new(4, 6,
|
11
|
+
3 => Position.new(4, 6, false, "000000"), # Código de Autorização
|
12
12
|
4 => Position.new(5, 8, false), # Data da Venda
|
13
13
|
5 => Position.new(6, 1, true), # Opção da Venda
|
14
14
|
6 => Position.new(7, 15, true), # Valor da venda
|
@@ -36,6 +36,38 @@ class CieloDetalhe < FormatSection
|
|
36
36
|
})
|
37
37
|
end
|
38
38
|
|
39
|
+
#-------------------------------------------------------------------
|
40
|
+
#-------------------------------------------------------------------
|
41
|
+
# Gerais
|
42
|
+
def process_section file
|
43
|
+
self.set_sequencial file[2..8]
|
44
|
+
self.set_numero_cartao file[9..27]
|
45
|
+
self.set_codigo_autorizacao file[28..33]
|
46
|
+
self.set_data_venda file[34..41]
|
47
|
+
self.set_opcao_venda file[42..42]
|
48
|
+
self.set_valor_venda file[43..57]
|
49
|
+
self.numero_parcelas file[58..60]
|
50
|
+
self.set_reservado_1 file[61..75]
|
51
|
+
self.set_reservado_2 file[76..90]
|
52
|
+
self.set_reservado_3 file[91..105]
|
53
|
+
self.set_valor_parcela file[106..120]
|
54
|
+
self.set_numero_lote file[121..127]
|
55
|
+
self.set_reservado_4 file[128..130]
|
56
|
+
self.set_numero_cielo file[131..140]
|
57
|
+
self.set_reservado_5 file[141..170]
|
58
|
+
self.set_status_venda file[171..172]
|
59
|
+
self.set_data_liquidacao file[173..180]
|
60
|
+
self.set_validade_cartao file[181..184]
|
61
|
+
self.set_reservado_6 file[185..191]
|
62
|
+
self.set_reservado_7 file[192..206]
|
63
|
+
self.set_reservado_8 file[207..209]
|
64
|
+
self.set_codigo_erro file[210..213]
|
65
|
+
self.set_reservado_9 file[214..224]
|
66
|
+
self.set_cartao_novo file[225..243]
|
67
|
+
self.set_vencimento_novo file[244..247]
|
68
|
+
self.set_reservado_10 file[248..249]
|
69
|
+
end
|
70
|
+
|
39
71
|
def get_sequencial
|
40
72
|
self.get_section_value(1)
|
41
73
|
end
|
@@ -64,6 +96,10 @@ class CieloDetalhe < FormatSection
|
|
64
96
|
self.get_section_value(18)
|
65
97
|
end
|
66
98
|
|
99
|
+
def get_status_venda
|
100
|
+
self.get_section_value(16)
|
101
|
+
end
|
102
|
+
|
67
103
|
def set_sequencial valor
|
68
104
|
self.set_section_value(1, valor)
|
69
105
|
end
|
@@ -72,8 +108,8 @@ class CieloDetalhe < FormatSection
|
|
72
108
|
self.set_section_value(2, valor)
|
73
109
|
end
|
74
110
|
|
75
|
-
def set_codigo_autorizacao
|
76
|
-
self.set_section_value(3,
|
111
|
+
def set_codigo_autorizacao valor = "000000"
|
112
|
+
self.set_section_value(3, valor)
|
77
113
|
end
|
78
114
|
|
79
115
|
def set_data_venda valor
|
@@ -93,80 +129,80 @@ class CieloDetalhe < FormatSection
|
|
93
129
|
end
|
94
130
|
end
|
95
131
|
|
96
|
-
def set_opcao_venda
|
97
|
-
self.set_section_value(5,
|
132
|
+
def set_opcao_venda valor = "0"
|
133
|
+
self.set_section_value(5, valor)
|
98
134
|
end
|
99
135
|
|
100
136
|
def set_valor_venda valor
|
101
137
|
self.set_section_value(6, valor)
|
102
138
|
end
|
103
139
|
|
104
|
-
def numero_parcelas
|
105
|
-
self.set_section_value(7,
|
140
|
+
def numero_parcelas valor = "0"
|
141
|
+
self.set_section_value(7, valor)
|
106
142
|
end
|
107
143
|
|
108
|
-
def set_reservado_1
|
109
|
-
self.set_section_value(8,
|
144
|
+
def set_reservado_1 valor = "0"
|
145
|
+
self.set_section_value(8, valor)
|
110
146
|
end
|
111
147
|
|
112
|
-
def set_reservado_2
|
113
|
-
self.set_section_value(9,
|
148
|
+
def set_reservado_2 valor = "0"
|
149
|
+
self.set_section_value(9, valor)
|
114
150
|
end
|
115
151
|
|
116
|
-
def set_reservado_3
|
117
|
-
self.set_section_value(10,
|
152
|
+
def set_reservado_3 valor = "0"
|
153
|
+
self.set_section_value(10, valor)
|
118
154
|
end
|
119
155
|
|
120
|
-
def set_valor_parcela
|
121
|
-
self.set_section_value(11,
|
156
|
+
def set_valor_parcela valor = "0"
|
157
|
+
self.set_section_value(11, valor)
|
122
158
|
end
|
123
159
|
|
124
160
|
def set_numero_lote valor
|
125
161
|
self.set_section_value(12, valor)
|
126
162
|
end
|
127
163
|
|
128
|
-
def set_reservado_4
|
129
|
-
self.set_section_value(13,
|
164
|
+
def set_reservado_4 valor = "0"
|
165
|
+
self.set_section_value(13, valor)
|
130
166
|
end
|
131
167
|
|
132
168
|
def set_numero_cielo valor
|
133
169
|
self.set_section_value(14, valor)
|
134
170
|
end
|
135
171
|
|
136
|
-
def set_reservado_5
|
137
|
-
self.set_section_value(15,
|
172
|
+
def set_reservado_5 valor = ""
|
173
|
+
self.set_section_value(15, valor)
|
138
174
|
end
|
139
175
|
|
140
|
-
def set_status_venda
|
141
|
-
self.set_section_value(16,
|
176
|
+
def set_status_venda valor = "0"
|
177
|
+
self.set_section_value(16, valor)
|
142
178
|
end
|
143
179
|
|
144
|
-
def set_data_liquidacao
|
145
|
-
self.set_section_value(17,
|
180
|
+
def set_data_liquidacao valor = "0"
|
181
|
+
self.set_section_value(17, valor)
|
146
182
|
end
|
147
183
|
|
148
184
|
def set_validade_cartao valor
|
149
185
|
self.set_section_value(18, valor)
|
150
186
|
end
|
151
187
|
|
152
|
-
def set_reservado_6
|
153
|
-
self.set_section_value(19,
|
188
|
+
def set_reservado_6 valor = "0"
|
189
|
+
self.set_section_value(19, valor)
|
154
190
|
end
|
155
191
|
|
156
|
-
def set_reservado_7
|
157
|
-
self.set_section_value(20,
|
192
|
+
def set_reservado_7 valor = "0"
|
193
|
+
self.set_section_value(20, valor)
|
158
194
|
end
|
159
195
|
|
160
|
-
def set_reservado_8
|
161
|
-
self.set_section_value(21,
|
196
|
+
def set_reservado_8 valor = ""
|
197
|
+
self.set_section_value(21, valor)
|
162
198
|
end
|
163
199
|
|
164
|
-
def set_codigo_erro
|
165
|
-
self.set_section_value(22,
|
200
|
+
def set_codigo_erro valor = ""
|
201
|
+
self.set_section_value(22, valor)
|
166
202
|
end
|
167
203
|
|
168
|
-
def set_reservado_9
|
169
|
-
self.set_section_value(23,
|
204
|
+
def set_reservado_9 valor = ""
|
205
|
+
self.set_section_value(23, valor)
|
170
206
|
end
|
171
207
|
|
172
208
|
def set_cartao_novo valor
|
@@ -177,8 +213,8 @@ class CieloDetalhe < FormatSection
|
|
177
213
|
self.set_section_value(25, valor)
|
178
214
|
end
|
179
215
|
|
180
|
-
def set_reservado_10
|
181
|
-
self.set_section_value(26,
|
216
|
+
def set_reservado_10 valor = ""
|
217
|
+
self.set_section_value(26, valor)
|
182
218
|
end
|
183
219
|
|
184
220
|
#-------------------------------------------------------------------
|
@@ -19,6 +19,22 @@ class CieloHeader < FormatSection
|
|
19
19
|
})
|
20
20
|
end
|
21
21
|
|
22
|
+
#-------------------------------------------------------------------
|
23
|
+
#-------------------------------------------------------------------
|
24
|
+
# Gerais
|
25
|
+
def process_section file
|
26
|
+
self.set_data_deposito file[2..9]
|
27
|
+
self.set_numero_lote file[10..16]
|
28
|
+
self.set_reservado_1 file[17..26]
|
29
|
+
self.set_reservado_2 file[27..29]
|
30
|
+
self.set_numero_cielo file[30..39]
|
31
|
+
self.set_moeda file[40..42]
|
32
|
+
self.set_indicador_processo file[43..43]
|
33
|
+
self.set_indicador_venda file[44..44]
|
34
|
+
self.set_indicador_especial file[45..45]
|
35
|
+
self.set_reservado_3 file[46..249]
|
36
|
+
end
|
37
|
+
|
22
38
|
def get_data_deposito
|
23
39
|
self.get_section_value(1)
|
24
40
|
end
|
@@ -56,12 +72,12 @@ class CieloHeader < FormatSection
|
|
56
72
|
self.set_section_value(2, valor)
|
57
73
|
end
|
58
74
|
|
59
|
-
def set_reservado_1
|
60
|
-
self.set_section_value(3,
|
75
|
+
def set_reservado_1 valor = ""
|
76
|
+
self.set_section_value(3, valor)
|
61
77
|
end
|
62
78
|
|
63
|
-
def set_reservado_2
|
64
|
-
self.set_section_value(4,
|
79
|
+
def set_reservado_2 valor = "000"
|
80
|
+
self.set_section_value(4, valor)
|
65
81
|
end
|
66
82
|
|
67
83
|
def set_numero_cielo valor
|
@@ -76,20 +92,20 @@ class CieloHeader < FormatSection
|
|
76
92
|
end
|
77
93
|
end
|
78
94
|
|
79
|
-
def set_indicador_processo
|
80
|
-
self.set_section_value(7,
|
95
|
+
def set_indicador_processo valor = "P"
|
96
|
+
self.set_section_value(7, valor)
|
81
97
|
end
|
82
98
|
|
83
|
-
def set_indicador_venda
|
84
|
-
self.set_section_value(8,
|
99
|
+
def set_indicador_venda valor = "V"
|
100
|
+
self.set_section_value(8, valor)
|
85
101
|
end
|
86
102
|
|
87
|
-
def set_indicador_especial
|
88
|
-
self.set_section_value(9,
|
103
|
+
def set_indicador_especial valor = ""
|
104
|
+
self.set_section_value(9, valor)
|
89
105
|
end
|
90
106
|
|
91
|
-
def set_reservado_3
|
92
|
-
self.set_section_value(10,
|
107
|
+
def set_reservado_3 valor = ""
|
108
|
+
self.set_section_value(10, valor)
|
93
109
|
end
|
94
110
|
|
95
111
|
#-------------------------------------------------------------------
|
@@ -15,6 +15,28 @@ class CieloTrailler < FormatSection
|
|
15
15
|
})
|
16
16
|
end
|
17
17
|
|
18
|
+
#-------------------------------------------------------------------
|
19
|
+
#-------------------------------------------------------------------
|
20
|
+
# Gerais
|
21
|
+
def process_section file
|
22
|
+
self.set_total_registros file[2..8]
|
23
|
+
self.set_valor_total file[9..24]
|
24
|
+
self.set_valor_aceito file[25..39]
|
25
|
+
self.set_valor_liquido file[40..54]
|
26
|
+
self.set_data_prevista file[55..62]
|
27
|
+
self.set_reservado file[63..249]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def get_total_registros
|
32
|
+
self.get_section_value(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_valor_total
|
36
|
+
self.get_section_value(2).to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
|
18
40
|
def set_total_registros registros
|
19
41
|
registros = registros.to_i
|
20
42
|
|
@@ -37,20 +59,27 @@ class CieloTrailler < FormatSection
|
|
37
59
|
end
|
38
60
|
end
|
39
61
|
|
40
|
-
def set_valor_aceito
|
41
|
-
self.set_section_value(3,
|
62
|
+
def set_valor_aceito valor = "0"
|
63
|
+
self.set_section_value(3, valor)
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_valor_liquido valor = "0"
|
67
|
+
self.set_section_value(4, valor)
|
42
68
|
end
|
43
69
|
|
44
|
-
def
|
45
|
-
self.set_section_value(
|
70
|
+
def set_data_prevista valor = "0"
|
71
|
+
self.set_section_value(5, valor)
|
46
72
|
end
|
47
73
|
|
48
|
-
def
|
49
|
-
self.set_section_value(
|
74
|
+
def set_reservado valor = ""
|
75
|
+
self.set_section_value(6, valor)
|
50
76
|
end
|
51
77
|
|
52
|
-
|
53
|
-
|
78
|
+
#-------------------------------------------------------------------
|
79
|
+
#-------------------------------------------------------------------
|
80
|
+
# Validações
|
81
|
+
def is_valid?
|
82
|
+
self.get_total_registros.length > 0 and self.get_valor_total > 0
|
54
83
|
end
|
55
84
|
|
56
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatos-febraban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- josé Ricardo Almeida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|