rename --showsubs to --subtotal, like ledger

This commit is contained in:
Simon Michael 2008-10-17 16:58:09 +00:00
parent 5383215051
commit 5df70bb3f4
3 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,7 @@ The balance command shows top-level accounts by default:
$1 liabilities $1 liabilities
@ @
With -s (--showsubs), also show the subaccounts: With -s (--subtotal), also show the subaccounts:
@ @
$-1 assets $-1 assets
@ -88,7 +88,7 @@ Some notes for the implementation:
- with an account pattern, it shows accounts whose leafname matches, plus their parents - with an account pattern, it shows accounts whose leafname matches, plus their parents
- with the showsubs option, it also shows all subaccounts of the above - with the subtotal option, it also shows all subaccounts of the above
- zero-balance leaf accounts are removed - zero-balance leaf accounts are removed
@ -125,7 +125,7 @@ showBalanceReport opts args l = acctsstr ++ totalstr
totalstr = if isZeroMixedAmount total totalstr = if isZeroMixedAmount total
then "" then ""
else printf "--------------------\n%20s\n" $ showMixedAmount total else printf "--------------------\n%20s\n" $ showMixedAmount total
showingsubs = ShowSubs `elem` opts showingsubs = SubTotal `elem` opts
pats@(apats,dpats) = parseAccountDescriptionArgs args pats@(apats,dpats) = parseAccountDescriptionArgs args
maxdepth = if null args && not showingsubs then 1 else 9999 maxdepth = if null args && not showingsubs then 1 else 9999
acctstoshow = balancereportaccts showingsubs apats l acctstoshow = balancereportaccts showingsubs apats l
@ -146,7 +146,7 @@ showBalanceReport opts args l = acctsstr ++ totalstr
addsubaccts l as = concatMap addsubs as where addsubs = maybe [] flatten . ledgerAccountTreeAt l addsubaccts l as = concatMap addsubs as where addsubs = maybe [] flatten . ledgerAccountTreeAt l
-- remove any accounts from the tree which are not one of the acctstoshow, -- remove any accounts from the tree which are not one of the acctstoshow,
-- or one of their parents, or one of their subaccounts when doing --showsubs -- or one of their parents, or one of their subaccounts when doing --subtotal
pruneUnmatchedAccounts :: Tree Account -> Tree Account pruneUnmatchedAccounts :: Tree Account -> Tree Account
pruneUnmatchedAccounts = treefilter matched pruneUnmatchedAccounts = treefilter matched
where where

View File

@ -28,7 +28,7 @@ options = [
Option ['e'] ["end"] (ReqArg End "YYYY/MM/DD") "report on entries prior to this date", Option ['e'] ["end"] (ReqArg End "YYYY/MM/DD") "report on entries prior to this date",
Option ['C'] ["cleared"] (NoArg Cleared) "report only on cleared entries", Option ['C'] ["cleared"] (NoArg Cleared) "report only on cleared entries",
Option ['R'] ["real"] (NoArg Real) "report only on real (non-virtual) transactions", Option ['R'] ["real"] (NoArg Real) "report only on real (non-virtual) transactions",
Option ['s'] ["showsubs"] (NoArg ShowSubs) "in the balance report, include subaccounts", Option ['s'] ["subtotal"] (NoArg SubTotal) "in the balance report, include subaccounts",
Option ['h'] ["help","usage"] (NoArg Help) "show this help", Option ['h'] ["help","usage"] (NoArg Help) "show this help",
Option ['V'] ["version"] (NoArg Version) "show version" Option ['V'] ["version"] (NoArg Version) "show version"
] ]
@ -40,7 +40,7 @@ data Opt =
End String | End String |
Cleared | Cleared |
Real | Real |
ShowSubs | SubTotal |
Help | Help |
Version Version
deriving (Show,Eq) deriving (Show,Eq)

View File

@ -111,7 +111,7 @@ balancecommandtests = TestList [
\" --" \" --"
(showBalanceReport [] [] l) (showBalanceReport [] [] l)
, ,
"balance report with showsubs" ~: do "balance report with --subtotal" ~: do
l <- ledgerfromfile "sample.ledger" l <- ledgerfromfile "sample.ledger"
assertequal assertequal
" $-1 assets\n\ " $-1 assets\n\
@ -125,7 +125,7 @@ balancecommandtests = TestList [
\ $-1 salary\n\ \ $-1 salary\n\
\ $1 liabilities:debts\n\ \ $1 liabilities:debts\n\
\" --" \" --"
(showBalanceReport [ShowSubs] [] l) (showBalanceReport [SubTotal] [] l)
, ,
"balance report with account pattern o" ~: do "balance report with account pattern o" ~: do
l <- ledgerfromfile "sample.ledger" l <- ledgerfromfile "sample.ledger"
@ -137,7 +137,7 @@ balancecommandtests = TestList [
\" --" \" --"
(showBalanceReport [] ["o"] l) (showBalanceReport [] ["o"] l)
, ,
"balance report with account pattern o and showsubs" ~: do "balance report with account pattern o and --subtotal" ~: do
l <- ledgerfromfile "sample.ledger" l <- ledgerfromfile "sample.ledger"
assertequal assertequal
" $1 expenses:food\n\ " $1 expenses:food\n\
@ -147,7 +147,7 @@ balancecommandtests = TestList [
\--------------------\n\ \--------------------\n\
\ $-1\n\ \ $-1\n\
\" --" \" --"
(showBalanceReport [ShowSubs] ["o"] l) (showBalanceReport [SubTotal] ["o"] l)
, ,
"balance report with account pattern a" ~: do "balance report with account pattern a" ~: do
l <- ledgerfromfile "sample.ledger" l <- ledgerfromfile "sample.ledger"