diff --git a/Account.hs b/Account.hs index f7d90c698..c1b3b287d 100644 --- a/Account.hs +++ b/Account.hs @@ -1,5 +1,7 @@ module Account where +import qualified Data.Map as Map + import Utils import BasicTypes import AccountName @@ -13,6 +15,8 @@ import Ledger -- and transactions (not including sub-accounts) type Account = (AccountName,[EntryTransaction],Amount) +nullacct = ("",[],nullamt) + aname (a,_,_) = a atransactions (_,ts,_) = ts abalance (_,_,b) = b @@ -30,7 +34,7 @@ aggregateBalanceInAccountNamed l a = sumEntryTransactions (aggregateTransactionsInAccountNamed l a) transactionsInAccountNamed :: Ledger -> AccountName -> [EntryTransaction] -transactionsInAccountNamed l a = +transactionsInAccountNamed l a = ledgerTransactionsMatching (["^" ++ a ++ "$"], []) l aggregateTransactionsInAccountNamed :: Ledger -> AccountName -> [EntryTransaction] diff --git a/BasicTypes.hs b/BasicTypes.hs index 825675640..cadb6e43e 100644 --- a/BasicTypes.hs +++ b/BasicTypes.hs @@ -22,7 +22,7 @@ branches = snd . node GOOG 500 a mixed amount is one or more simple amounts: - $50, EUR 3, APPL 500 + $50, EUR 3, AAPL 500 HRS 16, $13.55, oranges 6 arithmetic: @@ -31,9 +31,9 @@ branches = snd . node EUR0.76 + $1 = EUR 1.52 EUR0.76 - $1 = 0 ($5, HRS 2) + $1 = ($6, HRS 2) - ($50, EUR 3, APPL 500) + ($13.55, oranges 6) = $67.51, APPL 500, oranges 6 + ($50, EUR 3, AAPL 500) + ($13.55, oranges 6) = $67.51, AAPL 500, oranges 6 ($50, EUR 3) * $-1 = $-53.96 - ($50, APPL 500) * $-1 = error + ($50, AAPL 500) * $-1 = error -} @@ -46,6 +46,8 @@ data Amount = Amount { instance Show Amount where show = showAmountRoundedOrZero +nullamt = Amount "" 0 + showAmountRoundedOrZero :: Amount -> String showAmountRoundedOrZero (Amount cur qty) = let rounded = printf "%.2f" qty in diff --git a/Models.hs b/Models.hs index bc7d301ea..a4718b761 100644 --- a/Models.hs +++ b/Models.hs @@ -9,6 +9,8 @@ module Models ( module Account ) where +import qualified Data.Map as Map + import BasicTypes import AccountName import Entry diff --git a/hledger.hs b/hledger.hs index 9c7dbb1aa..2acc7de22 100644 --- a/hledger.hs +++ b/hledger.hs @@ -1,10 +1,10 @@ -#!/usr/bin/env runhaskell {- -hledger - ledger-compatible money management utilities (& haskell study) -GPLv3, (c) Simon Michael & contributors, -John Wiegley's ledger is at http://newartisans.com/ledger.html +hledger - ledger-compatible money management tool (& haskell study) +GPLv3, (c) Simon Michael & contributors +inspired by John Wiegley's ledger at http://newartisans.com/ledger.html -modules/models are organized roughly like this: +modules/models are organized roughly like this; each layer can only +reference things below it: hledger Options