From 2fd2110f3d0a2c90dc36b289868ef73a0b37d638 Mon Sep 17 00:00:00 2001 From: Henning Thielemann Date: Fri, 4 Oct 2024 08:53:08 +0200 Subject: [PATCH] cli: Cli.Commands.Balance.multiBalanceReportHtmlRows: removed export multiBalanceReportAsSpreadsheetParts for use in compoundBalanceReportAsHtml --- hledger/Hledger/Cli/Commands/Balance.hs | 22 +++---------------- hledger/Hledger/Cli/CompoundBalanceCommand.hs | 10 ++++++--- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 05f717bc1..31a898281 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -259,10 +259,10 @@ module Hledger.Cli.Commands.Balance ( ,multiBalanceReportAsText ,multiBalanceReportAsCsv ,multiBalanceReportAsHtml - ,multiBalanceReportHtmlRows ,multiBalanceReportAsTable ,multiBalanceReportTableAsText ,multiBalanceReportAsSpreadsheet + ,multiBalanceReportAsSpreadsheetParts ,multiBalanceHasTotalsColumn ,addTotalBorders ,addRowSpanHeader @@ -307,7 +307,6 @@ import Hledger.Cli.Utils import Hledger.Write.Csv (CSV, printCSV, printTSV) import Hledger.Write.Ods (printFods) import Hledger.Write.Html.Lucid (printHtml) -import qualified Hledger.Write.Html.Lucid as Html import qualified Hledger.Write.Spreadsheet as Ods @@ -781,7 +780,8 @@ multiBalanceReportAsCsv opts@ReportOpts{..} report = maybeTranspose allRows multiBalanceReportAsSpreadsheetParts False opts report maybeTranspose = if transpose_ then transpose else id --- Helper for CSV and ODS and HTML rendering. +-- | 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. multiBalanceReportAsSpreadsheetParts :: Bool -> ReportOpts -> MultiBalanceReport -> ([Ods.Cell Ods.NumLines Text], @@ -829,22 +829,6 @@ multiBalanceReportAsHtml ropts mbr = printHtml . map (map (fmap L.toHtml)) $ snd $ multiBalanceReportAsSpreadsheet ropts mbr --- | Render the HTML table rows for a MultiBalanceReport. --- Returns the heading row, 0 or more body rows, and the totals row if enabled. -multiBalanceReportHtmlRows :: ReportOpts -> MultiBalanceReport -> (Html (), [Html ()], [Html ()]) -multiBalanceReportHtmlRows ropts mbr = - let - -- TODO: should the commodity_column be displayed as a subaccount in this case as well? - (headingsrow, bodyrows, mtotalsrows) - | transpose_ ropts = error' "Sorry, --transpose with HTML output is not yet supported" -- PARTIAL: - | otherwise = multiBalanceReportAsSpreadsheetParts True ropts mbr - formatRow = Html.formatRow . map (fmap L.toHtml) - in - (formatRow headingsrow - ,map formatRow bodyrows - ,map formatRow mtotalsrows - ) - -- | Render the ODS table rows for a MultiBalanceReport. -- Returns the heading row, 0 or more body rows, and the totals row if enabled. multiBalanceReportAsSpreadsheet :: diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 10e8d3b5b..0593741ac 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -365,11 +365,15 @@ compoundBalanceReportAsHtml ropts cbr = subreportrows :: (T.Text, MultiBalanceReport, Bool) -> [Html ()] subreportrows (subreporttitle, mbr, _increasestotal) = let - (_,bodyrows,mtotalsrows) = multiBalanceReportHtmlRows ropts mbr + -- TODO: should the commodity_column be displayed as a subaccount in this case as well? + (_, bodyrows, mtotalsrows) = + multiBalanceReportAsSpreadsheetParts True ropts mbr + formatRow = Html.formatRow . map (fmap L.toHtml) + in [tr_ $ th_ [colspanattr, leftattr, class_ "account"] $ toHtml subreporttitle] - ++ bodyrows - ++ mtotalsrows + ++ map formatRow bodyrows + ++ map formatRow mtotalsrows ++ [blankrow] totalrows =