From 137cc8292e158267102cd21c85d11bedd2aee2c1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 19 Jan 2011 23:27:11 +0000 Subject: [PATCH] amount cleanups --- hledger-lib/Hledger/Data/Amount.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 95f7ada79..692d3ea81 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -45,6 +45,8 @@ module Hledger.Data.Amount ( convertMixedAmountTo, costOfAmount, costOfMixedAmount, + divideAmount, + divideMixedAmount, isNegativeMixedAmount, isReallyZeroMixedAmountCost, isZeroMixedAmount, @@ -54,6 +56,8 @@ module Hledger.Data.Amount ( nullamt, nullmixedamt, punctuatethousands, + setAmountPrecision, + setMixedAmountPrecision, showMixedAmount, showMixedAmountDebug, showMixedAmountOrZero, @@ -189,6 +193,7 @@ showAmount' (Amount (Commodity {decimalpoint=d,precision=p,separator=s,separator | otherwise = printf ("%."++show p++"f") q -- isint n = fromIntegral (round n) == n +-- | A special precision value meaning show all available digits. maxprecision = 999999 -- | Replace a number string's decimal point with the specified character, @@ -273,8 +278,8 @@ isReallyZeroMixedAmountCost = isReallyZeroMixedAmount . costOfMixedAmount showMixedAmount :: MixedAmount -> String showMixedAmount m = vConcatRightAligned $ map show $ amounts $ normaliseMixedAmount m --- setMixedAmountPrecision :: Int -> MixedAmount -> MixedAmount --- setMixedAmountPrecision p (Mixed as) = Mixed $ map (setAmountPrecision p) as +setMixedAmountPrecision :: Int -> MixedAmount -> MixedAmount +setMixedAmountPrecision p (Mixed as) = Mixed $ map (setAmountPrecision p) as -- | Get the string representation of a mixed amount, showing each of its -- component amounts with the specified precision, ignoring their