trim even more fat from amounts
This commit is contained in:
parent
06e224dc4a
commit
676845b269
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user