From 5989ca03814118d47e981b626e29688013242812 Mon Sep 17 00:00:00 2001 From: Lawrence Date: Tue, 27 Jul 2021 10:19:31 -0500 Subject: [PATCH] fix: skip budget grand total and average if they look zero Makes them consistent with the remaining cells and fixes awkward alignment issue in commodity-column mode where we don't display anything --- hledger-lib/Hledger/Reports/BudgetReport.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index 93f63ddc8..281d3e3a2 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -202,14 +202,14 @@ combineBudgetAndActual ropts j mbrsorted = map prrFullName . sortRows ropts j . map (fmap $ fromMaybe nullmixedamt . fst) rows = rows1 ++ rows2 - -- TODO: grand total & average shows 0% when there are no actual amounts, inconsistent with other cells totalrow = PeriodicReportRow () [ (Map.lookup p totActualByPeriod, Map.lookup p totBudgetByPeriod) | p <- periods ] - ( Just actualgrandtot, Just budgetgrandtot ) - ( Just actualgrandavg, Just budgetgrandavg ) + ( Just actualgrandtot, budget budgetgrandtot ) + ( Just actualgrandavg, budget budgetgrandavg ) where totBudgetByPeriod = Map.fromList $ zip budgetperiods budgettots :: Map DateSpan BudgetTotal totActualByPeriod = Map.fromList $ zip actualperiods actualtots :: Map DateSpan Change + budget b = if mixedAmountLooksZero b then Nothing else Just b -- | Render a budget report as plain text suitable for console output. budgetReportAsText :: ReportOpts -> BudgetReport -> TL.Text