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)
|
-- an Account caches an account's name, balance (including sub-accounts)
|
||||||
-- and transactions (not 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)
|
nullacct = Account "" [] nullamt
|
||||||
|
|
||||||
aname (a,_,_) = a
|
|
||||||
atransactions (_,ts,_) = ts
|
|
||||||
abalance (_,_,b) = b
|
|
||||||
|
|
||||||
mkAccount :: Ledger -> AccountName -> Account
|
mkAccount :: Ledger -> AccountName -> Account
|
||||||
mkAccount l a =
|
mkAccount l a =
|
||||||
(a, transactionsInAccountNamed l a, aggregateBalanceInAccountNamed l a)
|
Account
|
||||||
|
a
|
||||||
|
(transactionsInAccountNamed l a)
|
||||||
|
(aggregateBalanceInAccountNamed l a)
|
||||||
|
|
||||||
balanceInAccountNamed :: Ledger -> AccountName -> Amount
|
balanceInAccountNamed :: Ledger -> AccountName -> Amount
|
||||||
balanceInAccountNamed l a =
|
balanceInAccountNamed l a =
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user