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
@
the standard balance command shows all top-level accounts:
The standard balance command shows all top-level accounts:
@
\> ledger balance
@ -171,14 +171,14 @@ $ income
$ 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
$ assets
@
with -s, show all subaccounts of matched accounts:
With -s, show all subaccounts of matched accounts:
@
\> ledger -s balance asset
@ -188,7 +188,7 @@ $ checking
$ 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
@ -217,13 +217,25 @@ e
f
g
@
If the overall balance of accounts shown is non-zero (eg when using filter
patterns), display it:
@
--------------------
$
@
-}
showLedgerAccountBalances :: Ledger -> Int -> String
showLedgerAccountBalances l maxdepth =
concatMap
(showAccountTree l)
(branches $ ledgerAccountTree l maxdepth)
-- XXX need to add up and show balances too
concatMap (showAccountTree l) bs
++
if isZeroAmount total
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.
-- 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:
* filtered balance reports should show a total
* register report adds $ when no currency is specified
* timelog parser doesn't work