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,
}
end
def finalize
@transactions.sort! do |a, b|
a[:txn].date <=> b[:txn].date
end
end
end
end

View File

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

View File

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