mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 03:42:25 +03:00
;lib: styleAmountExceptPrecision
This commit is contained in:
parent
f09111b8b9
commit
b598f30a8a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user