From e7e0b5c868f409d0abd2ace095c714bddd69ae43 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 15 Jan 2025 13:21:25 -1000 Subject: [PATCH] lib: Hledger.Data.Amount: showAmountCost --- hledger-lib/Hledger/Data/Amount.hs | 5 +++++ 1 file changed, 5 insertions(+) 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