;lib: styleAmountExceptPrecision

This commit is contained in:
Simon Michael 2019-10-20 07:08:45 -07:00
parent f09111b8b9
commit b598f30a8a

View File

@ -66,6 +66,7 @@ module Hledger.Data.Amount (
-- ** rendering
amountstyle,
styleAmount,
styleAmountExceptPrecision,
showAmount,
cshowAmount,
showAmountWithZeroCommodity,
@ -368,6 +369,13 @@ styleAmount styles a =
Just s -> a{astyle=s}
Nothing -> a
-- | Like styleAmount, but keep the number of decimal places unchanged.
styleAmountExceptPrecision :: M.Map CommoditySymbol AmountStyle -> Amount -> Amount
styleAmountExceptPrecision styles a@Amount{astyle=AmountStyle{asprecision=origp}} =
case M.lookup (acommodity a) styles of
Just s -> a{astyle=s{asprecision=origp}}
Nothing -> a
-- | Get the string representation of an amount, based on its
-- commodity's display settings. String representations equivalent to
-- zero are converted to just \"0\". The special "missing" amount is