From aac492c746702cc16f5bd13081769206a06319a2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 15 Oct 2008 00:37:38 +0000 Subject: [PATCH] rename amount show functions --- BalanceCommand.hs | 2 +- Ledger/Amount.hs | 14 +++++++------- Ledger/Entry.hs | 2 +- Ledger/RawTransaction.hs | 2 +- RegisterCommand.hs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/BalanceCommand.hs b/BalanceCommand.hs index ffea8a44f..3af213a47 100644 --- a/BalanceCommand.hs +++ b/BalanceCommand.hs @@ -124,7 +124,7 @@ showBalanceReport opts args l = acctsstr ++ totalstr acctsstr = concatMap (showAccountTreeWithBalances acctnamestoshow) $ subs treetoshow totalstr = if isZeroAmount total then "" - else printf "--------------------\n%20s\n" $ showAmountRounded total + else printf "--------------------\n%20s\n" $ showAmount total showingsubs = ShowSubs `elem` opts pats@(apats,dpats) = parseAccountDescriptionArgs args maxdepth = if null args && not showingsubs then 1 else 9999 diff --git a/Ledger/Amount.hs b/Ledger/Amount.hs index 7ecd20713..9e4dac3ec 100644 --- a/Ledger/Amount.hs +++ b/Ledger/Amount.hs @@ -46,12 +46,12 @@ import Ledger.Commodity amounttests = TestList [ ] -instance Show Amount where show = showAmountRounded +instance Show Amount where show = showAmount -- | Get the string representation of an amount, based on its commodity's -- display settings. -showAmountRounded :: Amount -> String -showAmountRounded (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precision=p}) q) +showAmount :: Amount -> String +showAmount (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precision=p}) q) | side==L = printf "%s%s%s" sym space quantity | side==R = printf "%s%s%s" quantity space sym where @@ -60,17 +60,17 @@ showAmountRounded (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precisi punctuatethousands = id -- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. -showAmountRoundedOrZero :: Amount -> String -showAmountRoundedOrZero a +showAmountOrZero :: Amount -> String +showAmountOrZero a | isZeroAmount a = "0" - | otherwise = showAmountRounded a + | otherwise = showAmount a -- | is this amount zero, when displayed with its given precision ? isZeroAmount :: Amount -> Bool isZeroAmount a@(Amount c _ ) = nonzerodigits == "" where nonzerodigits = filter (flip notElem "-+,.0") quantitystr - quantitystr = withoutsymbol $ showAmountRounded a + quantitystr = withoutsymbol $ showAmount a withoutsymbol = drop (length $ symbol c) -- XXX punctuatethousands :: String -> String diff --git a/Ledger/Entry.hs b/Ledger/Entry.hs index f0417e15c..9db568802 100644 --- a/Ledger/Entry.hs +++ b/Ledger/Entry.hs @@ -83,7 +83,7 @@ showEntry e = showtxn t = showacct t ++ " " ++ (showamount $ tamount t) ++ (showcomment $ tcomment t) showtxnnoamt t = showacct t ++ " " ++ (showcomment $ tcomment t) showacct t = " " ++ (showaccountname $ taccount t) - showamount = printf "%12s" . showAmountRounded + showamount = printf "%12s" . showAmount showaccountname s = printf "%-34s" s showcomment s = if (length s) > 0 then " ; "++s else "" diff --git a/Ledger/RawTransaction.hs b/Ledger/RawTransaction.hs index 358625043..8c88b1456 100644 --- a/Ledger/RawTransaction.hs +++ b/Ledger/RawTransaction.hs @@ -21,7 +21,7 @@ showLedgerTransaction :: RawTransaction -> String showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t) where showaccountname = printf "%-22s" . elideRight 22 - showamount = printf "%12s" . showAmountRoundedOrZero + showamount = printf "%12s" . showAmountOrZero elideRight width s = case length s > width of diff --git a/RegisterCommand.hs b/RegisterCommand.hs index 13807f447..85539e9a5 100644 --- a/RegisterCommand.hs +++ b/RegisterCommand.hs @@ -46,5 +46,5 @@ showTransactionAndBalance t b = (replicate 32 ' ') ++ (showLedgerTransaction $ RawTransaction (account t) (amount t) "") ++ (showBalance b) showBalance :: Amount -> String -showBalance b = printf " %12s" (showAmountRoundedOrZero b) +showBalance b = printf " %12s" (showAmountOrZero b)