diff --git a/Ledger/Ledger.hs b/Ledger/Ledger.hs index 1fccd7ee8..137fe9b7c 100644 --- a/Ledger/Ledger.hs +++ b/Ledger/Ledger.hs @@ -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 diff --git a/README b/README index 3191ba8da..7b47191eb 100644 --- a/README +++ b/README @@ -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