ofx_parser 1.0.6

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.
@@ -0,0 +1,53 @@
1
+ OFXHEADER:100
2
+ DATA:OFXSGML
3
+ VERSION:102
4
+ SECURITY:NONE
5
+ ENCODING:USASCII
6
+ CHARSET:1252
7
+ COMPRESSION:NONE
8
+ OLDFILEUID:NONE
9
+ NEWFILEUID:e1dffb32-0a88-1111-12fb-111056c11111
10
+
11
+ <OFX>
12
+ <SIGNONMSGSRSV1>
13
+ <SONRS>
14
+ <STATUS>
15
+ <CODE>0
16
+ <SEVERITY>INFO
17
+ </STATUS>
18
+ <DTSERVER>20070702051227
19
+ <LANGUAGE>ENG
20
+ <DTPROFUP>20040828230101
21
+ <FI>
22
+ <ORG>Citigroup
23
+ <FID>24909
24
+ </FI>
25
+ <SESSCOOKIE>11111
26
+ </SONRS>
27
+ </SIGNONMSGSRSV1>
28
+ <SIGNUPMSGSRSV1>
29
+ <ACCTINFOTRNRS>
30
+ <TRNUID>e1dffb32-0a88-1111-12fb-111056c11111
31
+ <STATUS>
32
+ <CODE>0
33
+ <SEVERITY>INFO
34
+ </STATUS>
35
+ <CLTCOOKIE>4
36
+ <ACCTINFORS>
37
+ <DTACCTUP>20070702045709
38
+ <ACCTINFO>
39
+ <DESC>CREDIT CARD ************1111
40
+ <CCACCTINFO>
41
+ <CCACCTFROM>
42
+ <ACCTID>XXXXXXXXXXXX1111
43
+ </CCACCTFROM>
44
+ <SUPTXDL>Y
45
+ <XFERSRC>N
46
+ <XFERDEST>N
47
+ <SVCSTATUS>ACTIVE
48
+ </CCACCTINFO>
49
+ </ACCTINFO>
50
+ </ACCTINFORS>
51
+ </ACCTINFOTRNRS>
52
+ </SIGNUPMSGSRSV1>
53
+ </OFX>
@@ -0,0 +1,106 @@
1
+
2
+ OFXHEADER:100
3
+ DATA:OFXSGML
4
+ VERSION:102
5
+ SECURITY:NONE
6
+ ENCODING:USASCII
7
+ CHARSET:1252
8
+ COMPRESSION:NONE
9
+ OLDFILEUID:NONE
10
+ NEWFILEUID:NONE
11
+ <OFX>
12
+ <SIGNONMSGSRSV1>
13
+ <SONRS>
14
+ <STATUS>
15
+ <CODE>0
16
+ <SEVERITY>INFO
17
+ </STATUS>
18
+ <DTSERVER>20070820120000[0:GMT]
19
+ <LANGUAGE>ENG
20
+ </SONRS>
21
+ </SIGNONMSGSRSV1>
22
+ <CREDITCARDMSGSRSV1>
23
+ <CCSTMTTRNRS>
24
+ <TRNUID>1
25
+ <STATUS>
26
+ <CODE>0
27
+ <SEVERITY>INFO
28
+ <MESSAGE>Success
29
+ </STATUS>
30
+ <CCSTMTRS>
31
+ <CURDEF>USD
32
+ <CCACCTFROM>
33
+ <ACCTID>xxxxxxxxxxxxxxxx
34
+ </CCACCTFROM>
35
+ <BANKTRANLIST>
36
+ <DTSTART>20070706120000[0:GMT]
37
+ <DTEND>20070820120000[0:GMT]
38
+ <STMTTRN>
39
+ <TRNTYPE>CREDIT
40
+ <DTPOSTED>20070719120000[0:GMT]
41
+ <TRNAMT>4.68
42
+ <FITID>GEN20070719-0000004.68PERFECTCARD_REB00000
43
+ <NAME>MY CREDIT CARD
44
+ </STMTTRN>
45
+ <STMTTRN>
46
+ <TRNTYPE>DEBIT
47
+ <DTPOSTED>20070814120000[0:GMT]
48
+ <TRNAMT>-59.99
49
+ <FITID>2007081425411177225225085596201
50
+ <NAME>Another Store
51
+ </STMTTRN>
52
+ <STMTTRN>
53
+ <TRNTYPE>DEBIT
54
+ <DTPOSTED>20070815120000[0:GMT]
55
+ <TRNAMT>-1.50
56
+ <FITID>2007081555541867296004064778618
57
+ <NAME>PATHTVM 33RD STREET
58
+ </STMTTRN>
59
+ <STMTTRN>
60
+ <TRNTYPE>DEBIT
61
+ <DTPOSTED>20070817120000[0:GMT]
62
+ <TRNAMT>-39.37
63
+ <FITID>2007081755432867228100699618500
64
+ <NAME>Yet another store
65
+ </STMTTRN>
66
+ <STMTTRN>
67
+ <TRNTYPE>DEBIT
68
+ <DTPOSTED>20070814120000[0:GMT]
69
+ <TRNAMT>-381.21
70
+ <FITID>2007081455432867226000370175054
71
+ <NAME>Store
72
+ </STMTTRN>
73
+ <STMTTRN>
74
+ <TRNTYPE>DEBIT
75
+ <DTPOSTED>20070803120000[0:GMT]
76
+ <TRNAMT>-108.38
77
+ <FITID>2007080325411178214214070266502
78
+ <NAME>Store
79
+ </STMTTRN>
80
+ <STMTTRN>
81
+ <TRNTYPE>DEBIT
82
+ <DTPOSTED>20070819120000[0:GMT]
83
+ <TRNAMT>-27.00
84
+ <FITID>2007081955500807229017000653817
85
+ <NAME>ZENITH PARKING LLC
86
+ </STMTTRN>
87
+ <STMTTRN>
88
+ <TRNTYPE>DEBIT
89
+ <DTPOSTED>20070730120000[0:GMT]
90
+ <TRNAMT>-59.61
91
+ <FITID>2007073085486757210101972840130
92
+ <NAME>CHRYSLER CAMERA REPAIR
93
+ </STMTTRN>
94
+ </BANKTRANLIST>
95
+ <LEDGERBAL>
96
+ <BALAMT>-2.00
97
+ <DTASOF>20070820120000[0:GMT]
98
+ </LEDGERBAL>
99
+ <AVAILBAL>
100
+ <BALAMT>1.00
101
+ <DTASOF>20070820120000[0:GMT]
102
+ </AVAILBAL>
103
+ </CCSTMTRS>
104
+ </CCSTMTTRNRS>
105
+ </CREDITCARDMSGSRSV1>
106
+ </OFX>
@@ -0,0 +1,28 @@
1
+ OFXHEADER:100
2
+ DATA:OFXSGML
3
+ VERSION:102
4
+ SECURITY:NONE
5
+ ENCODING:USASCII
6
+ CHARSET:1252
7
+ COMPRESSION:NONE
8
+ OLDFILEUID:
9
+ NEWFILEUID:NONE
10
+
11
+ <OFX>
12
+ <SIGNONMSGSRSV1>
13
+ <SONRS>
14
+ <STATUS>
15
+ <CODE> 0
16
+ <SEVERITY> INFO
17
+ <MESSAGE> The user is authentic; operation succeeded.
18
+ </STATUS>
19
+ <DTSERVER> 20070623142635.169[-5:CDT]
20
+ <LANGUAGE>ENG
21
+ <FI>
22
+ <ORG> U.S. Bank
23
+ <FID> 1402
24
+ </FI>
25
+ <INTU.BID>1402
26
+ </SONRS>
27
+ </SIGNONMSGSRSV1>
28
+ </OFX>
@@ -0,0 +1,213 @@
1
+ require 'test/unit'
2
+
3
+ require File.dirname(File.expand_path(__FILE__)) + '/../lib/ofx_parser.rb'
4
+
5
+ class OfxParserTest < Test::Unit::TestCase
6
+
7
+ OFX_FILES = {}
8
+
9
+ fixtures_dir = File.dirname(__FILE__) + '/fixtures'
10
+
11
+ # Load up the xml files
12
+ Dir.open(fixtures_dir).each do |fn|
13
+ next unless fn =~ /\.ofx\.sgml$/
14
+
15
+ ofx = File.read(fixtures_dir + "/#{fn}")
16
+ ofx.gsub!(/\r?\n/,"\r\n") # change line endings to \r\n
17
+
18
+ OFX_FILES[fn.scan(/^[^.]*/)[0].to_s.to_sym] = ofx
19
+ end
20
+
21
+ def setup
22
+ # empty ofx parser - useful for testing other methods independently
23
+ @parser = OfxParser::OfxParser
24
+ end
25
+
26
+ def test_pre_process_strips_spaces
27
+ header, body = @parser.pre_process(OFX_FILES[:with_spaces])
28
+
29
+ assert_no_match(/>\s+.*?</, body, "should be no spaces after a tag close")
30
+ assert_no_match(/>.*?\s+</, body, "should be no spaces before a tag close")
31
+ assert_no_match(/>\s+</, body, "should be no spaces between two tags")
32
+ assert_match("The user is authentic; operation succeeded.", body, "content in tags should not be altered")
33
+ end
34
+
35
+ def test_pre_process_header
36
+ header, body = @parser.pre_process(OFX_FILES[:with_spaces])
37
+
38
+ assert_equal 9, header.keys.size
39
+ end
40
+
41
+ def test_parse_datetime
42
+ assert_equal DateTime.civil(2007, 6, 22, 19, 0, 0, Rational(-5,24)), @parser.parse_datetime('20070622190000.200[-5:CDT]')
43
+ assert_equal DateTime.civil(2007, 6, 22, 19, 0, 0, Rational(9,24)), @parser.parse_datetime('20070622190000.200[+9.0:JST]')
44
+ assert_equal DateTime.civil(2007, 6, 22), @parser.parse_datetime('20070622')
45
+ assert_equal DateTime.civil(2007, 6, 22, 19, 0, 0), @parser.parse_datetime('20070622190000')
46
+ assert_equal DateTime.civil(2007, 6, 22, 19, 0, 0), @parser.parse_datetime('20070622190000.200')
47
+ end
48
+
49
+ def test_sign_on
50
+ ofx = OfxParser::OfxParser.parse(OFX_FILES[:with_spaces])
51
+
52
+ assert_equal '0', ofx.sign_on.status.code
53
+ assert_equal 'INFO', ofx.sign_on.status.severity
54
+ assert_equal 'The user is authentic; operation succeeded.', ofx.sign_on.status.message
55
+ assert_equal 'Success', ofx.sign_on.status.code_desc
56
+
57
+ assert_equal DateTime.civil(2007,6,23,14,26,35,Rational(-5, 24)), ofx.sign_on.date
58
+ assert_equal 'ENG', ofx.sign_on.language
59
+ assert_equal 'U.S. Bank', ofx.sign_on.institute.name
60
+ assert_equal '1402', ofx.sign_on.institute.id
61
+ end
62
+
63
+ def test_no_accounts
64
+ ofx = OfxParser::OfxParser.parse(OFX_FILES[:with_spaces])
65
+
66
+ assert_equal 0, ofx.accounts.size
67
+ end
68
+
69
+ def test_banking
70
+ ofx = OfxParser::OfxParser.parse(OFX_FILES[:banking])
71
+
72
+ acct = ofx.bank_account
73
+
74
+ assert_equal '103333333333', acct.number
75
+ assert_equal '033000033', acct.routing_number
76
+ assert_equal :CHECKING, acct.type
77
+ assert_equal '1234.09', acct.balance
78
+ assert_equal DateTime.civil(2007,6,23,14,26,35,Rational(-5, 24)), acct.balance_date
79
+ assert_equal '9C24229A0077EAA50000011353C9E00743FC', acct.transaction_uid
80
+
81
+ statement = acct.statement
82
+
83
+ assert_equal 'USD', statement.currency
84
+ assert_equal DateTime.civil(2007,6,4,19,0,0,Rational(-5, 24)), statement.start_date
85
+ assert_equal DateTime.civil(2007,6,22,19,0,0,Rational(-5, 24)), statement.end_date
86
+
87
+ transactions = statement.transactions
88
+ assert_equal 4, transactions.size
89
+
90
+ assert_equal :PAYMENT, transactions[0].type
91
+ assert_equal OfxParser::Transaction::TYPE[:PAYMENT], transactions[0].type_desc
92
+ assert_equal DateTime.civil(2007,6,6,12,0,0), transactions[0].date
93
+ assert_equal '-11.11', transactions[0].amount
94
+ assert_equal '11111111 22', transactions[0].fit_id
95
+ assert_equal nil, transactions[0].check_number
96
+ assert_equal nil, transactions[0].sic
97
+ assert_equal nil, transactions[0].sic_desc
98
+ assert_equal 'WEB AUTHORIZED PMT FOO INC', transactions[0].payee
99
+ assert_equal 'Download from usbank.com. FOO INC', transactions[0].memo
100
+
101
+ assert_equal :CHECK, transactions[1].type
102
+ assert_equal OfxParser::Transaction::TYPE[:CHECK], transactions[1].type_desc
103
+ assert_equal DateTime.civil(2007,6,7,12,0,0), transactions[1].date
104
+ assert_equal '-111.11', transactions[1].amount
105
+ assert_equal '22222A', transactions[1].fit_id
106
+ assert_equal '0000009611', transactions[1].check_number
107
+ assert_equal nil, transactions[1].sic
108
+ assert_equal nil, transactions[1].sic_desc
109
+ assert_equal 'CHECK', transactions[1].payee
110
+ assert_equal 'Download from usbank.com.', transactions[1].memo
111
+
112
+ assert_equal :DIRECTDEP, transactions[2].type
113
+ assert_equal OfxParser::Transaction::TYPE[:DIRECTDEP], transactions[2].type_desc
114
+ assert_equal DateTime.civil(2007,6,14,12,0,0), transactions[2].date
115
+ assert_equal '1111.11', transactions[2].amount
116
+ assert_equal 'X34AE33', transactions[2].fit_id
117
+ assert_equal nil, transactions[2].check_number
118
+ assert_equal nil, transactions[2].sic
119
+ assert_equal nil, transactions[2].sic_desc
120
+ assert_equal 'ELECTRONIC DEPOSIT BAR INC', transactions[2].payee
121
+ assert_equal 'Download from usbank.com. BAR INC', transactions[2].memo
122
+
123
+ assert_equal :CREDIT, transactions[3].type
124
+ assert_equal OfxParser::Transaction::TYPE[:CREDIT], transactions[3].type_desc
125
+ assert_equal DateTime.civil(2007,6,19,12,0,0), transactions[3].date
126
+ assert_equal '11.11', transactions[3].amount
127
+ assert_equal '8 8 9089743', transactions[3].fit_id
128
+ assert_equal nil, transactions[3].check_number
129
+ assert_equal nil, transactions[3].sic
130
+ assert_equal nil, transactions[3].sic_desc
131
+ assert_equal 'ATM DEPOSIT US BANK ANYTOWNAS', transactions[3].payee
132
+ assert_equal 'Download from usbank.com. US BANK ANYTOWN ASUS1', transactions[3].memo
133
+
134
+ assert_equal 1, ofx.accounts.size
135
+ end
136
+
137
+ def test_creditcard
138
+ ofx = OfxParser::OfxParser.parse(OFX_FILES[:creditcard])
139
+
140
+ acct = ofx.credit_card
141
+
142
+ assert_equal 'XXXXXXXXXXXX1111', acct.number
143
+ assert_equal '19000.99', acct.remaining_credit
144
+ assert_equal DateTime.civil(2007,6,23,19,20,13), acct.remaining_credit_date
145
+ assert_equal '-1111.01', acct.balance
146
+ assert_equal DateTime.civil(2007,6,23,19,20,13), acct.balance_date
147
+ assert_equal '0', acct.transaction_uid
148
+
149
+ statement = acct.statement
150
+
151
+ assert_equal 'USD', statement.currency
152
+ assert_equal DateTime.civil(2007,5,9,12,0,0), statement.start_date
153
+ assert_equal DateTime.civil(2007,6,8,12,0,0), statement.end_date
154
+
155
+ transactions = statement.transactions
156
+ assert_equal 3, transactions.size
157
+
158
+ assert_equal :DEBIT, transactions[0].type
159
+ assert_equal OfxParser::Transaction::TYPE[:DEBIT], transactions[0].type_desc
160
+ assert_equal DateTime.civil(2007,5,10,17,0,0), transactions[0].date
161
+ assert_equal '-19.17', transactions[0].amount
162
+ assert_equal 'xx', transactions[0].fit_id
163
+ assert_equal nil, transactions[0].check_number
164
+ assert_equal '5912', transactions[0].sic
165
+ assert_equal OfxParser::Mcc::CODES['5912'], transactions[0].sic_desc
166
+ assert_equal 'WALGREEN 34638675 ANYTOWN', transactions[0].payee
167
+ assert_equal '', transactions[0].memo
168
+
169
+ assert_equal :DEBIT, transactions[1].type
170
+ assert_equal OfxParser::Transaction::TYPE[:DEBIT], transactions[1].type_desc
171
+ assert_equal DateTime.civil(2007,5,12,17,0,0), transactions[1].date
172
+ assert_equal '-12.0', transactions[1].amount
173
+ assert_equal 'yy-56', transactions[1].fit_id
174
+ assert_equal nil, transactions[1].check_number
175
+ assert_equal '7933', transactions[1].sic
176
+ assert_equal OfxParser::Mcc::CODES['7933'], transactions[1].sic_desc
177
+ assert_equal 'SUNSET BOWL ANYTOWN', transactions[1].payee
178
+ assert_equal '', transactions[1].memo
179
+
180
+ assert_equal :CREDIT, transactions[2].type
181
+ assert_equal OfxParser::Transaction::TYPE[:CREDIT], transactions[2].type_desc
182
+ assert_equal DateTime.civil(2007,5,26,17,0,0), transactions[2].date
183
+ assert_equal '11.01', transactions[2].amount
184
+ assert_equal '78-9', transactions[2].fit_id
185
+ assert_equal nil, transactions[2].check_number
186
+ assert_equal '0000', transactions[2].sic
187
+ assert_equal nil, transactions[2].sic_desc
188
+ assert_equal 'ELECTRONIC PAYMENT-THANK YOU', transactions[2].payee
189
+ assert_equal '', transactions[2].memo
190
+
191
+ assert_equal 1, ofx.accounts.size
192
+ assert_equal [], ofx.signup_account_info
193
+ end
194
+
195
+ def test_account_listing
196
+ ofx = OfxParser::OfxParser.parse(OFX_FILES[:list])
197
+
198
+ cc_info = ofx.signup_account_info.first
199
+ assert_equal 'CREDIT CARD ************1111', cc_info.desc
200
+ assert_equal 'XXXXXXXXXXXX1111', cc_info.number
201
+
202
+ assert_equal 0, ofx.accounts.size
203
+ end
204
+
205
+
206
+ def test_malformed_header_parses
207
+ assert_nothing_raised do
208
+ OfxParser::OfxParser.parse(OFX_FILES[:malformed_header])
209
+ end
210
+ end
211
+
212
+
213
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ofx_parser
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.6
6
+ platform: ruby
7
+ authors:
8
+ - Andrew A. Smith
9
+ - Armand du Plessis
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-02-23 00:00:00 +02:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: hpricot
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ type: :runtime
27
+ version_requirements: *id001
28
+ description: ofx-parser is an OFX 1.x parser written in Ruby. Forked from original ofx-parser gem to remove UK monetary support
29
+ email:
30
+ - adp@bank.io
31
+ executables: []
32
+
33
+ extensions: []
34
+
35
+ extra_rdoc_files: []
36
+
37
+ files:
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - History.txt
41
+ - Manifest.txt
42
+ - README.txt
43
+ - Rakefile
44
+ - lib/class-extension.rb
45
+ - lib/ofx_parser.rb
46
+ - lib/ofx_parser/mcc.rb
47
+ - lib/ofx_parser/ofx.rb
48
+ - lib/ofx_parser/ofx_parser.rb
49
+ - ofx-parser.gemspec
50
+ - pkg/ofx_parser-1.0.4.gem
51
+ - pkg/ofx_parser-1.0.5.gem
52
+ - pkg/ofx_parser-1.0.6.gem
53
+ - test/fixtures/banking.ofx.sgml
54
+ - test/fixtures/creditcard.ofx.sgml
55
+ - test/fixtures/list.ofx.sgml
56
+ - test/fixtures/malformed_header.ofx.sgml
57
+ - test/fixtures/with_spaces.ofx.sgml
58
+ - test/test_ofx_parser.rb
59
+ has_rdoc: true
60
+ homepage: http://ofx-parser.rubyforge.org/
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: ofx_parser
83
+ rubygems_version: 1.5.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: ofx-parser is an OFX 1.x parser written in Ruby. Forked from original ofx-parser gem to remove UK monetary support
87
+ test_files:
88
+ - test/fixtures/banking.ofx.sgml
89
+ - test/fixtures/creditcard.ofx.sgml
90
+ - test/fixtures/list.ofx.sgml
91
+ - test/fixtures/malformed_header.ofx.sgml
92
+ - test/fixtures/with_spaces.ofx.sgml
93
+ - test/test_ofx_parser.rb