salt-parser 0.0.1
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 +11 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +88 -0
- data/README.rdoc +39 -0
- data/Rakefile +7 -0
- data/lib/ofx/account.rb +28 -0
- data/lib/ofx/accounts.rb +9 -0
- data/lib/ofx/balance.rb +15 -0
- data/lib/ofx/builder.rb +61 -0
- data/lib/ofx/dependencies.rb +13 -0
- data/lib/ofx/parser/base.rb +366 -0
- data/lib/ofx/parser/ofx102.rb +28 -0
- data/lib/ofx/parser/ofx211.rb +21 -0
- data/lib/ofx/sign_on.rb +18 -0
- data/lib/ofx/transaction.rb +28 -0
- data/lib/qif/account.rb +19 -0
- data/lib/qif/accounts.rb +54 -0
- data/lib/qif/builder.rb +37 -0
- data/lib/qif/dependencies.rb +8 -0
- data/lib/qif/parser.rb +68 -0
- data/lib/qif/transaction.rb +28 -0
- data/lib/salt-parser/accounts.rb +11 -0
- data/lib/salt-parser/base.rb +19 -0
- data/lib/salt-parser/builder.rb +24 -0
- data/lib/salt-parser/errors.rb +14 -0
- data/lib/salt-parser/version.rb +8 -0
- data/salt-parser.gemspec +24 -0
- data/spec/ofx/account_spec.rb +97 -0
- data/spec/ofx/accounts_response_spec.rb +45 -0
- data/spec/ofx/accounts_spec.rb +34 -0
- data/spec/ofx/balance_spec.rb +32 -0
- data/spec/ofx/builder_spec.rb +136 -0
- data/spec/ofx/error_request_spec.rb +37 -0
- data/spec/ofx/fixtures/accounts_partial.ofx +52 -0
- data/spec/ofx/fixtures/accounts_request.ofx +11 -0
- data/spec/ofx/fixtures/accounts_response.ofx +109 -0
- data/spec/ofx/fixtures/avatar.gif +0 -0
- data/spec/ofx/fixtures/bb.ofx +700 -0
- data/spec/ofx/fixtures/credit_card_response.ofx +52 -0
- data/spec/ofx/fixtures/creditcard.ofx +79 -0
- data/spec/ofx/fixtures/creditcard_transactions_request.ofx +11 -0
- data/spec/ofx/fixtures/creditcards_partial.ofx +85 -0
- data/spec/ofx/fixtures/date_missing.ofx +73 -0
- data/spec/ofx/fixtures/empty_balance.ofx +44 -0
- data/spec/ofx/fixtures/invalid_version.ofx +308 -0
- data/spec/ofx/fixtures/investment_transactions_response.ofx +108 -0
- data/spec/ofx/fixtures/investment_transactions_response2.ofx +200 -0
- data/spec/ofx/fixtures/investments_with_mkval.ofx +99 -0
- data/spec/ofx/fixtures/missing_headers.ofx +47 -0
- data/spec/ofx/fixtures/mixed_accountinfo_response.ofx +58 -0
- data/spec/ofx/fixtures/ms_money.ofx +52 -0
- data/spec/ofx/fixtures/request_error.ofx +39 -0
- data/spec/ofx/fixtures/request_error2.ofx +39 -0
- data/spec/ofx/fixtures/request_error3.ofx +36 -0
- data/spec/ofx/fixtures/sample_examples/sample_401K_loan.qfx +651 -0
- data/spec/ofx/fixtures/sample_examples/sample_banking.qbo +258 -0
- data/spec/ofx/fixtures/sample_examples/sample_banking.qfx +258 -0
- data/spec/ofx/fixtures/sample_examples/sample_banking_multiacct.qfx +284 -0
- data/spec/ofx/fixtures/sample_examples/sample_credit_card.qfx +257 -0
- data/spec/ofx/fixtures/sample_examples/sample_investment.qfx +654 -0
- data/spec/ofx/fixtures/transactions_empty.ofx +60 -0
- data/spec/ofx/fixtures/utf8.ofx +65 -0
- data/spec/ofx/fixtures/v102.ofx +314 -0
- data/spec/ofx/fixtures/v202.ofx +22 -0
- data/spec/ofx/fixtures/v211.ofx +85 -0
- data/spec/ofx/investment_accounts_spec.rb +70 -0
- data/spec/ofx/ofx102_spec.rb +44 -0
- data/spec/ofx/ofx211_spec.rb +68 -0
- data/spec/ofx/ofx_parser_spec.rb +100 -0
- data/spec/ofx/sign_on_spec.rb +49 -0
- data/spec/ofx/transaction_spec.rb +157 -0
- data/spec/qif/account_spec.rb +42 -0
- data/spec/qif/fixtures/3_records_ddmmyy.qif +19 -0
- data/spec/qif/fixtures/3_records_ddmmyyyy.qif +19 -0
- data/spec/qif/fixtures/3_records_dmyy.qif +19 -0
- data/spec/qif/fixtures/3_records_invalid_header.qif +20 -0
- data/spec/qif/fixtures/3_records_mdyy.qif +19 -0
- data/spec/qif/fixtures/3_records_mmddyy.qif +19 -0
- data/spec/qif/fixtures/3_records_mmddyyyy.qif +19 -0
- data/spec/qif/fixtures/3_records_spaced.qif +19 -0
- data/spec/qif/fixtures/bank_account.qif +19 -0
- data/spec/qif/fixtures/empty_body.qif +1 -0
- data/spec/qif/fixtures/empty_header.qif +18 -0
- data/spec/qif/fixtures/incompatible_date_formats.qif +13 -0
- data/spec/qif/fixtures/invalid_date_format.qif +7 -0
- data/spec/qif/fixtures/not_a_QIF_file.txt +3 -0
- data/spec/qif/fixtures/quicken_non_investement_account.qif +30 -0
- data/spec/qif/fixtures/unknown_account.qif +20 -0
- data/spec/qif/fixtures/various_date_format.qif +19 -0
- data/spec/qif/fixtures/with_categories_list.qif +8669 -0
- data/spec/qif/parser_spec.rb +156 -0
- data/spec/qif/transaction_spec.rb +18 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/fixture.rb +9 -0
- metadata +208 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SaltParser::Ofx::Builder do
|
4
|
+
let(:ofx) { SaltParser::Ofx::Builder.new("spec/ofx/fixtures/v102.ofx") }
|
5
|
+
let(:ofx2) { SaltParser::Ofx::Builder.new("spec/ofx/fixtures/ms_money.ofx") }
|
6
|
+
let(:parser) { ofx.parser }
|
7
|
+
|
8
|
+
describe "initialize" do
|
9
|
+
it "does not raise error if valid file given" do
|
10
|
+
expect{ SaltParser::Ofx::Builder.new("spec/ofx/fixtures/v102.ofx") }.not_to raise_error
|
11
|
+
expect{ SaltParser::Ofx::Builder.new("spec/ofx/fixtures/v211.ofx") }.not_to raise_error
|
12
|
+
expect{ SaltParser::Ofx::Builder.new("spec/ofx/fixtures/v202.ofx") }.not_to raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "raises error if file has not valid format" do
|
16
|
+
expect do
|
17
|
+
SaltParser::Ofx::Builder.new("spec/ofx/fixtures/missing_headers.ofx").parser
|
18
|
+
end.to raise_error(SaltParser::Error::UnsupportedFileError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "parses file without balances" do
|
22
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/ms_money.ofx").parser
|
23
|
+
parser.accounts.size.should == 1
|
24
|
+
parser.accounts.first.transactions.size.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does not raise errors if parsing gone bad" do
|
28
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/date_missing.ofx").parser
|
29
|
+
|
30
|
+
expect {parser.accounts}.to_not raise_error
|
31
|
+
|
32
|
+
parser.accounts.size.should == 1
|
33
|
+
# Total 3 transactions, 2 of them raised error during the parsing
|
34
|
+
parser.accounts.first.transactions.size.should == 1
|
35
|
+
parser.errors.size.should == 2
|
36
|
+
|
37
|
+
parser.errors.first.should be_a_kind_of(SaltParser::Error::ParseError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does not raise errors if transactions list is empty" do
|
41
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/transactions_empty.ofx").parser
|
42
|
+
|
43
|
+
expect {parser.accounts}.to_not raise_error
|
44
|
+
|
45
|
+
parser.accounts.size.should == 2
|
46
|
+
parser.accounts.first.transactions.should be_empty
|
47
|
+
parser.accounts.last.transactions.should be_empty
|
48
|
+
|
49
|
+
parser.errors.should be_empty
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns even partial data" do
|
53
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/accounts_partial.ofx").parser
|
54
|
+
|
55
|
+
expect {parser.accounts}.to_not raise_error
|
56
|
+
|
57
|
+
parser.accounts.size.should == 1
|
58
|
+
account = parser.accounts.first
|
59
|
+
account.balance.amount.should == 598.44
|
60
|
+
account.bank_id.should be_empty
|
61
|
+
account.id.should be_empty
|
62
|
+
account.name.should be_empty
|
63
|
+
account.currency.should == "BRL"
|
64
|
+
account.transactions.size.should == 1
|
65
|
+
account.type.should be_nil
|
66
|
+
account.available_balance.should be_nil
|
67
|
+
|
68
|
+
parser.errors.should be_empty
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns even partial data" do
|
72
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/creditcards_partial.ofx").parser
|
73
|
+
|
74
|
+
expect {parser.accounts}.to_not raise_error
|
75
|
+
parser.accounts.size.should == 3
|
76
|
+
account = parser.accounts.last
|
77
|
+
account.balance.should be_nil
|
78
|
+
account.bank_id.should be_nil
|
79
|
+
account.id.should == "345678901234567"
|
80
|
+
account.currency.should be_empty
|
81
|
+
account.transactions.size.should == 0
|
82
|
+
account.type.should == :credit_card
|
83
|
+
account.available_balance.should be_nil
|
84
|
+
|
85
|
+
parser.errors.should be_empty
|
86
|
+
end
|
87
|
+
|
88
|
+
it "returns investment data" do
|
89
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/investment_transactions_response.ofx").parser
|
90
|
+
|
91
|
+
expect {parser.accounts}.to_not raise_error
|
92
|
+
|
93
|
+
parser.accounts.size.should == 1
|
94
|
+
account = parser.accounts.last
|
95
|
+
account.balance.amount.should == 1308.93
|
96
|
+
account.bank_id.should be_nil
|
97
|
+
account.id.should == "123456789"
|
98
|
+
account.currency.should == "USD"
|
99
|
+
account.transactions.size.should == 1
|
100
|
+
account.type.should == :investment
|
101
|
+
account.available_balance.should be_nil
|
102
|
+
|
103
|
+
parser.errors.should be_empty
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns investment data" do
|
107
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/investment_transactions_response2.ofx").parser
|
108
|
+
|
109
|
+
expect {parser.accounts}.to_not raise_error
|
110
|
+
|
111
|
+
parser.accounts.size.should == 1
|
112
|
+
account = parser.accounts.last
|
113
|
+
account.balance.amount.should == 2113.43
|
114
|
+
account.bank_id.should be_nil
|
115
|
+
account.id.should == "123456"
|
116
|
+
account.currency.should == "USD"
|
117
|
+
account.transactions.size.should == 3
|
118
|
+
account.type.should == :investment
|
119
|
+
account.available_balance.should be_nil
|
120
|
+
|
121
|
+
parser.errors.should be_empty
|
122
|
+
end
|
123
|
+
|
124
|
+
it "does not fail if account balance is missing" do
|
125
|
+
parser = SaltParser::Ofx::Builder.new("spec/ofx/fixtures/empty_balance.ofx").parser
|
126
|
+
|
127
|
+
expect {parser.accounts}.to_not raise_error
|
128
|
+
|
129
|
+
parser.accounts.size.should == 1
|
130
|
+
parser.accounts.first.balance.should be_nil
|
131
|
+
|
132
|
+
|
133
|
+
parser.errors.should be_empty
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Error request" do
|
4
|
+
let(:parser) { SaltParser::Ofx::Builder.new("spec/ofx/fixtures/request_error.ofx").parser }
|
5
|
+
let(:parser2) { SaltParser::Ofx::Builder.new("spec/ofx/fixtures/request_error2.ofx").parser }
|
6
|
+
let(:parser3) { SaltParser::Ofx::Builder.new("spec/ofx/fixtures/request_error3.ofx").parser }
|
7
|
+
|
8
|
+
describe "errors" do
|
9
|
+
it "should contain SaltParser::Error::RequestError" do
|
10
|
+
parser.errors.size.should == 2
|
11
|
+
|
12
|
+
error = parser.errors.first
|
13
|
+
error.class.should == SaltParser::Error::RequestError
|
14
|
+
error.message.should == "[2000] Application which you are using is not enabled. Please call customer service."
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should contain SaltParser::Error::RequestError" do
|
18
|
+
parser2.errors.size.should == 1
|
19
|
+
|
20
|
+
error = parser2.errors.first
|
21
|
+
error.class.should == SaltParser::Error::RequestError
|
22
|
+
error.message.should == "[2019] A duplicate request has been entered."
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should contain SaltParser::Error::RequestError" do
|
26
|
+
parser3.errors.size.should == 2
|
27
|
+
|
28
|
+
error = parser3.errors.first
|
29
|
+
error.class.should == SaltParser::Error::RequestError
|
30
|
+
error.message.should == "[15500]"
|
31
|
+
|
32
|
+
second_error = parser3.errors.last
|
33
|
+
second_error.class.should == SaltParser::Error::RequestError
|
34
|
+
second_error.message.should == "[2000] Due to an error, we are unable to complete your request; please contact your software support."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
+
<BANKTRANLIST>
|
34
|
+
<DTSTART>20091009080000
|
35
|
+
<DTEND>20091103080000
|
36
|
+
<STMTTRN>
|
37
|
+
<TRNTYPE>DEBIT
|
38
|
+
<DTPOSTED>20091103080000
|
39
|
+
<TRNAMT>-89.03
|
40
|
+
<FITID>200911031
|
41
|
+
<CHECKNUM>0001223
|
42
|
+
<MEMO>COMPRA VISA ELECTRON
|
43
|
+
</STMTTRN>
|
44
|
+
</BANKTRANLIST>
|
45
|
+
<LEDGERBAL>
|
46
|
+
<BALAMT>598.44
|
47
|
+
<DTASOF>20091101
|
48
|
+
</LEDGERBAL>
|
49
|
+
</STMTRS>
|
50
|
+
</STMTTRNRS>
|
51
|
+
</BANKMSGSRSV1>
|
52
|
+
</OFX>
|
@@ -0,0 +1,11 @@
|
|
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:NONE
|
10
|
+
|
11
|
+
<OFX><SIGNONMSGSRQV1><SONRQ><DTCLIENT>20140905134849<USERID>username<USERPASS>secret<LANGUAGE>ENG<FI><ORG>HAN<FID>5959</FI><APPID>QWIN<APPVER>2300</SONRQ></SIGNONMSGSRQV1><SIGNUPMSGSRQV1><ACCTINFOTRNRQ><TRNUID>1409924929<CLTCOOKIE>4<ACCTINFORQ><DTACCTUP>19980101</ACCTINFORQ></ACCTINFOTRNRQ></SIGNUPMSGSRQV1></OFX>
|
@@ -0,0 +1,109 @@
|
|
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:NONE
|
10
|
+
|
11
|
+
<OFX>
|
12
|
+
<SIGNONMSGSRSV1>
|
13
|
+
<SONRS>
|
14
|
+
<STATUS>
|
15
|
+
<CODE>0
|
16
|
+
<SEVERITY>INFO
|
17
|
+
<MESSAGE>SUCCESS
|
18
|
+
</STATUS>
|
19
|
+
<DTSERVER>20141031063103.045[-4:EDT]
|
20
|
+
<LANGUAGE>ENG
|
21
|
+
<FI>
|
22
|
+
<ORG>B1
|
23
|
+
<FID>10898
|
24
|
+
</FI>
|
25
|
+
</SONRS>
|
26
|
+
</SIGNONMSGSRSV1>
|
27
|
+
|
28
|
+
<SIGNUPMSGSRSV1>
|
29
|
+
<ACCTINFOTRNRS>
|
30
|
+
<TRNUID>1414751462
|
31
|
+
<STATUS>
|
32
|
+
<CODE>0
|
33
|
+
<SEVERITY>INFO
|
34
|
+
</STATUS>
|
35
|
+
<CLTCOOKIE>1
|
36
|
+
<ACCTINFORS>
|
37
|
+
<DTACCTUP>20141031063103.202[-4:EDT]
|
38
|
+
<ACCTINFO>
|
39
|
+
<DESC>SILVERWIZ SAVINGS
|
40
|
+
<BANKACCTINFO>
|
41
|
+
<BANKACCTFROM>
|
42
|
+
<BANKID>123456789
|
43
|
+
<ACCTID>1234567890
|
44
|
+
<ACCTTYPE>MONEYMRKT
|
45
|
+
</BANKACCTFROM>
|
46
|
+
<SUPTXDL>Y
|
47
|
+
<XFERSRC>Y
|
48
|
+
<XFERDEST>Y
|
49
|
+
<SVCSTATUS>ACTIVE
|
50
|
+
</BANKACCTINFO>
|
51
|
+
</ACCTINFO>
|
52
|
+
<ACCTINFO>
|
53
|
+
<DESC>SILVERWIZ CHECKING
|
54
|
+
<BANKACCTINFO>
|
55
|
+
<BANKACCTFROM>
|
56
|
+
<BANKID>123456789
|
57
|
+
<ACCTID>234567890
|
58
|
+
<ACCTTYPE>CHECKING
|
59
|
+
</BANKACCTFROM>
|
60
|
+
<SUPTXDL>Y
|
61
|
+
<XFERSRC>Y
|
62
|
+
<XFERDEST>Y
|
63
|
+
<SVCSTATUS>ACTIVE
|
64
|
+
</BANKACCTINFO>
|
65
|
+
</ACCTINFO>
|
66
|
+
<ACCTINFO>
|
67
|
+
<DESC>ILIYA CHECKING
|
68
|
+
<BANKACCTINFO>
|
69
|
+
<BANKACCTFROM>
|
70
|
+
<BANKID>123456789
|
71
|
+
<ACCTID>345678901
|
72
|
+
<ACCTTYPE>CHECKING
|
73
|
+
</BANKACCTFROM>
|
74
|
+
<SUPTXDL>Y
|
75
|
+
<XFERSRC>Y
|
76
|
+
<XFERDEST>Y
|
77
|
+
<SVCSTATUS>ACTIVE
|
78
|
+
</BANKACCTINFO>
|
79
|
+
</ACCTINFO>
|
80
|
+
<ACCTINFO>
|
81
|
+
<DESC>ILIYA SAVINGS
|
82
|
+
<BANKACCTINFO>
|
83
|
+
<BANKACCTFROM>
|
84
|
+
<BANKID>987654321
|
85
|
+
<ACCTID>4567890123
|
86
|
+
<ACCTTYPE>MONEYMRKT
|
87
|
+
</BANKACCTFROM>
|
88
|
+
<SUPTXDL>Y
|
89
|
+
<XFERSRC>Y
|
90
|
+
<XFERDEST>Y
|
91
|
+
<SVCSTATUS>ACTIVE
|
92
|
+
</BANKACCTINFO>
|
93
|
+
</ACCTINFO>
|
94
|
+
<ACCTINFO>
|
95
|
+
<DESC>ILIYA CREDIT
|
96
|
+
<CCACCTINFO>
|
97
|
+
<CCACCTFROM>
|
98
|
+
<ACCTID>1234567890123456
|
99
|
+
</CCACCTFROM>
|
100
|
+
<SUPTXDL>Y
|
101
|
+
<XFERSRC>N
|
102
|
+
<XFERDEST>Y
|
103
|
+
<SVCSTATUS>ACTIVE
|
104
|
+
</CCACCTINFO>
|
105
|
+
</ACCTINFO>
|
106
|
+
</ACCTINFORS>
|
107
|
+
</ACCTINFOTRNRS>
|
108
|
+
</SIGNUPMSGSRSV1>
|
109
|
+
</OFX>
|
Binary file
|