cli: Cli.Commands.Balance.multiBalanceReportAsSpreadsheetParts: parameter ishtml::Bool -> fmt::AmountFormat

arguments machineFmt, oneLineNoCostFmt are more descriptive than False, True
This commit is contained in:
Henning Thielemann 2024-10-04 09:38:37 +02:00 committed by Simon Michael
parent 2fd2110f3d
commit 2122444c4b
2 changed files with 8 additions and 8 deletions

View File

@ -777,17 +777,17 @@ multiBalanceReportAsCsv opts@ReportOpts{..} report = maybeTranspose allRows
_ -> rows ++ totals _ -> rows ++ totals
rows = header:body rows = header:body
(header, body, totals) = (header, body, totals) =
multiBalanceReportAsSpreadsheetParts False opts report multiBalanceReportAsSpreadsheetParts machineFmt opts report
maybeTranspose = if transpose_ then transpose else id maybeTranspose = if transpose_ then transpose else id
-- | Render the Spreadsheet table rows (CSV, ODS, HTML) for a MultiBalanceReport. -- | Render the Spreadsheet table rows (CSV, ODS, HTML) for a MultiBalanceReport.
-- Returns the heading row, 0 or more body rows, and the totals row if enabled. -- Returns the heading row, 0 or more body rows, and the totals row if enabled.
multiBalanceReportAsSpreadsheetParts :: multiBalanceReportAsSpreadsheetParts ::
Bool -> ReportOpts -> MultiBalanceReport -> AmountFormat -> ReportOpts -> MultiBalanceReport ->
([Ods.Cell Ods.NumLines Text], ([Ods.Cell Ods.NumLines Text],
[[Ods.Cell Ods.NumLines Text]], [[Ods.Cell Ods.NumLines Text]],
[[Ods.Cell Ods.NumLines Text]]) [[Ods.Cell Ods.NumLines Text]])
multiBalanceReportAsSpreadsheetParts ishtml opts@ReportOpts{..} (PeriodicReport colspans items tr) = multiBalanceReportAsSpreadsheetParts fmt opts@ReportOpts{..} (PeriodicReport colspans items tr) =
(headers, concatMap fullRowAsTexts items, addTotalBorders totalrows) (headers, concatMap fullRowAsTexts items, addTotalBorders totalrows)
where where
accountCell label = accountCell label =
@ -818,8 +818,7 @@ multiBalanceReportAsSpreadsheetParts ishtml opts@ReportOpts{..} (PeriodicReport
else addRowSpanHeader (accountCell totalRowHeadingSpreadsheet) $ else addRowSpanHeader (accountCell totalRowHeadingSpreadsheet) $
rowAsText Total simpleDateSpanCell tr rowAsText Total simpleDateSpanCell tr
rowAsText rc dsCell = rowAsText rc dsCell =
let fmt = if ishtml then oneLineNoCostFmt else machineFmt map (map (fmap wbToText)) .
in map (map (fmap wbToText)) .
multiBalanceRowAsCellBuilders fmt opts colspans rc dsCell multiBalanceRowAsCellBuilders fmt opts colspans rc dsCell
@ -835,7 +834,8 @@ multiBalanceReportAsSpreadsheet ::
ReportOpts -> MultiBalanceReport -> ReportOpts -> MultiBalanceReport ->
((Maybe Int, Maybe Int), [[Ods.Cell Ods.NumLines Text]]) ((Maybe Int, Maybe Int), [[Ods.Cell Ods.NumLines Text]])
multiBalanceReportAsSpreadsheet ropts mbr = multiBalanceReportAsSpreadsheet ropts mbr =
let (header,body,total) = multiBalanceReportAsSpreadsheetParts True ropts mbr let (header,body,total) =
multiBalanceReportAsSpreadsheetParts oneLineNoCostFmt ropts mbr
in (if transpose_ ropts then swap *** Ods.transpose else id) $ in (if transpose_ ropts then swap *** Ods.transpose else id) $
((Just 1, case layout_ ropts of LayoutWide _ -> Just 1; _ -> Nothing), ((Just 1, case layout_ ropts of LayoutWide _ -> Just 1; _ -> Nothing),
header : body ++ total) header : body ++ total)

View File

@ -367,7 +367,7 @@ compoundBalanceReportAsHtml ropts cbr =
let let
-- TODO: should the commodity_column be displayed as a subaccount in this case as well? -- TODO: should the commodity_column be displayed as a subaccount in this case as well?
(_, bodyrows, mtotalsrows) = (_, bodyrows, mtotalsrows) =
multiBalanceReportAsSpreadsheetParts True ropts mbr multiBalanceReportAsSpreadsheetParts oneLineNoCostFmt ropts mbr
formatRow = Html.formatRow . map (fmap L.toHtml) formatRow = Html.formatRow . map (fmap L.toHtml)
in in