ofx 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ require "iconv"
2
+ require "kconv"
3
+
1
4
  module OFX
2
5
  module Parser
3
6
  class Base
@@ -9,7 +12,7 @@ module OFX
9
12
  def initialize(resource)
10
13
  resource = open_resource(resource)
11
14
  resource.rewind
12
- @content = resource.read
15
+ @content = convert_to_utf8(resource.read)
13
16
 
14
17
  begin
15
18
  @headers, @body = prepare(content)
@@ -41,7 +44,10 @@ module OFX
41
44
  private
42
45
  def prepare(content)
43
46
  # Split headers & body
44
- headers, body = content.dup.split(/\n{2,}|:?<OFX>/, 2)
47
+ headers, body = content.dup.split(/<OFX>/, 2)
48
+
49
+ # Change single CR's to LF's to avoid issues with some banks
50
+ headers.gsub!(/\r(?!\n)/, "\n")
45
51
 
46
52
  raise OFX::UnsupportedFileError unless body
47
53
 
@@ -60,6 +66,11 @@ module OFX
60
66
 
61
67
  [headers, body]
62
68
  end
69
+
70
+ def convert_to_utf8(string)
71
+ return string if Kconv.isutf8(string)
72
+ Iconv.conv('UTF-8', 'LATIN1//IGNORE', string)
73
+ end
63
74
  end
64
75
  end
