diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index f6194bc2c..b79ac015f 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -63,6 +63,7 @@ module Hledger.Data.Amount ( showAmount, showAmountDebug, showAmountWithoutPrice, + showMixedAmountOneLineWithoutPrice, maxprecision, maxprecisionwithpoint, setAmountPrecision, @@ -501,6 +502,14 @@ showMixedAmountWithoutPrice m = concat $ intersperse "\n" $ map showfixedwidth a width = maximum $ map (length . showAmount) as showfixedwidth = printf (printf "%%%ds" width) . showAmountWithoutPrice +-- | Get the one-line string representation of a mixed amount, but without +-- any \@ prices. +showMixedAmountOneLineWithoutPrice :: MixedAmount -> String +showMixedAmountOneLineWithoutPrice m = concat $ intersperse ", " $ map showAmountWithoutPrice as + where + (Mixed as) = normaliseMixedAmountPreservingFirstPrice $ stripPrices m + stripPrices (Mixed as) = Mixed $ map stripprice as where stripprice a = a{aprice=NoPrice} + -- | Canonicalise a mixed amount's display styles using the provided commodity style map. canonicaliseMixedAmount :: M.Map Commodity AmountStyle -> MixedAmount -> MixedAmount canonicaliseMixedAmount styles (Mixed as) = Mixed $ map (canonicaliseAmount styles) as diff --git a/hledger/Hledger/Cli/Balance.hs b/hledger/Hledger/Cli/Balance.hs index 9211577d2..2bb34a296 100644 --- a/hledger/Hledger/Cli/Balance.hs +++ b/hledger/Hledger/Cli/Balance.hs @@ -374,7 +374,7 @@ periodBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) render id ((" "++) . showDateSpan) - showMixedAmountWithoutPrice + showMixedAmountOneLineWithoutPrice $ Table (T.Group NoLine $ map (Header . padright acctswidth) accts) (T.Group NoLine $ map Header colspans) @@ -398,7 +398,7 @@ cumulativeBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> [String] cumulativeBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) = (["Ending balance (cumulative):"] ++) $ trimborder $ lines $ - render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountWithoutPrice $ + render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountOneLineWithoutPrice $ addtotalrow $ Table (T.Group NoLine $ map (Header . padright acctswidth) accts) @@ -419,7 +419,7 @@ historicalBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> [String] historicalBalanceReportAsText opts (MultiBalanceReport (colspans, items, coltotals)) = (["Ending balance (historical):"] ++) $ trimborder $ lines $ - render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountWithoutPrice $ + render id ((" "++) . maybe "" (showDate . prevday) . spanEnd) showMixedAmountOneLineWithoutPrice $ addtotalrow $ Table (T.Group NoLine $ map (Header . padright acctswidth) accts)