diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 81191ed78..dc18af1ab 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -580,7 +580,8 @@ multiBalanceReportAsCsvHelper ishtml opts@ReportOpts{..} (PeriodicReport colspan where showName = accountNameDrop drop_ . prrFullName totalrows | no_total_ = mempty - | otherwise = map ("total" :) $ rowAsText opts colspans tr + | ishtml = zipWith (:) ("total":repeat "") $ rowAsText opts colspans tr + | otherwise = map ("total" :) $ rowAsText opts colspans tr rowAsText = if ishtml then multiBalanceRowAsHtmlText else multiBalanceRowAsCsvText -- | Render a multi-column balance report as HTML. diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 456e8b87f..da95e9cc5 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -29,6 +29,7 @@ import Hledger import Hledger.Cli.Commands.Balance import Hledger.Cli.CliOptions import Hledger.Cli.Utils (unsupportedOutputFormatError, writeOutputLazyText) +import Data.Function ((&)) -- | Description of a compound balance report command, -- from which we generate the command's cmdargs mode and IO action. @@ -337,8 +338,13 @@ compoundBalanceReportAsHtml ropts cbr = ++ mtotalsrows ++ [blankrow] - totalrows | no_total_ ropts || length subreports == 1 = [] - | otherwise = multiBalanceReportHtmlFootRow ropts <$> (("Net:" :) <$> multiBalanceRowAsCsvText ropts colspans totalrow) + totalrows = + if no_total_ ropts || length subreports == 1 then [] + else + multiBalanceRowAsCsvText ropts colspans totalrow -- make a table of rendered lines of the report totals row + & zipWith (:) ("Net:":repeat "") -- insert a headings column, with Net: on the first line only + & map (multiBalanceReportHtmlFootRow ropts) -- convert to a list of HTML totals rows + in do style_ (T.unlines ["" ,"td { padding:0 0.5em; }"