print: always show zero amounts as 0, hiding any commodity/decimal places/price, like ledger

This commit is contained in:
Simon Michael 2010-03-09 04:12:38 +00:00
parent 57c537de41
commit e4cd127fc4
2 changed files with 13 additions and 1 deletions

View File

@ -82,7 +82,7 @@ showTransaction' elide effective t =
showpostingnoamt p = rstrip $ showacct p ++ " " ++ showcomment (pcomment p) showpostingnoamt p = rstrip $ showacct p ++ " " ++ showcomment (pcomment p)
showacct p = " " ++ showstatus p ++ printf (printf "%%-%ds" w) (showAccountName Nothing (ptype p) (paccount p)) showacct p = " " ++ showstatus p ++ printf (printf "%%-%ds" w) (showAccountName Nothing (ptype p) (paccount p))
w = maximum $ map (length . paccount) ps w = maximum $ map (length . paccount) ps
showamount = printf "%12s" . showMixedAmount showamount = printf "%12s" . showMixedAmountOrZero
showcomment s = if null s then "" else " ; "++s showcomment s = if null s then "" else " ; "++s
showstatus p = if pstatus p then "* " else "" showstatus p = if pstatus p then "* " else ""

12
tests/zero-handling.test Normal file
View File

@ -0,0 +1,12 @@
# a zero amount is always displayed as just "0", regardless of any commodity/decimal places/price (like ledger)
#
-f- print --empty
<<<
2010/3/1 x
a $0.00 @ 3EUR
b
>>>
2010/03/01 x
a 0
b 0