cli: CompoundBalanceCommand: row_total_ -> multiBalanceHasTotalsColumn (bugfix)
This way, total column header is not shown in balancesheet. This is consistent with table data and with compoundBalanceReportAsText.
This commit is contained in:
parent
c969e66049
commit
6b5a158935
@ -260,6 +260,7 @@ module Hledger.Cli.Commands.Balance (
|
|||||||
,multiBalanceReportAsTable
|
,multiBalanceReportAsTable
|
||||||
,multiBalanceReportTableAsText
|
,multiBalanceReportTableAsText
|
||||||
,multiBalanceReportAsSpreadsheet
|
,multiBalanceReportAsSpreadsheet
|
||||||
|
,multiBalanceHasTotalsColumn
|
||||||
,addTotalBorders
|
,addTotalBorders
|
||||||
,addRowSpanHeader
|
,addRowSpanHeader
|
||||||
,simpleDateSpanCell
|
,simpleDateSpanCell
|
||||||
@ -913,7 +914,7 @@ multiBalanceReportTableAsText ReportOpts{..} = renderTableByRowsB tableopts rend
|
|||||||
|
|
||||||
-- | Build a 'Table' from a multi-column balance report.
|
-- | Build a 'Table' from a multi-column balance report.
|
||||||
multiBalanceReportAsTable :: ReportOpts -> MultiBalanceReport -> Table T.Text T.Text WideBuilder
|
multiBalanceReportAsTable :: ReportOpts -> MultiBalanceReport -> Table T.Text T.Text WideBuilder
|
||||||
multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, row_total_, balanceaccum_}
|
multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, balanceaccum_}
|
||||||
(PeriodicReport spans items tr) =
|
(PeriodicReport spans items tr) =
|
||||||
maybetranspose $
|
maybetranspose $
|
||||||
addtotalrow $
|
addtotalrow $
|
||||||
@ -922,10 +923,9 @@ multiBalanceReportAsTable opts@ReportOpts{summary_only_, average_, row_total_, b
|
|||||||
(Group multiColumnTableInterColumnBorder $ map Header colheadings)
|
(Group multiColumnTableInterColumnBorder $ map Header colheadings)
|
||||||
(concat rows)
|
(concat rows)
|
||||||
where
|
where
|
||||||
totalscolumn = row_total_ && balanceaccum_ `notElem` [Cumulative, Historical]
|
|
||||||
colheadings = ["Commodity" | layout_ opts == LayoutBare]
|
colheadings = ["Commodity" | layout_ opts == LayoutBare]
|
||||||
++ (if not summary_only_ then map (reportPeriodName balanceaccum_ spans) spans else [])
|
++ (if not summary_only_ then map (reportPeriodName balanceaccum_ spans) spans else [])
|
||||||
++ [" Total" | totalscolumn]
|
++ [" Total" | multiBalanceHasTotalsColumn opts]
|
||||||
++ ["Average" | average_]
|
++ ["Average" | average_]
|
||||||
(accts, rows) = unzip $ fmap fullRowAsTexts items
|
(accts, rows) = unzip $ fmap fullRowAsTexts items
|
||||||
where
|
where
|
||||||
@ -950,7 +950,7 @@ multiBalanceRowAsCellBuilders ::
|
|||||||
RowClass -> (DateSpan -> Ods.Cell Ods.NumLines Text) ->
|
RowClass -> (DateSpan -> Ods.Cell Ods.NumLines Text) ->
|
||||||
PeriodicReportRow a MixedAmount ->
|
PeriodicReportRow a MixedAmount ->
|
||||||
[[Ods.Cell Ods.NumLines WideBuilder]]
|
[[Ods.Cell Ods.NumLines WideBuilder]]
|
||||||
multiBalanceRowAsCellBuilders bopts ReportOpts{..} colspans
|
multiBalanceRowAsCellBuilders bopts ropts@ReportOpts{..} colspans
|
||||||
rc renderDateSpanCell (PeriodicReportRow _acct as rowtot rowavg) =
|
rc renderDateSpanCell (PeriodicReportRow _acct as rowtot rowavg) =
|
||||||
case layout_ of
|
case layout_ of
|
||||||
LayoutWide width -> [fmap (cellFromMixedAmount bopts{displayMaxWidth=width}) clsamts]
|
LayoutWide width -> [fmap (cellFromMixedAmount bopts{displayMaxWidth=width}) clsamts]
|
||||||
@ -971,12 +971,12 @@ multiBalanceRowAsCellBuilders bopts ReportOpts{..} colspans
|
|||||||
where
|
where
|
||||||
wbCell = Ods.defaultCell . wbFromText
|
wbCell = Ods.defaultCell . wbFromText
|
||||||
wbDate content = (wbCell content) {Ods.cellType = Ods.TypeDate}
|
wbDate content = (wbCell content) {Ods.cellType = Ods.TypeDate}
|
||||||
totalscolumn = row_total_ && balanceaccum_ `notElem` [Cumulative, Historical]
|
|
||||||
cs = if all mixedAmountLooksZero allamts then [""] else S.toList $ foldMap maCommodities allamts
|
cs = if all mixedAmountLooksZero allamts then [""] else S.toList $ foldMap maCommodities allamts
|
||||||
classified = map ((,) (amountClass rc)) as
|
classified = map ((,) (amountClass rc)) as
|
||||||
allamts = map snd clsamts
|
allamts = map snd clsamts
|
||||||
clsamts = (if not summary_only_ then classified else []) ++
|
clsamts = (if not summary_only_ then classified else []) ++
|
||||||
[(rowTotalClass rc, rowtot) | totalscolumn && not (null as)] ++
|
[(rowTotalClass rc, rowtot) |
|
||||||
|
multiBalanceHasTotalsColumn ropts && not (null as)] ++
|
||||||
[(rowAverageClass rc, rowavg) | average_ && not (null as)]
|
[(rowAverageClass rc, rowavg) | average_ && not (null as)]
|
||||||
addDateColumns spn@(DateSpan s e) remCols =
|
addDateColumns spn@(DateSpan s e) remCols =
|
||||||
(wbFromText <$> renderDateSpanCell spn) :
|
(wbFromText <$> renderDateSpanCell spn) :
|
||||||
@ -999,6 +999,10 @@ multiBalanceRowAsCellBuilders bopts ReportOpts{..} colspans
|
|||||||
m [] = [n]
|
m [] = [n]
|
||||||
|
|
||||||
|
|
||||||
|
multiBalanceHasTotalsColumn :: ReportOpts -> Bool
|
||||||
|
multiBalanceHasTotalsColumn ropts =
|
||||||
|
row_total_ ropts && balanceaccum_ ropts `notElem` [Cumulative, Historical]
|
||||||
|
|
||||||
multiBalanceRowAsText :: ReportOpts -> PeriodicReportRow a MixedAmount -> [[WideBuilder]]
|
multiBalanceRowAsText :: ReportOpts -> PeriodicReportRow a MixedAmount -> [[WideBuilder]]
|
||||||
multiBalanceRowAsText opts =
|
multiBalanceRowAsText opts =
|
||||||
rawTableContent .
|
rawTableContent .
|
||||||
|
|||||||
@ -311,7 +311,7 @@ compoundBalanceReportAsCsv ropts (CompoundPeriodicReport title colspans subrepor
|
|||||||
: ( "Account"
|
: ( "Account"
|
||||||
: ["Commodity" | layout_ ropts == LayoutBare]
|
: ["Commodity" | layout_ ropts == LayoutBare]
|
||||||
++ map (reportPeriodName (balanceaccum_ ropts) colspans) colspans
|
++ map (reportPeriodName (balanceaccum_ ropts) colspans) colspans
|
||||||
++ (if row_total_ ropts then ["Total"] else [])
|
++ (if multiBalanceHasTotalsColumn ropts then ["Total"] else [])
|
||||||
++ (if average_ ropts then ["Average"] else [])
|
++ (if average_ ropts then ["Average"] else [])
|
||||||
)
|
)
|
||||||
: concatMap (subreportAsCsv ropts) subreports
|
: concatMap (subreportAsCsv ropts) subreports
|
||||||
@ -327,7 +327,7 @@ compoundBalanceReportAsCsv ropts (CompoundPeriodicReport title colspans subrepor
|
|||||||
| otherwise =
|
| otherwise =
|
||||||
(1 +) $ -- account name column
|
(1 +) $ -- account name column
|
||||||
(if layout_ ropts == LayoutBare then (1+) else id) $
|
(if layout_ ropts == LayoutBare then (1+) else id) $
|
||||||
(if row_total_ ropts then (1+) else id) $
|
(if multiBalanceHasTotalsColumn ropts then (1+) else id) $
|
||||||
(if average_ ropts then (1+) else id) $
|
(if average_ ropts then (1+) else id) $
|
||||||
maximum $ -- depends on non-null subreports
|
maximum $ -- depends on non-null subreports
|
||||||
map (length . prDates . second3) subreports
|
map (length . prDates . second3) subreports
|
||||||
@ -343,7 +343,7 @@ compoundBalanceReportAsHtml ropts cbr =
|
|||||||
colspanattr = colspan_ $ T.pack $ show $ sum [
|
colspanattr = colspan_ $ T.pack $ show $ sum [
|
||||||
1,
|
1,
|
||||||
length colspans,
|
length colspans,
|
||||||
if row_total_ ropts then 1 else 0,
|
if multiBalanceHasTotalsColumn ropts then 1 else 0,
|
||||||
if average_ ropts then 1 else 0,
|
if average_ ropts then 1 else 0,
|
||||||
if layout_ ropts == LayoutBare then 1 else 0
|
if layout_ ropts == LayoutBare then 1 else 0
|
||||||
]
|
]
|
||||||
@ -356,7 +356,7 @@ compoundBalanceReportAsHtml ropts cbr =
|
|||||||
th_ ""
|
th_ ""
|
||||||
when (layout_ ropts == LayoutBare) $ th_ "Commodity"
|
when (layout_ ropts == LayoutBare) $ th_ "Commodity"
|
||||||
mconcat $ map (th_ [style_ alignright] . toHtml . reportPeriodName (balanceaccum_ ropts) colspans) colspans
|
mconcat $ map (th_ [style_ alignright] . toHtml . reportPeriodName (balanceaccum_ ropts) colspans) colspans
|
||||||
when (row_total_ ropts) $ th_ "Total"
|
when (multiBalanceHasTotalsColumn ropts) $ th_ "Total"
|
||||||
when (average_ ropts) $ th_ "Average"
|
when (average_ ropts) $ th_ "Average"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user