mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
a distinct Account data type
This commit is contained in:
parent
e5fc135707
commit
453ca1206e
17
Account.hs
17
Account.hs
@ -13,17 +13,20 @@ import Ledger
|
||||
|
||||
-- an Account caches an account's name, balance (including sub-accounts)
|
||||
-- and transactions (not including sub-accounts)
|
||||
type Account = (AccountName,[EntryTransaction],Amount)
|
||||
data Account = Account {
|
||||
aname :: AccountName,
|
||||
atransactions :: [EntryTransaction],
|
||||
abalance :: Amount
|
||||
}
|
||||
|
||||
nullacct = ("",[],nullamt)
|
||||
|
||||
aname (a,_,_) = a
|
||||
atransactions (_,ts,_) = ts
|
||||
abalance (_,_,b) = b
|
||||
nullacct = Account "" [] nullamt
|
||||
|
||||
mkAccount :: Ledger -> AccountName -> Account
|
||||
mkAccount l a =
|
||||
(a, transactionsInAccountNamed l a, aggregateBalanceInAccountNamed l a)
|
||||
Account
|
||||
a
|
||||
(transactionsInAccountNamed l a)
|
||||
(aggregateBalanceInAccountNamed l a)
|
||||
|
||||
balanceInAccountNamed :: Ledger -> AccountName -> Amount
|
||||
balanceInAccountNamed l a =
|
||||
|
Loading…
Reference in New Issue
Block a user