make balance reports show the total balance when non-zero

This commit is contained in:
Simon Michael 2008-10-03 08:24:24 +00:00
parent 7db9c4c910
commit c76540e348
2 changed files with 20 additions and 9 deletions

View File

@ -160,7 +160,7 @@ liabilities
debts debts
@ @
the standard balance command shows all top-level accounts: The standard balance command shows all top-level accounts:
@ @
\> ledger balance \> ledger balance
@ -171,14 +171,14 @@ $ income
$ liabilities $ liabilities
@ @
with an account pattern, show only the ones with matching names: With an account pattern, show only the ones with matching names:
@ @
\> ledger balance asset \> ledger balance asset
$ assets $ assets
@ @
with -s, show all subaccounts of matched accounts: With -s, show all subaccounts of matched accounts:
@ @
\> ledger -s balance asset \> ledger -s balance asset
@ -188,7 +188,7 @@ $ checking
$ saving $ saving
@ @
we elide boring accounts in two ways: Elide boring accounts in two ways:
- leaf accounts and branches with 0 balance or 0 transactions are omitted - leaf accounts and branches with 0 balance or 0 transactions are omitted
@ -217,13 +217,25 @@ e
f f
g g
@ @
If the overall balance of accounts shown is non-zero (eg when using filter
patterns), display it:
@
--------------------
$
@
-} -}
showLedgerAccountBalances :: Ledger -> Int -> String showLedgerAccountBalances :: Ledger -> Int -> String
showLedgerAccountBalances l maxdepth = showLedgerAccountBalances l maxdepth =
concatMap concatMap (showAccountTree l) bs
(showAccountTree l) ++
(branches $ ledgerAccountTree l maxdepth) if isZeroAmount total
-- XXX need to add up and show balances too then ""
else printf "--------------------\n%20s\n" $ showAmountRounded total
where
bs = branches $ ledgerAccountTree l maxdepth
total = sum $ map (abalance . root) bs
-- | Get the string representation of a tree of accounts. -- | Get the string representation of a tree of accounts.
-- The ledger from which the accounts come is also required, so that -- The ledger from which the accounts come is also required, so that

1
README
View File

@ -30,6 +30,5 @@ possible, see the ledger manual for more info:
Bugs: Bugs:
* filtered balance reports should show a total
* register report adds $ when no currency is specified * register report adds $ when no currency is specified
* timelog parser doesn't work * timelog parser doesn't work