cli: CompoundBalance.compoundBalanceReportAsSpreadsheet: somehow support layout tidy
However, it is not quite correct since it contains totals and net values.
This commit is contained in:
parent
270360a103
commit
49f1af04ef
@ -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 ()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user