From e4cd127fc4bfd03d252dd6d56ffc48ce7871db63 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 9 Mar 2010 04:12:38 +0000 Subject: [PATCH] print: always show zero amounts as 0, hiding any commodity/decimal places/price, like ledger --- hledger-lib/Ledger/Transaction.hs | 2 +- tests/zero-handling.test | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/zero-handling.test diff --git a/hledger-lib/Ledger/Transaction.hs b/hledger-lib/Ledger/Transaction.hs index f366a3cfd..616e33d92 100644 --- a/hledger-lib/Ledger/Transaction.hs +++ b/hledger-lib/Ledger/Transaction.hs @@ -82,7 +82,7 @@ showTransaction' elide effective t = showpostingnoamt p = rstrip $ showacct p ++ " " ++ showcomment (pcomment p) showacct p = " " ++ showstatus p ++ printf (printf "%%-%ds" w) (showAccountName Nothing (ptype p) (paccount p)) w = maximum $ map (length . paccount) ps - showamount = printf "%12s" . showMixedAmount + showamount = printf "%12s" . showMixedAmountOrZero showcomment s = if null s then "" else " ; "++s showstatus p = if pstatus p then "* " else "" diff --git a/tests/zero-handling.test b/tests/zero-handling.test new file mode 100644 index 000000000..db9932655 --- /dev/null +++ b/tests/zero-handling.test @@ -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 +