From 676845b269ede0a69ccce65254207a200d7b419b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 31 Aug 2011 17:44:20 +0000 Subject: [PATCH] trim even more fat from amounts --- hledger-lib/Hledger/Data/Amount.hs | 21 --------------------- hledger-lib/Hledger/Data/Posting.hs | 4 ++-- hledger-lib/Hledger/Data/Transaction.hs | 2 +- hledger/Hledger/Cli/Register.hs | 2 +- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index d4eb71526..8bcbd1ffe 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -73,8 +73,6 @@ module Hledger.Data.Amount ( -- ** rendering showMixedAmount, showMixedAmountDebug, - showMixedAmountOrZero, - showMixedAmountOrZeroWithoutPrice, showMixedAmountWithoutPrice, showMixedAmountWithPrecision, -- * misc. @@ -376,20 +374,6 @@ showMixedAmountWithoutPrice m = concat $ intersperse "\n" $ map showfixedwidth a width = maximum $ map (length . show) as showfixedwidth = printf (printf "%%%ds" width) . showAmountWithoutPrice --- | Get the string representation of a mixed amount, and if it --- appears to be all zero just show a bare 0, ledger-style. -showMixedAmountOrZero :: MixedAmount -> String -showMixedAmountOrZero a | a == missingamt = "" - | isZeroMixedAmount a = "0" - | otherwise = showMixedAmount a - --- | Get the string representation of a mixed amount, or a bare 0, --- without any \@ prices. -showMixedAmountOrZeroWithoutPrice :: MixedAmount -> String -showMixedAmountOrZeroWithoutPrice a - | isZeroMixedAmount a = "0" - | otherwise = showMixedAmountWithoutPrice a - -- | Replace a mixed amount's commodity with the canonicalised version from -- the provided commodity map. canonicaliseMixedAmountCommodity :: Maybe (Map.Map String Commodity) -> MixedAmount -> MixedAmount @@ -463,11 +447,6 @@ tests_Hledger_Data_Amount = TestList [ showMixedAmount (Mixed []) `is` "0" showMixedAmount missingamt `is` "" - ,"showMixedAmountOrZero" ~: do - showMixedAmountOrZero (Mixed [Amount dollar 0 Nothing]) `is` "0" - showMixedAmountOrZero (Mixed []) `is` "0" - showMixedAmountOrZero missingamt `is` "" - ,"showMixedAmountWithoutPrice" ~: do let a = (dollars 1){price=Just $ UnitPrice $ Mixed [euros 2]} showMixedAmountWithoutPrice (Mixed [a]) `is` "$1.00" diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index 445014ec6..bb51f6f56 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -39,7 +39,7 @@ showPosting (Posting{paccount=a,pamount=amt,pcomment=com,ptype=t}) = BalancedVirtualPosting -> (\s -> "["++s++"]", acctnamewidth-2) VirtualPosting -> (\s -> "("++s++")", acctnamewidth-2) _ -> (id,acctnamewidth) - showamount = padleft 12 . showMixedAmountOrZero + showamount = padleft 12 . showMixedAmount comment = if null com then "" else " ; " ++ com -- XXX refactor showPostingForRegister :: Posting -> String @@ -53,7 +53,7 @@ showPostingForRegister (Posting{paccount=a,pamount=amt,ptype=t}) = BalancedVirtualPosting -> (\s -> "["++s++"]", acctnamewidth-2) VirtualPosting -> (\s -> "("++s++")", acctnamewidth-2) _ -> (id,acctnamewidth) - showamount = padleft 12 . showMixedAmountOrZeroWithoutPrice + showamount = padleft 12 . showMixedAmountWithoutPrice isReal :: Posting -> Bool isReal p = ptype p == RegularPosting diff --git a/hledger-lib/Hledger/Data/Transaction.hs b/hledger-lib/Hledger/Data/Transaction.hs index e7215c838..17844bbff 100644 --- a/hledger-lib/Hledger/Data/Transaction.hs +++ b/hledger-lib/Hledger/Data/Transaction.hs @@ -95,7 +95,7 @@ showTransaction' elide effective t = where w = maximum $ map (length . paccount) ps showstatus p = if pstatus p then "* " else "" showamt = - padleft 12 . showMixedAmountOrZero + padleft 12 . showMixedAmount showcomment s = if null s then "" else " ; "++s -- | Show an account name, clipped to the given width if any, and diff --git a/hledger/Hledger/Cli/Register.hs b/hledger/Hledger/Cli/Register.hs index 5619a43bc..7acb4ed8f 100644 --- a/hledger/Hledger/Cli/Register.hs +++ b/hledger/Hledger/Cli/Register.hs @@ -54,7 +54,7 @@ postingsReportItemAsText _ (dd, p, b) = concatTopPadded [datedesc, pstr, " ", ba datedescwidth = 32 datewidth = 10 pstr = showPostingForRegister p - bal = padleft 12 (showMixedAmountOrZeroWithoutPrice b) + bal = padleft 12 (showMixedAmountWithoutPrice b) -- XXX showPostingWithBalanceForVty showtxninfo p b = postingsReportItemAsText defreportopts $ mkpostingsReportItem showtxninfo p b