cli: Cli.Commands.Balance.budgetReportAsSpreadsheet: support for tree mode

use renderPeriodicAcct
This commit is contained in:
Henning Thielemann 2024-10-01 12:41:00 +02:00 committed by Simon Michael
parent e21a8e6d76
commit 6b0cca4fa8

View File

@ -1265,7 +1265,7 @@ budgetReportAsCsv ropts report
budgetReportAsSpreadsheet :: budgetReportAsSpreadsheet ::
ReportOpts -> BudgetReport -> [[Ods.Cell Ods.NumLines Text]] ReportOpts -> BudgetReport -> [[Ods.Cell Ods.NumLines Text]]
budgetReportAsSpreadsheet budgetReportAsSpreadsheet
ReportOpts{..} ropts@ReportOpts{..}
(PeriodicReport colspans items totrow) (PeriodicReport colspans items totrow)
= (if transpose_ then Ods.transpose else id) $ = (if transpose_ then Ods.transpose else id) $
@ -1279,14 +1279,18 @@ budgetReportAsSpreadsheet
) : ) :
-- account rows -- account rows
concatMap (rowAsTexts Value prrFullName) items concatMap (\row -> rowAsTexts Value (accountCell row) row) items
-- totals row -- totals row
++ addTotalBorders ++ addTotalBorders
(concat [ rowAsTexts Total (const totalRowHeadingBudgetCsv) totrow | not no_total_ ]) (concat [ rowAsTexts Total (cell totalRowHeadingBudgetCsv) totrow | not no_total_ ])
where where
cell = Ods.defaultCell cell = Ods.defaultCell
accountCell row =
let name = prrFullName row in
setAccountAnchor (balance_base_url_) querystring_ name $
cell $ renderPeriodicAcct ropts nbsp row
{- {-
ToDo: The chosen HTML cell class names are not put in stone. ToDo: The chosen HTML cell class names are not put in stone.
If you find you need more systematic names, If you find you need more systematic names,
@ -1298,17 +1302,18 @@ budgetReportAsSpreadsheet
maybe Ods.emptyCell (fmap wbToText . curry (cellFromMixedAmount oneLineNoCostFmt) cls) mval maybe Ods.emptyCell (fmap wbToText . curry (cellFromMixedAmount oneLineNoCostFmt) cls) mval
rowAsTexts :: RowClass rowAsTexts :: RowClass
-> (PeriodicReportRow a BudgetCell -> Text) -> Ods.Cell Ods.NumLines Text
-> PeriodicReportRow a BudgetCell -> PeriodicReportRow a BudgetCell
-> [[Ods.Cell Ods.NumLines Text]] -> [[Ods.Cell Ods.NumLines Text]]
rowAsTexts rc render row@(PeriodicReportRow _ as (rowtot,budgettot) (rowavg, budgetavg)) rowAsTexts rc acctCell (PeriodicReportRow _ as (rowtot,budgettot) (rowavg, budgetavg)) =
| layout_ /= LayoutBare = [accountCell : map showNorm vals] addRowSpanHeader acctCell $
| otherwise = case layout_ of
addRowSpanHeader accountCell -- add name LayoutBare ->
. zipWith (:) (map cell cs) -- add symbols zipWith (:) (map cell cs) -- add symbols
. transpose -- each row becomes a list of Text quantities . transpose -- each row becomes a list of Text quantities
. map (map (fmap wbToText) . cellsFromMixedAmount dopts . second (fromMaybe nullmixedamt)) . map (map (fmap wbToText) . cellsFromMixedAmount dopts . second (fromMaybe nullmixedamt))
$ vals $ vals
_ -> [map showNorm vals]
where where
cs = S.toList . mconcat . map maCommodities $ mapMaybe snd vals cs = S.toList . mconcat . map maCommodities $ mapMaybe snd vals
dopts = oneLineNoCostFmt{displayCommodity=layout_ /= LayoutBare, displayCommodityOrder=Just cs, displayMinWidth=Nothing} dopts = oneLineNoCostFmt{displayCommodity=layout_ /= LayoutBare, displayCommodityOrder=Just cs, displayMinWidth=Nothing}
@ -1320,11 +1325,6 @@ budgetReportAsSpreadsheet
(budgetAverageClass rc, budgetavg)] (budgetAverageClass rc, budgetavg)]
| average_] | average_]
accountCell =
let name = render row in
setAccountAnchor (guard (rc==Value) >> balance_base_url_)
querystring_ name (cell name)
nbsp :: Text nbsp :: Text
nbsp = "\160" nbsp = "\160"