cli: Cli.CompoundBalanceCommand.compoundBalanceReportAsHtml.headerrow: collect all column headers
colspanattr: count those headers This way, we can assert that colspanattr covers all columns.
This commit is contained in:
parent
2122444c4b
commit
746c927cee
@ -37,7 +37,7 @@ import Hledger.Cli.Commands.Balance
|
|||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.Cli.Utils (unsupportedOutputFormatError, writeOutputLazyText)
|
import Hledger.Cli.Utils (unsupportedOutputFormatError, writeOutputLazyText)
|
||||||
import Data.Function ((&))
|
import Data.Function ((&))
|
||||||
import Control.Monad (when)
|
import Control.Monad (guard)
|
||||||
|
|
||||||
-- | Description of a compound balance report command,
|
-- | Description of a compound balance report command,
|
||||||
-- from which we generate the command's cmdargs mode and IO action.
|
-- from which we generate the command's cmdargs mode and IO action.
|
||||||
@ -340,24 +340,22 @@ compoundBalanceReportAsHtml :: ReportOpts -> CompoundPeriodicReport DisplayName
|
|||||||
compoundBalanceReportAsHtml ropts cbr =
|
compoundBalanceReportAsHtml ropts cbr =
|
||||||
let
|
let
|
||||||
CompoundPeriodicReport title colspans subreports totalrow = cbr
|
CompoundPeriodicReport title colspans subreports totalrow = cbr
|
||||||
colspanattr = colspan_ $ T.pack $ show $ sum [
|
headerrow =
|
||||||
1,
|
th_ "" :
|
||||||
length colspans,
|
(guard (layout_ ropts == LayoutBare) >> [th_ "Commodity"]) ++
|
||||||
if multiBalanceHasTotalsColumn ropts then 1 else 0,
|
map (th_ [style_ alignright] . toHtml .
|
||||||
if average_ ropts then 1 else 0,
|
reportPeriodName (balanceaccum_ ropts) colspans)
|
||||||
if layout_ ropts == LayoutBare then 1 else 0
|
colspans ++
|
||||||
]
|
(guard (multiBalanceHasTotalsColumn ropts) >> [th_ "Total"]) ++
|
||||||
|
(guard (average_ ropts) >> [th_ "Average"])
|
||||||
|
|
||||||
|
colspanattr = colspan_ $ T.pack $ show $ length headerrow
|
||||||
leftattr = style_ alignleft
|
leftattr = style_ alignleft
|
||||||
blankrow = tr_ $ td_ [colspanattr] $ toHtmlRaw (" "::String)
|
blankrow = tr_ $ td_ [colspanattr] $ toHtmlRaw (" "::String)
|
||||||
|
|
||||||
titlerows =
|
titlerows =
|
||||||
[tr_ $ th_ [colspanattr, leftattr] $ h2_ $ toHtml title
|
[tr_ $ th_ [colspanattr, leftattr] $ h2_ $ toHtml title
|
||||||
,tr_ $ do
|
,tr_ $ mconcat headerrow
|
||||||
th_ ""
|
|
||||||
when (layout_ ropts == LayoutBare) $ th_ "Commodity"
|
|
||||||
mconcat $ map (th_ [style_ alignright] . toHtml . reportPeriodName (balanceaccum_ ropts) colspans) colspans
|
|
||||||
when (multiBalanceHasTotalsColumn ropts) $ th_ "Total"
|
|
||||||
when (average_ ropts) $ th_ "Average"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Make rows for a subreport: its title row, not the headings row,
|
-- Make rows for a subreport: its title row, not the headings row,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user