-n flag for balance command

This commit is contained in:
Simon Michael 2008-11-22 09:46:57 +00:00
parent 42bfc4afd9
commit 6fc8cdfe3e
4 changed files with 9 additions and 2 deletions

View File

@ -119,7 +119,7 @@ balance opts args l = putStr $ showBalanceReport opts args l
-- | Generate balance report output for a ledger, based on options.
showBalanceReport :: [Opt] -> [String] -> Ledger -> String
showBalanceReport opts args l = acctsstr ++ totalstr
showBalanceReport opts args l = acctsstr ++ (if collapse then "" else totalstr)
where
acctsstr = concatMap showatree $ subs t
showatree t = showAccountTreeWithBalances matchedacctnames t
@ -128,6 +128,7 @@ showBalanceReport opts args l = acctsstr ++ totalstr
apats = fst $ parseAccountDescriptionArgs args
sub = SubTotal `elem` opts
empty = Empty `elem` opts
collapse = Collapse `elem` opts
maxdepth = 9999
totalstr = if isZeroMixedAmount total
then ""

1
NOTES
View File

@ -12,7 +12,6 @@ implementations were its consequences." --Niklaus Wirth
*** parse commented lines at end of file
*** display mixed amounts vertically, not horizontally
** features
*** -n to skip total, for compound reports
*** flexible date expressions, for easier time reports
*** commodity @ rate, for tracking client hours in main ledger
*** actual/effective entry & txn dates, for ...

View File

@ -29,6 +29,7 @@ options = [
Option ['C'] ["cleared"] (NoArg Cleared) "report only on cleared entries",
Option ['E'] ["empty"] (NoArg Empty) "balance report: show accounts with zero balance",
Option ['R'] ["real"] (NoArg Real) "report only on real (non-virtual) transactions",
Option ['n'] ["collapse"] (NoArg Collapse) "balance report: no grand total",
Option ['s'] ["subtotal"] (NoArg SubTotal) "balance report: show subaccounts",
Option ['h'] ["help","usage"] (NoArg Help) "show this help",
Option ['V'] ["version"] (NoArg Version) "show version"
@ -42,6 +43,7 @@ data Opt =
Cleared |
Empty |
Real |
Collapse |
SubTotal |
Help |
Version

View File

@ -222,6 +222,11 @@ balancecommand_tests = TestList [
"--------------------\n" ++
" $-1\n" ++
"")
,
"balance report with -n omits the total" ~:
([Collapse], ["cash"]) `gives`
(" $-2 assets:cash\n" ++
"")
] where
gives (opts,pats) e = do
l <- ledgerfromfile pats "sample.ledger"