Skip to content

Commit 49f1af0

Browse files
thielemasimonmichael
authored andcommitted
cli: CompoundBalance.compoundBalanceReportAsSpreadsheet: somehow support layout tidy
However, it is not quite correct since it contains totals and net values.
1 parent 270360a commit 49f1af0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

hledger/Hledger/Cli/Commands/Balance.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ module Hledger.Cli.Commands.Balance (
266266
,multiBalanceHasTotalsColumn
267267
,addTotalBorders
268268
,simpleDateSpanCell
269+
,tidyColumnLabels
269270
,nbsp
270271
,RowClass(..)
271272
-- ** Tests
@@ -777,9 +778,7 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..} (PeriodicReport col
777778
addHeaderBorders $
778779
hCell "account" "account" :
779780
case layout_ of
780-
LayoutTidy ->
781-
map headerCell
782-
["period", "start_date", "end_date", "commodity", "value"]
781+
LayoutTidy -> map headerCell tidyColumnLabels
783782
LayoutBare -> headerCell "commodity" : dateHeaders
784783
_ -> dateHeaders
785784
dateHeaders =
@@ -802,6 +801,10 @@ multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..} (PeriodicReport col
802801
map (map (fmap wbToText)) .
803802
multiBalanceRowAsCellBuilders fmt opts colspans rc dsCell
804803

804+
tidyColumnLabels :: [Text]
805+
tidyColumnLabels =
806+
["period", "start_date", "end_date", "commodity", "value"]
807+
805808

806809
-- | Render a multi-column balance report as HTML.
807810
multiBalanceReportAsHtml :: ReportOpts -> MultiBalanceReport -> Html ()

hledger/Hledger/Cli/CompoundBalanceCommand.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,19 @@ compoundBalanceReportAsSpreadsheet ::
347347
compoundBalanceReportAsSpreadsheet fmt accountLabel maybeBlank ropts cbr =
348348
let
349349
CompoundPeriodicReport title colspans subreports totalrow = cbr
350-
headerrow =
350+
leadingHeaders =
351351
Spr.headerCell accountLabel :
352-
(guard (layout_ ropts == LayoutBare) >> [Spr.headerCell "Commodity"]) ++
352+
case layout_ ropts of
353+
LayoutTidy -> map Spr.headerCell tidyColumnLabels
354+
LayoutBare -> [Spr.headerCell "Commodity"]
355+
_ -> []
356+
dataHeaders =
357+
(guard (layout_ ropts /= LayoutTidy) >>) $
353358
map (Spr.headerCell . reportPeriodName (balanceaccum_ ropts) colspans)
354359
colspans ++
355360
(guard (multiBalanceHasTotalsColumn ropts) >> [Spr.headerCell "Total"]) ++
356361
(guard (average_ ropts) >> [Spr.headerCell "Average"])
362+
headerrow = leadingHeaders ++ dataHeaders
357363

358364
blankrow =
359365
fmap (Spr.horizontalSpan headerrow . Spr.defaultCell) maybeBlank

0 commit comments

Comments
 (0)