diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 143ce039a..7e746f950 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -266,6 +266,7 @@ module Hledger.Cli.Commands.Balance ( ,multiBalanceHasTotalsColumn ,addTotalBorders ,simpleDateSpanCell + ,tidyColumnLabels ,nbsp ,RowClass(..) -- ** Tests @@ -777,9 +778,7 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..} (PeriodicReport col addHeaderBorders $ hCell "account" "account" : case layout_ of - LayoutTidy -> - map headerCell - ["period", "start_date", "end_date", "commodity", "value"] + LayoutTidy -> map headerCell tidyColumnLabels LayoutBare -> headerCell "commodity" : dateHeaders _ -> dateHeaders dateHeaders = @@ -802,6 +801,10 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..} (PeriodicReport col map (map (fmap wbToText)) . multiBalanceRowAsCellBuilders fmt opts colspans rc dsCell +tidyColumnLabels :: [Text] +tidyColumnLabels = + ["period", "start_date", "end_date", "commodity", "value"] + -- | Render a multi-column balance report as HTML. multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html () diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 74d5fe032..cfc7e8d5e 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -347,13 +347,19 @@ compoundBalanceReportAsSpreadsheet :: compoundBalanceReportAsSpreadsheet fmt accountLabel maybeBlank ropts cbr = let CompoundPeriodicReport title colspans subreports totalrow = cbr - headerrow = + leadingHeaders = Spr.headerCell accountLabel : - (guard (layout_ ropts == LayoutBare) >> [Spr.headerCell "Commodity"]) ++ + case layout_ ropts of + LayoutTidy -> map Spr.headerCell tidyColumnLabels + LayoutBare -> [Spr.headerCell "Commodity"] + _ -> [] + dataHeaders = + (guard (layout_ ropts /= LayoutTidy) >>) $ map (Spr.headerCell . reportPeriodName (balanceaccum_ ropts) colspans) colspans ++ (guard (multiBalanceHasTotalsColumn ropts) >> [Spr.headerCell "Total"]) ++ (guard (average_ ropts) >> [Spr.headerCell "Average"]) + headerrow = leadingHeaders ++ dataHeaders blankrow = fmap (Spr.horizontalSpan headerrow . Spr.defaultCell) maybeBlank