diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 33984bb93..347bb9d8f 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -88,6 +88,7 @@ module Hledger.Data.Amount ( showAmount, showAmountWith, showAmountB, + showAmountCost, showAmountCostB, cshowAmount, showAmountWithZeroCommodity, @@ -672,6 +673,10 @@ showAmountB space = if not (T.null comm) && ascommodityspaced style then WideBuilder (TB.singleton ' ') 1 else mempty cost = if displayCost then showAmountCostB afmt a else mempty +-- Show an amount's cost as @ UNITCOST or @@ TOTALCOST. +showAmountCost :: Amount -> String +showAmountCost = wbUnpack . showAmountCostB defaultFmt + -- Show an amount's cost as @ UNITCOST or @@ TOTALCOST (builder version). showAmountCostB :: AmountFormat -> Amount -> WideBuilder showAmountCostB afmt amt = case acost amt of