finalize accounts to sort transactions by date

This commit is contained in:
Josh Holtrop 2013-08-04 18:44:41 -04:00
parent 0f8b579a34
commit 5ba8e2806c
3 changed files with 14 additions and 0 deletions

View File

@ -33,5 +33,11 @@ module Gnucash
value: value, value: value,
} }
end end
def finalize
@transactions.sort! do |a, b|
a[:txn].date <=> b[:txn].date
end
end
end end
end end

View File

@ -15,6 +15,7 @@ module Gnucash
@book_node = book_nodes.first @book_node = book_nodes.first
build_accounts build_accounts
build_transactions build_transactions
finalize
end end
def find_account_by_id(id) def find_account_by_id(id)
@ -34,5 +35,11 @@ module Gnucash
Transaction.new(self, txn_node) Transaction.new(self, txn_node)
end end
end end
def finalize
@accounts.each do |account|
account.finalize
end
end
end end
end end

View File

@ -1,5 +1,6 @@
module Gnucash module Gnucash
class Transaction class Transaction
attr_accessor :date
attr_accessor :value attr_accessor :value
attr_accessor :id attr_accessor :id