65
- end
76
+ end
@@ -2,7 +2,7 @@ module OFX
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 6
5
+ PATCH = 7
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ofx}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nando Vieira"]
12
- s.date = %q{2010-05-06}
12
+ s.date = %q{2010-06-29}
13
13
  s.description = %q{A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports OFX 1.0.2.
14
14
 
15
15
  Usage:
@@ -37,6 +37,7 @@ Usage:
37
37
  "spec/fixtures/avatar.gif",
38
38
  "spec/fixtures/invalid_version.ofx",
39
39
  "spec/fixtures/sample.ofx",
40
+ "spec/fixtures/utf8.ofx",
40
41
  "spec/ofx/account_spec.rb",
41
42
  "spec/ofx/ofx102_spec.rb",
42
43
  "spec/ofx/ofx_parser_spec.rb",
@@ -1,308 +1,308 @@
1
-
2
-
3
- OFXHEADER:100
4
- DATA:OFXSGML
5
- VERSION:102
6
- SECURITY:NONE
7
- ENCODING:USASCII
8
- CHARSET:1252
9
- COMPRESSION:NONE
10
- OLDFILEUID:NONE
11
- NEWFILEUID:NONE
12
-
13
- <OFX>
14
- <SIGNONMSGSRSV1>
15
- <SONRS>
16
- <STATUS>
17
- <CODE>0
18
- <SEVERITY>INFO
19
- </STATUS>
20
- <DTSERVER>20091101192253
21
- <LANGUAGE>POR
22
- </SONRS>
23
- </SIGNONMSGSRSV1>
24
- <BANKMSGSRSV1>
25
- <STMTTRNRS>
26
- <TRNUID>1
27
- <STATUS>
28
- <CODE>0
29
- <SEVERITY>INFO
30
- </STATUS>
31
- <STMTRS>
32
- <CURDEF>BRL
33
- <BANKACCTFROM>
34
- <BANKID>0356
35
- <ACCTID>03227113109
36
- <ACCTTYPE>CHECKING
37
- </BANKACCTFROM>
38
- <BANKTRANLIST>
39
- <DTSTART>20091009080000
40
- <DTEND>20091103080000
41
- <STMTTRN>
42
- <TRNTYPE>DEBIT
43
- <DTPOSTED>20091009080000
44
- <TRNAMT>-35.34
45
- <FITID>200910091
46
- <CHECKNUM>0001223
47
- <MEMO>COMPRA VISA ELECTRON
48
- </STMTTRN><STMTTRN>
49
- <TRNTYPE>CREDIT
50
- <DTPOSTED>20091016080000
51
- <TRNAMT>60.39
52
- <FITID>200910162
53
- <CHECKNUM>0880136
54
- <MEMO>DEPOSITO POUP.CORRENTE
55
- </STMTTRN>
56
-
57
- <STMTTRN>
58
- <TRNTYPE>OTHER</TRNTYPE>
59
- <DTPOSTED>20091019120000[-3:BRT]</DTPOSTED>
60
- <TRNAMT>-148.40</TRNAMT>
61
- <FITID>200910191148400</FITID>
62
- <CHECKNUM>000000101901</CHECKNUM>
63
- <REFNUM>101.901</REFNUM>
64
- <PAYEE>Pagto conta telefone</PAYEE>
65
- <MEMO>Pagto conta telefone</MEMO>
66
- </STMTTRN>
67
-
68
- <STMTTRN>
69
- <TRNTYPE>DEBIT
70
- <DTPOSTED>20091013080000
71
- <TRNAMT>-126.13
72
- <FITID>200910131
73
- <CHECKNUM>0001511
74
- <MEMO>TITULO COBRANCA-IB
75
- </STMTTRN><STMTTRN>
76
- <TRNTYPE>DEBIT
77
- <DTPOSTED>20091013080000
78
- <TRNAMT>-232.23
79
- <FITID>200910132
80
- <CHECKNUM>0001511
81
- <MEMO>TITULO COBRANCA-IB
82
- </STMTTRN><STMTTRN>
83
- <TRNTYPE>DEBIT
84
- <DTPOSTED>20091013080000
85
- <TRNAMT>-501.24
86
- <FITID>200910133
87
- <CHECKNUM>0001511
88
- <MEMO>TITULO COBRANCA-IB
89
- </STMTTRN><STMTTRN>
90
- <TRNTYPE>DEBIT
91
- <DTPOSTED>20091013080000
92
- <TRNAMT>-719.03
93
- <FITID>200910134
94
- <CHECKNUM>0001511
95
- <MEMO>TITULO COBRANCA-IB
96
- </STMTTRN><STMTTRN>
97
- <TRNTYPE>DEBIT
98
- <DTPOSTED>20091013080000
99
- <TRNAMT>-90.75
100
- <FITID>200910135
101
- <CHECKNUM>0001223
102
- <MEMO>COMPRA VISA ELECTRON
103
- </STMTTRN><STMTTRN>
104
- <TRNTYPE>DEBIT
105
- <DTPOSTED>20091013080000
106
- <TRNAMT>-49.80
107
- <FITID>200910136
108
- <CHECKNUM>0001223
109
- <MEMO>COMPRA VISA ELECTRON
110
- </STMTTRN><STMTTRN>
111
- <TRNTYPE>DEBIT
112
- <DTPOSTED>20091013080000
113
- <TRNAMT>-219.90
114
- <FITID>200910137
115
- <CHECKNUM>0001223
116
- <MEMO>COMPRA VISA ELECTRON
117
- </STMTTRN><STMTTRN>
118
- <TRNTYPE>DEBIT
119
- <DTPOSTED>20091013080000
120
- <TRNAMT>-54.61
121
- <FITID>200910138
122
- <CHECKNUM>0001223
123
- <MEMO>COMPRA VISA ELECTRON
124
- </STMTTRN><STMTTRN>
125
- <TRNTYPE>DEBIT
126
- <DTPOSTED>20091013080000
127
- <TRNAMT>-38.57
128
- <FITID>200910139
129
- <CHECKNUM>0002208
130
- <MEMO>PAGTO CONTA TELEFONE -RIB
131
- </STMTTRN><STMTTRN>
132
- <TRNTYPE>DEBIT
133
- <DTPOSTED>20091013080000
134
- <TRNAMT>-119.40
135
- <FITID>2009101310
136
- <CHECKNUM>0002209
137
- <MEMO>CONTA DE LUZ -RIB
138
- </STMTTRN><STMTTRN>
139
- <TRNTYPE>DEBIT
140
- <DTPOSTED>20091013080000
141
- <TRNAMT>-34.69
142
- <FITID>2009101311
143
- <CHECKNUM>0002208
144
- <MEMO>PAGTO CONTA TELEFONE -RIB
145
- </STMTTRN><STMTTRN>
146
- <TRNTYPE>DEBIT
147
- <DTPOSTED>20091013080000
148
- <TRNAMT>-35.07
149
- <FITID>2009101312
150
- <CHECKNUM>0002231
151
- <MEMO>IPTU / TAXAS SP -RIB
152
- </STMTTRN><STMTTRN>
153
- <TRNTYPE>DEBIT
154
- <DTPOSTED>20091013080000
155
- <TRNAMT>-259.10
156
- <FITID>2009101313
157
- <CHECKNUM>0001085
158
- <MEMO>PGTO NET
159
- </STMTTRN><STMTTRN>
160
- <TRNTYPE>DEBIT
161
- <DTPOSTED>20091013080000
162
- <TRNAMT>-202.84
163
- <FITID>2009101314
164
- <CHECKNUM>0002606
165
- <MEMO>PARC RC EXCLUSIVO 12
166
- </STMTTRN><STMTTRN>
167
- <TRNTYPE>DEBIT
168
- <DTPOSTED>20091013080000
169
- <TRNAMT>-272.77
170
- <FITID>2009101315
171
- <CHECKNUM>0002606
172
- <MEMO>PARC RC EXCLUSIVO 08
173
- </STMTTRN><STMTTRN>
174
- <TRNTYPE>DEBIT
175
- <DTPOSTED>20091014080000
176
- <TRNAMT>-80.00
177
- <FITID>200910141
178
- <CHECKNUM>0010991
179
- <MEMO>CHEQUE COMPENSADO
180
- </STMTTRN><STMTTRN>
181
- <TRNTYPE>DEBIT
182
- <DTPOSTED>20091014080000
183
- <TRNAMT>-177.00
184
- <FITID>200910142
185
- <CHECKNUM>0010986
186
- <MEMO>CHEQUE COMPENSADO
187
- </STMTTRN><STMTTRN>
188
- <TRNTYPE>DEBIT
189
- <DTPOSTED>20091014080000
190
- <TRNAMT>-386.00
191
- <FITID>200910143
192
- <CHECKNUM>0011063
193
- <MEMO>CHEQUE COMPENSADO
194
- </STMTTRN><STMTTRN>
195
- <TRNTYPE>DEBIT
196
- <DTPOSTED>20091014080000
197
- <TRNAMT>-12.19
198
- <FITID>200910144
199
- <CHECKNUM>0001223
200
- <MEMO>COMPRA VISA ELECTRON
201
- </STMTTRN><STMTTRN>
202
- <TRNTYPE>DEBIT
203
- <DTPOSTED>20091015080000
204
- <TRNAMT>-41.00
205
- <FITID>200910151
206
- <CHECKNUM>0011064
207
- <MEMO>CHEQUE COMPENSADO
208
- </STMTTRN><STMTTRN>
209
- <TRNTYPE>DEBIT
210
- <DTPOSTED>20091016080000
211
- <TRNAMT>-63.00
212
- <FITID>200910161
213
- <CHECKNUM>0010856
214
- <MEMO>CHEQUE COMPENSADO
215
- </STMTTRN><STMTTRN>
216
- <TRNTYPE>DEBIT
217
- <DTPOSTED>20091019080000
218
- <TRNAMT>-51.00
219
- <FITID>200910191
220
- <CHECKNUM>0011065
221
- <MEMO>CHEQUE COMPENSADO
222
- </STMTTRN><STMTTRN>
223
- <TRNTYPE>DEBIT
224
- <DTPOSTED>20091019080000
225
- <TRNAMT>-23.81
226
- <FITID>200910192
227
- <CHECKNUM>0001203
228
- <MEMO>ASSINATURA ABRIL
229
- </STMTTRN><STMTTRN>
230
- <TRNTYPE>DEBIT
231
- <DTPOSTED>20091020080000
232
- <TRNAMT>-15.50
233
- <FITID>200910201
234
- <CHECKNUM>0001223
235
- <MEMO>COMPRA VISA ELECTRON
236
- </STMTTRN><STMTTRN>
237
- <TRNTYPE>DEBIT
238
- <DTPOSTED>20091021080000
239
- <TRNAMT>-132.00
240
- <FITID>200910211
241
- <CHECKNUM>0011023
242
- <MEMO>CHEQUE COMPENSADO
243
- </STMTTRN><STMTTRN>
244
- <TRNTYPE>CREDIT
245
- <DTPOSTED>20091022080000
246
- <TRNAMT>600.00
247
- <FITID>200910221
248
- <CHECKNUM>0001433
249
- <MEMO>DOC REM 216.397.168-66
250
- </STMTTRN><STMTTRN>
251
- <TRNTYPE>DEBIT
252
- <DTPOSTED>20091022080000
253
- <TRNAMT>-22.40
254
- <FITID>200910222
255
- <CHECKNUM>0001223
256
- <MEMO>COMPRA VISA ELECTRON
257
- </STMTTRN><STMTTRN>
258
- <TRNTYPE>DEBIT
259
- <DTPOSTED>20091022080000
260
- <TRNAMT>-73.16
261
- <FITID>200910223
262
- <CHECKNUM>0001223
263
- <MEMO>COMPRA VISA ELECTRON
264
- </STMTTRN><STMTTRN>
265
- <TRNTYPE>DEBIT
266
- <DTPOSTED>20091023080000
267
- <TRNAMT>-61.36
268
- <FITID>200910231
269
- <CHECKNUM>0000292
270
- <MEMO>CONTA AGUA/ESGOTO
271
- </STMTTRN><STMTTRN>
272
- <TRNTYPE>DEBIT
273
- <DTPOSTED>20091026080000
274
- <TRNAMT>-96.00
275
- <FITID>200910261
276
- <CHECKNUM>0002212
277
- <MEMO>PAGTO FATURA REALVISA-RIB
278
- </STMTTRN><STMTTRN>
279
- <TRNTYPE>DEBIT
280
- <DTPOSTED>20091030080000
281
- <TRNAMT>-67.75
282
- <FITID>200910301
283
- <CHECKNUM>0011061
284
- <MEMO>CHEQUE COMPENSADO
285
- </STMTTRN><STMTTRN>
286
- <TRNTYPE>DEBIT
287
- <DTPOSTED>20091030080000
288
- <TRNAMT>-25.88
289
- <FITID>200910302
290
- <CHECKNUM>0001223
291
- <MEMO>COMPRA VISA ELECTRON
292
- </STMTTRN><STMTTRN>
293
- <TRNTYPE>DEBIT
294
- <DTPOSTED>20091103080000
295
- <TRNAMT>-89.03
296
- <FITID>200911031
297
- <CHECKNUM>0001223
298
- <MEMO>COMPRA VISA ELECTRON
299
- </STMTTRN>
300
- </BANKTRANLIST>
301
- <LEDGERBAL>
302
- <BALAMT>598.44
303
- <DTASOF>20091101
304
- </LEDGERBAL>
305
- </STMTRS>
306
- </STMTTRNRS>
307
- </BANKMSGSRSV1>
308
- </OFX>
1
+
2
+
3
+ OFXHEADER:100
4
+ DATA:OFXSGML
5
+ VERSION:102
6
+ SECURITY:NONE
7
+ ENCODING:USASCII
8
+ CHARSET:1252
9
+ COMPRESSION:NONE
10
+ OLDFILEUID:NONE
11
+ NEWFILEUID:NONE
12
+
13
+ <OFX>
14
+ <SIGNONMSGSRSV1>
15
+ <SONRS>
16
+ <STATUS>
17
+ <CODE>0
18
+ <SEVERITY>INFO
19
+ </STATUS>
20
+ <DTSERVER>20091101192253
21
+ <LANGUAGE>POR
22
+ </SONRS>
23
+ </SIGNONMSGSRSV1>
24
+ <BANKMSGSRSV1>
25
+ <STMTTRNRS>
26
+ <TRNUID>1
27
+ <STATUS>
28
+ <CODE>0
29
+ <SEVERITY>INFO
30
+ </STATUS>
31
+ <STMTRS>
32
+ <CURDEF>BRL
33
+ <BANKACCTFROM>
34
+ <BANKID>0356
35
+ <ACCTID>03227113109
36
+ <ACCTTYPE>CHECKING
37
+ </BANKACCTFROM>
38
+ <BANKTRANLIST>
39
+ <DTSTART>20091009080000
40
+ <DTEND>20091103080000
41
+ <STMTTRN>
42
+ <TRNTYPE>DEBIT
43
+ <DTPOSTED>20091009080000
44
+ <TRNAMT>-35.34
45
+ <FITID>200910091
46
+ <CHECKNUM>0001223
47
+ <MEMO>COMPRA VISA ELECTRON
48
+ </STMTTRN><STMTTRN>
49
+ <TRNTYPE>CREDIT
50
+ <DTPOSTED>20091016080000
51
+ <TRNAMT>60.39
52
+ <FITID>200910162
53
+ <CHECKNUM>0880136
54
+ <MEMO>DEPOSITO POUP.CORRENTE
55
+ </STMTTRN>
56
+
57
+ <STMTTRN>
58
+ <TRNTYPE>OTHER</TRNTYPE>
59
+ <DTPOSTED>20091019120000[-3:BRT]</DTPOSTED>
60
+ <TRNAMT>-148.40</TRNAMT>
61
+ <FITID>200910191148400</FITID>
62
+ <CHECKNUM>000000101901</CHECKNUM>
63
+ <REFNUM>101.901</REFNUM>
64
+ <PAYEE>Pagto conta telefone</PAYEE>
65
+ <MEMO>Pagto conta telefone</MEMO>
66
+ </STMTTRN>
67
+
68
+ <STMTTRN>
69
+ <TRNTYPE>DEBIT
70
+ <DTPOSTED>20091013080000
71
+ <TRNAMT>-126.13
72
+ <FITID>200910131
73
+ <CHECKNUM>0001511
74
+ <MEMO>TITULO COBRANCA-IB
75
+ </STMTTRN><STMTTRN>
76
+ <TRNTYPE>DEBIT
77
+ <DTPOSTED>20091013080000
78
+ <TRNAMT>-232.23
79
+ <FITID>200910132
80
+ <CHECKNUM>0001511
81
+ <MEMO>TITULO COBRANCA-IB
82
+ </STMTTRN><STMTTRN>
83
+ <TRNTYPE>DEBIT
84
+ <DTPOSTED>20091013080000
85
+ <TRNAMT>-501.24
86
+ <FITID>200910133
87
+ <CHECKNUM>0001511
88
+ <MEMO>TITULO COBRANCA-IB
89
+ </STMTTRN><STMTTRN>
90
+ <TRNTYPE>DEBIT
91
+ <DTPOSTED>20091013080000
92
+ <TRNAMT>-719.03
93
+ <FITID>200910134
94
+ <CHECKNUM>0001511
95
+ <MEMO>TITULO COBRANCA-IB
96
+ </STMTTRN><STMTTRN>
97
+ <TRNTYPE>DEBIT
98
+ <DTPOSTED>20091013080000
99
+ <TRNAMT>-90.75
100
+ <FITID>200910135
101
+ <CHECKNUM>0001223
102
+ <MEMO>COMPRA VISA ELECTRON
103
+ </STMTTRN><STMTTRN>
104
+ <TRNTYPE>DEBIT
105
+ <DTPOSTED>20091013080000
106
+ <TRNAMT>-49.80
107
+ <FITID>200910136
108
+ <CHECKNUM>0001223
109
+ <MEMO>COMPRA VISA ELECTRON
110
+ </STMTTRN><STMTTRN>
111
+ <TRNTYPE>DEBIT
112
+ <DTPOSTED>20091013080000
113
+ <TRNAMT>-219.90
114
+ <FITID>200910137
115
+ <CHECKNUM>0001223
116
+ <MEMO>COMPRA VISA ELECTRON
117
+ </STMTTRN><STMTTRN>
118
+ <TRNTYPE>DEBIT
119
+ <DTPOSTED>20091013080000
120
+ <TRNAMT>-54.61
121
+ <FITID>200910138
122
+ <CHECKNUM>0001223
123
+ <MEMO>COMPRA VISA ELECTRON
124
+ </STMTTRN><STMTTRN>
125
+ <TRNTYPE>DEBIT
126
+ <DTPOSTED>20091013080000
127
+ <TRNAMT>-38.57
128
+ <FITID>200910139
129
+ <CHECKNUM>0002208
130
+ <MEMO>PAGTO CONTA TELEFONE -RIB
131
+ </STMTTRN><STMTTRN>
132
+ <TRNTYPE>DEBIT
133
+ <DTPOSTED>20091013080000
134
+ <TRNAMT>-119.40
135
+ <FITID>2009101310
136
+ <CHECKNUM>0002209
137
+ <MEMO>CONTA DE LUZ -RIB
138
+ </STMTTRN><STMTTRN>
139
+ <TRNTYPE>DEBIT
140
+ <DTPOSTED>20091013080000
141
+ <TRNAMT>-34.69
142
+ <FITID>2009101311
143
+ <CHECKNUM>0002208
144
+ <MEMO>PAGTO CONTA TELEFONE -RIB
145
+ </STMTTRN><STMTTRN>
146
+ <TRNTYPE>DEBIT
147
+ <DTPOSTED>20091013080000
148
+ <TRNAMT>-35.07
149
+ <FITID>2009101312
150
+ <CHECKNUM>0002231
151
+ <MEMO>IPTU / TAXAS SP -RIB
152
+ </STMTTRN><STMTTRN>
153
+ <TRNTYPE>DEBIT
154
+ <DTPOSTED>20091013080000
155
+ <TRNAMT>-259.10
156
+ <FITID>2009101313
157
+ <CHECKNUM>0001085
158
+ <MEMO>PGTO NET
159
+ </STMTTRN><STMTTRN>
160
+ <TRNTYPE>DEBIT
161
+ <DTPOSTED>20091013080000
162
+ <TRNAMT>-202.84
163
+ <FITID>2009101314
164
+ <CHECKNUM>0002606
165
+ <MEMO>PARC RC EXCLUSIVO 12
166
+ </STMTTRN><STMTTRN>
167
+ <TRNTYPE>DEBIT
168
+ <DTPOSTED>20091013080000
169
+ <TRNAMT>-272.77
170
+ <FITID>2009101315
171
+ <CHECKNUM>0002606
172
+ <MEMO>PARC RC EXCLUSIVO 08
173
+ </STMTTRN><STMTTRN>
174
+ <TRNTYPE>DEBIT
175
+ <DTPOSTED>20091014080000
176
+ <TRNAMT>-80.00
177
+ <FITID>200910141
178
+ <CHECKNUM>0010991
179
+ <MEMO>CHEQUE COMPENSADO
180
+ </STMTTRN><STMTTRN>
181
+ <TRNTYPE>DEBIT
182
+ <DTPOSTED>20091014080000
183
+ <TRNAMT>-177.00
184
+ <FITID>200910142
185
+ <CHECKNUM>0010986
186
+ <MEMO>CHEQUE COMPENSADO
187
+ </STMTTRN><STMTTRN>
188
+ <TRNTYPE>DEBIT
189
+ <DTPOSTED>20091014080000
190
+ <TRNAMT>-386.00
191
+ <FITID>200910143
192
+ <CHECKNUM>0011063
193
+ <MEMO>CHEQUE COMPENSADO
194
+ </STMTTRN><STMTTRN>
195
+ <TRNTYPE>DEBIT
196
+ <DTPOSTED>20091014080000
197
+ <TRNAMT>-12.19
198
+ <FITID>200910144
199
+ <CHECKNUM>0001223
200
+ <MEMO>COMPRA VISA ELECTRON
201
+ </STMTTRN><STMTTRN>
202
+ <TRNTYPE>DEBIT
203
+ <DTPOSTED>20091015080000
204
+ <TRNAMT>-41.00
205
+ <FITID>200910151
206
+ <CHECKNUM>0011064
207
+ <MEMO>CHEQUE COMPENSADO
208
+ </STMTTRN><STMTTRN>
209
+ <TRNTYPE>DEBIT
210
+ <DTPOSTED>20091016080000
211
+ <TRNAMT>-63.00
212
+ <FITID>200910161
213
+ <CHECKNUM>0010856
214
+ <MEMO>CHEQUE COMPENSADO
215
+ </STMTTRN><STMTTRN>
216
+ <TRNTYPE>DEBIT
217
+ <DTPOSTED>20091019080000
218
+ <TRNAMT>-51.00
219
+ <FITID>200910191
220
+ <CHECKNUM>0011065
221
+ <MEMO>CHEQUE COMPENSADO
222
+ </STMTTRN><STMTTRN>
223
+ <TRNTYPE>DEBIT
224
+ <DTPOSTED>20091019080000
225
+ <TRNAMT>-23.81
226
+ <FITID>200910192
227
+ <CHECKNUM>0001203
228
+ <MEMO>ASSINATURA ABRIL
229
+ </STMTTRN><STMTTRN>
230
+ <TRNTYPE>DEBIT
231
+ <DTPOSTED>20091020080000
232
+ <TRNAMT>-15.50
233
+ <FITID>200910201
234
+ <CHECKNUM>0001223
235
+ <MEMO>COMPRA VISA ELECTRON
236
+ </STMTTRN><STMTTRN>
237
+ <TRNTYPE>DEBIT
238
+ <DTPOSTED>20091021080000
239
+ <TRNAMT>-132.00
240
+ <FITID>200910211
241
+ <CHECKNUM>0011023
242
+ <MEMO>CHEQUE COMPENSADO
243
+ </STMTTRN><STMTTRN>
244
+ <TRNTYPE>CREDIT
245
+ <DTPOSTED>20091022080000
246
+ <TRNAMT>600.00
247
+ <FITID>200910221
248
+ <CHECKNUM>0001433
249
+ <MEMO>DOC REM 216.397.168-66
250
+ </STMTTRN><STMTTRN>
251
+ <TRNTYPE>DEBIT
252
+ <DTPOSTED>20091022080000
253
+ <TRNAMT>-22.40
254
+ <FITID>200910222
255
+ <CHECKNUM>0001223
256
+ <MEMO>COMPRA VISA ELECTRON
257
+ </STMTTRN><STMTTRN>
258
+ <TRNTYPE>DEBIT
259
+ <DTPOSTED>20091022080000
260
+ <TRNAMT>-73.16
261
+ <FITID>200910223
262
+ <CHECKNUM>0001223
263
+ <MEMO>COMPRA VISA ELECTRON
264
+ </STMTTRN><STMTTRN>
265
+ <TRNTYPE>DEBIT
266
+ <DTPOSTED>20091023080000
267
+ <TRNAMT>-61.36
268
+ <FITID>200910231
269
+ <CHECKNUM>0000292
270
+ <MEMO>CONTA AGUA/ESGOTO
271
+ </STMTTRN><STMTTRN>
272
+ <TRNTYPE>DEBIT
273
+ <DTPOSTED>20091026080000
274
+ <TRNAMT>-96.00
275
+ <FITID>200910261
276
+ <CHECKNUM>0002212
277
+ <MEMO>PAGTO FATURA REALVISA-RIB
278
+ </STMTTRN><STMTTRN>
279
+ <TRNTYPE>DEBIT
280
+ <DTPOSTED>20091030080000
281
+ <TRNAMT>-67.75
282
+ <FITID>200910301
283
+ <CHECKNUM>0011061
284
+ <MEMO>CHEQUE COMPENSADO
285
+ </STMTTRN><STMTTRN>
286
+ <TRNTYPE>DEBIT
287
+ <DTPOSTED>20091030080000
288
+ <TRNAMT>-25.88
289
+ <FITID>200910302
290
+ <CHECKNUM>0001223
291
+ <MEMO>COMPRA VISA ELECTRON
292
+ </STMTTRN><STMTTRN>
293
+ <TRNTYPE>DEBIT
294
+ <DTPOSTED>20091103080000
295
+ <TRNAMT>-89.03
296
+ <FITID>200911031
297
+ <CHECKNUM>0001223
298
+ <MEMO>COMPRA VISA ELECTRON
299
+ </STMTTRN>
300
+ </BANKTRANLIST>
301
+ <LEDGERBAL>
302
+ <BALAMT>598.44
303
+ <DTASOF>20091101
304
+ </LEDGERBAL>
305
+ </STMTRS>
306
+ </STMTTRNRS>
307
+ </BANKMSGSRSV1>
308
+ </OFX>
@@ -0,0 +1,308 @@
1
+
2
+
3
+ OFXHEADER:100
4
+ DATA:OFXSGML
5
+ VERSION:102
6
+ SECURITY:NONE
7
+ ENCODING:USASCII
8
+ CHARSET:1252
9
+ COMPRESSION:NONE
10
+ OLDFILEUID:NONE
11
+ NEWFILEUID:NONE
12
+
13
+ <OFX>
14
+ <SIGNONMSGSRSV1>
15
+ <SONRS>
16
+ <STATUS>
17
+ <CODE>0
18
+ <SEVERITY>INFO
19
+ </STATUS>
20
+ <DTSERVER>20091101192253
21
+ <LANGUAGE>POR
22
+ </SONRS>
23
+ </SIGNONMSGSRSV1>
24
+ <BANKMSGSRSV1>
25
+ <STMTTRNRS>
26
+ <TRNUID>1
27
+ <STATUS>
28
+ <CODE>0
29
+ <SEVERITY>INFO
30
+ </STATUS>
31
+ <STMTRS>
32
+ <CURDEF>BRL
33
+ <BANKACCTFROM>
34
+ <BANKID>0356
35
+ <ACCTID>03227113109
36
+ <ACCTTYPE>CHECKING
37
+ </BANKACCTFROM>
38
+ <BANKTRANLIST>
39
+ <DTSTART>20091009080000
40
+ <DTEND>20091103080000
41
+ <STMTTRN>
42
+ <TRNTYPE>DEBIT
43
+ <DTPOSTED>20091009080000
44
+ <TRNAMT>-35.34
45
+ <FITID>200910091
46
+ <CHECKNUM>0001223
47
+ <MEMO>COMPRA VISA ELECTRON
48
+ </STMTTRN><STMTTRN>
49
+ <TRNTYPE>CREDIT
50
+ <DTPOSTED>20091016080000
51
+ <TRNAMT>60.39
52
+ <FITID>200910162
53
+ <CHECKNUM>0880136
54
+ <MEMO>DEPOSITO POUP.CORRENTE
55
+ </STMTTRN>
56
+
57
+ <STMTTRN>
58
+ <TRNTYPE>OTHER</TRNTYPE>
59
+ <DTPOSTED>20091019120000[-3:BRT]</DTPOSTED>
60
+ <TRNAMT>-148.40</TRNAMT>
61
+ <FITID>200910191148400</FITID>
62
+ <CHECKNUM>000000101901</CHECKNUM>
63
+ <REFNUM>101.901</REFNUM>
64
+ <PAYEE>Pagto conta telefone</PAYEE>
65
+ <MEMO>Pagto conta telefone</MEMO>
66
+ </STMTTRN>
67
+
68
+ <STMTTRN>
69
+ <TRNTYPE>DEBIT
70
+ <DTPOSTED>20091013080000
71
+ <TRNAMT>-126.13
72
+ <FITID>200910131
73
+ <CHECKNUM>0001511
74
+ <MEMO>TÍTULO COBRANÇA-IB
75
+ </STMTTRN><STMTTRN>
76
+ <TRNTYPE>DEBIT
77
+ <DTPOSTED>20091013080000
78
+ <TRNAMT>-232.23
79
+ <FITID>200910132
80
+ <CHECKNUM>0001511
81
+ <MEMO>TÍTULO COBRANÇA-IB
82
+ </STMTTRN><STMTTRN>
83
+ <TRNTYPE>DEBIT
84
+ <DTPOSTED>20091013080000
85
+ <TRNAMT>-501.24
86
+ <FITID>200910133
87
+ <CHECKNUM>0001511
88
+ <MEMO>TÍTULO COBRANÇA-IB
89
+ </STMTTRN><STMTTRN>
90
+ <TRNTYPE>DEBIT
91
+ <DTPOSTED>20091013080000
92
+ <TRNAMT>-719.03
93
+ <FITID>200910134
94
+ <CHECKNUM>0001511
95
+ <MEMO>TÍTULO COBRANÇA-IB
96
+ </STMTTRN><STMTTRN>
97
+ <TRNTYPE>DEBIT
98
+ <DTPOSTED>20091013080000
99
+ <TRNAMT>-90.75
100
+ <FITID>200910135
101
+ <CHECKNUM>0001223
102
+ <MEMO>COMPRA VISA ELECTRON
103
+ </STMTTRN><STMTTRN>
104
+ <TRNTYPE>DEBIT
105
+ <DTPOSTED>20091013080000
106
+ <TRNAMT>-49.80
107
+ <FITID>200910136
108
+ <CHECKNUM>0001223
109
+ <MEMO>COMPRA VISA ELECTRON
110
+ </STMTTRN><STMTTRN>
111
+ <TRNTYPE>DEBIT
112
+ <DTPOSTED>20091013080000
113
+ <TRNAMT>-219.90
114
+ <FITID>200910137
115
+ <CHECKNUM>0001223
116
+ <MEMO>COMPRA VISA ELECTRON
117
+ </STMTTRN><STMTTRN>
118
+ <TRNTYPE>DEBIT
119
+ <DTPOSTED>20091013080000
120
+ <TRNAMT>-54.61
121
+ <FITID>200910138
122
+ <CHECKNUM>0001223
123
+ <MEMO>COMPRA VISA ELECTRON
124
+ </STMTTRN><STMTTRN>
125
+ <TRNTYPE>DEBIT
126
+ <DTPOSTED>20091013080000
127
+ <TRNAMT>-38.57
128
+ <FITID>200910139
129
+ <CHECKNUM>0002208
130
+ <MEMO>PAGTO CONTA TELEFONE -RIB
131
+ </STMTTRN><STMTTRN>
132
+ <TRNTYPE>DEBIT
133
+ <DTPOSTED>20091013080000
134
+ <TRNAMT>-119.40
135
+ <FITID>2009101310
136
+ <CHECKNUM>0002209
137
+ <MEMO>CONTA DE LUZ -RIB
138
+ </STMTTRN><STMTTRN>
139
+ <TRNTYPE>DEBIT
140
+ <DTPOSTED>20091013080000
141
+ <TRNAMT>-34.69
142
+ <FITID>2009101311
143
+ <CHECKNUM>0002208
144
+ <MEMO>PAGTO CONTA TELEFONE -RIB
145
+ </STMTTRN><STMTTRN>
146
+ <TRNTYPE>DEBIT
147
+ <DTPOSTED>20091013080000
148
+ <TRNAMT>-35.07
149
+ <FITID>2009101312
150
+ <CHECKNUM>0002231
151
+ <MEMO>IPTU / TAXAS SP -RIB
152
+ </STMTTRN><STMTTRN>
153
+ <TRNTYPE>DEBIT
154
+ <DTPOSTED>20091013080000
155
+ <TRNAMT>-259.10
156
+ <FITID>2009101313
157
+ <CHECKNUM>0001085
158
+ <MEMO>PGTO NET
159
+ </STMTTRN><STMTTRN>
160
+ <TRNTYPE>DEBIT
161
+ <DTPOSTED>20091013080000
162
+ <TRNAMT>-202.84
163
+ <FITID>2009101314
164
+ <CHECKNUM>0002606
165
+ <MEMO>PARC RC EXCLUSIVO 12
166
+ </STMTTRN><STMTTRN>
167
+ <TRNTYPE>DEBIT
168
+ <DTPOSTED>20091013080000
169
+ <TRNAMT>-272.77
170
+ <FITID>2009101315
171
+ <CHECKNUM>0002606
172
+ <MEMO>PARC RC EXCLUSIVO 08
173
+ </STMTTRN><STMTTRN>
174
+ <TRNTYPE>DEBIT
175
+ <DTPOSTED>20091014080000
176
+ <TRNAMT>-80.00
177
+ <FITID>200910141
178
+ <CHECKNUM>0010991
179
+ <MEMO>CHEQUE COMPENSADO
180
+ </STMTTRN><STMTTRN>
181
+ <TRNTYPE>DEBIT
182
+ <DTPOSTED>20091014080000
183
+ <TRNAMT>-177.00
184
+ <FITID>200910142
185
+ <CHECKNUM>0010986
186
+ <MEMO>CHEQUE COMPENSADO
187
+ </STMTTRN><STMTTRN>
188
+ <TRNTYPE>DEBIT
189
+ <DTPOSTED>20091014080000
190
+ <TRNAMT>-386.00
191
+ <FITID>200910143
192
+ <CHECKNUM>0011063
193
+ <MEMO>CHEQUE COMPENSADO
194
+ </STMTTRN><STMTTRN>
195
+ <TRNTYPE>DEBIT
196
+ <DTPOSTED>20091014080000
197
+ <TRNAMT>-12.19
198
+ <FITID>200910144
199
+ <CHECKNUM>0001223
200
+ <MEMO>COMPRA VISA ELECTRON
201
+ </STMTTRN><STMTTRN>
202
+ <TRNTYPE>DEBIT
203
+ <DTPOSTED>20091015080000
204
+ <TRNAMT>-41.00
205
+ <FITID>200910151
206
+ <CHECKNUM>0011064
207
+ <MEMO>CHEQUE COMPENSADO
208
+ </STMTTRN><STMTTRN>
209
+ <TRNTYPE>DEBIT
210
+ <DTPOSTED>20091016080000
211
+ <TRNAMT>-63.00
212
+ <FITID>200910161
213
+ <CHECKNUM>0010856
214
+ <MEMO>CHEQUE COMPENSADO
215
+ </STMTTRN><STMTTRN>
216
+ <TRNTYPE>DEBIT
217
+ <DTPOSTED>20091019080000
218
+ <TRNAMT>-51.00
219
+ <FITID>200910191
220
+ <CHECKNUM>0011065
221
+ <MEMO>CHEQUE COMPENSADO
222
+ </STMTTRN><STMTTRN>
223
+ <TRNTYPE>DEBIT
224
+ <DTPOSTED>20091019080000
225
+ <TRNAMT>-23.81
226
+ <FITID>200910192
227
+ <CHECKNUM>0001203
228
+ <MEMO>ASSINATURA ABRIL
229
+ </STMTTRN><STMTTRN>
230
+ <TRNTYPE>DEBIT
231
+ <DTPOSTED>20091020080000
232
+ <TRNAMT>-15.50
233
+ <FITID>200910201
234
+ <CHECKNUM>0001223
235
+ <MEMO>COMPRA VISA ELECTRON
236
+ </STMTTRN><STMTTRN>
237
+ <TRNTYPE>DEBIT
238
+ <DTPOSTED>20091021080000
239
+ <TRNAMT>-132.00
240
+ <FITID>200910211
241
+ <CHECKNUM>0011023
242
+ <MEMO>CHEQUE COMPENSADO
243
+ </STMTTRN><STMTTRN>
244
+ <TRNTYPE>CREDIT
245
+ <DTPOSTED>20091022080000
246
+ <TRNAMT>600.00
247
+ <FITID>200910221
248
+ <CHECKNUM>0001433
249
+ <MEMO>DOC REM 216.397.168-66
250
+ </STMTTRN><STMTTRN>
251
+ <TRNTYPE>DEBIT
252
+ <DTPOSTED>20091022080000
253
+ <TRNAMT>-22.40
254
+ <FITID>200910222
255
+ <CHECKNUM>0001223
256
+ <MEMO>COMPRA VISA ELECTRON
257
+ </STMTTRN><STMTTRN>
258
+ <TRNTYPE>DEBIT
259
+ <DTPOSTED>20091022080000
260
+ <TRNAMT>-73.16
261
+ <FITID>200910223
262
+ <CHECKNUM>0001223
263
+ <MEMO>COMPRA VISA ELECTRON
264
+ </STMTTRN><STMTTRN>
265
+ <TRNTYPE>DEBIT
266
+ <DTPOSTED>20091023080000
267
+ <TRNAMT>-61.36
268
+ <FITID>200910231
269
+ <CHECKNUM>0000292
270
+ <MEMO>CONTA ÁGUA/ESGOTO
271
+ </STMTTRN><STMTTRN>
272
+ <TRNTYPE>DEBIT
273
+ <DTPOSTED>20091026080000
274
+ <TRNAMT>-96.00
275
+ <FITID>200910261
276
+ <CHECKNUM>0002212
277
+ <MEMO>PAGTO FATURA REALVISA-RIB
278
+ </STMTTRN><STMTTRN>
279
+ <TRNTYPE>DEBIT
280
+ <DTPOSTED>20091030080000
281
+ <TRNAMT>-67.75
282
+ <FITID>200910301
283
+ <CHECKNUM>0011061
284
+ <MEMO>CHEQUE COMPENSADO
285
+ </STMTTRN><STMTTRN>
286
+ <TRNTYPE>DEBIT
287
+ <DTPOSTED>20091030080000
288
+ <TRNAMT>-25.88
289
+ <FITID>200910302
290
+ <CHECKNUM>0001223
291
+ <MEMO>COMPRA VISA ELECTRON
292
+ </STMTTRN><STMTTRN>
293
+ <TRNTYPE>DEBIT
294
+ <DTPOSTED>20091103080000
295
+ <TRNAMT>-89.03
296
+ <FITID>200911031
297
+ <CHECKNUM>0001223
298
+ <MEMO>COMPRA VISA ELECTRON
299
+ </STMTTRN>
300
+ </BANKTRANLIST>
301
+ <LEDGERBAL>
302
+ <BALAMT>598.44
303
+ <DTASOF>20091101
304
+ </LEDGERBAL>
305
+ </STMTRS>
306
+ </STMTTRNRS>
307
+ </BANKMSGSRSV1>
308
+ </OFX>
@@ -26,6 +26,11 @@ describe OFX::Parser do
26
26
  @ofx.content.should == open("spec/fixtures/sample.ofx").read
27
27
  end
28
28
 
29
+ it "should work with UTF8 and Latin1 encodings" do
30
+ @ofx = OFX::Parser::Base.new("spec/fixtures/utf8.ofx")
31
+ @ofx.content.should == open("spec/fixtures/utf8.ofx").read
32
+ end
33
+
29
34
  it "should set body" do
30
35
  @ofx.body.should_not be_nil
31
36
  end
@@ -82,5 +87,16 @@ describe OFX::Parser do
82
87
  @ofx.headers.should have_key("NEWFILEUID")
83
88
  @ofx.headers["NEWFILEUID"].should be_nil
84
89
  end
90
+
91
+ it "should parse headers with CR and without LF" do
92
+ @ofx = OFX::Parser::Base.new(ofx_with_carriage_return)
93
+ @ofx.headers.size.should be(9)
94
+ end
95
+ end
96
+
97
+ def ofx_with_carriage_return
98
+ header = %{OFXHEADER:100\rDATA:OFXSGML\rVERSION:102\rSECURITY:NONE\rENCODING:USASCII\rCHARSET:1252\rCOMPRESSION:NONE\rOLDFILEUID:NONE\rNEWFILEUID:NONE\r}
99
+ body = open("spec/fixtures/sample.ofx").read.split(/<OFX>/, 2)[1]
100
+ header + "<OFX>" + body
85
101
  end
86
102
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 6
9
- version: 0.2.6
8
+ - 7
9
+ version: 0.2.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nando Vieira
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-06 00:00:00 -03:00
17
+ date: 2010-06-29 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -60,6 +60,7 @@ files:
60
60
  - spec/fixtures/avatar.gif
61
61
  - spec/fixtures/invalid_version.ofx
62
62
  - spec/fixtures/sample.ofx
63
+ - spec/fixtures/utf8.ofx
63
64
  - spec/ofx/account_spec.rb
64
65
  - spec/ofx/ofx102_spec.rb
65
66
  - spec/ofx/ofx_parser_spec.rb