Skip to content

Commit

Permalink
Merge pull request annacruz#4 from chrisroos/additional_transaction_t…
Browse files Browse the repository at this point in the history
…ypes

Additional transaction types
  • Loading branch information
fnando committed May 16, 2011
2 parents 5a6d889 + c4312c3 commit 8657feb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/ofx/parser/ofx102.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ class OFX102
ACCOUNT_TYPES = {
"CHECKING" => :checking
}

TRANSACTION_TYPES = {
"CREDIT" => :credit,
"DEBIT" => :debit,
"OTHER" => :other,
"DEP" => :dep,
"XFER" => :xfer,
"CASH" => :cash,
"CHECK" => :check
}

TRANSACTION_TYPES = [
'ATM', 'CASH', 'CHECK', 'CREDIT', 'DEBIT', 'DEP', 'DIRECTDEBIT', 'DIRECTDEP', 'DIV',
'FEE', 'INT', 'OTHER', 'PAYMENT', 'POS', 'REPEATPMT', 'SRVCHG', 'XFER'
].inject({}) { |hash, tran_type| hash[tran_type] = tran_type.downcase.to_sym; hash }

attr_reader :headers
attr_reader :body
Expand Down
13 changes: 13 additions & 0 deletions spec/ofx/ofx102_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,17 @@
it "should set account" do
@parser.account.should be_a_kind_of(OFX::Account)
end

it "should know about all transaction types" do
valid_types = [
'CREDIT', 'DEBIT', 'INT', 'DIV', 'FEE', 'SRVCHG', 'DEP', 'ATM', 'POS', 'XFER',
'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER'
]
valid_types.sort.should == OFX::Parser::OFX102::TRANSACTION_TYPES.keys.sort

valid_types.each do |transaction_type|
transaction_type.downcase.to_sym.should equal OFX::Parser::OFX102::TRANSACTION_TYPES[transaction_type]
end
end

end

0 comments on commit 8657feb

Please sign in to comment.