include the column spans explicitly in CompoundBalanceReport

This commit is contained in:
Simon Michael 2018-01-14 17:49:45 -08:00
parent 32693de44a
commit a26f7a9f51

View File

@ -168,8 +168,13 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{command_=cmd,
| otherwise = grandtotal `divideMixedAmount` fromIntegral (length coltotals) | otherwise = grandtotal `divideMixedAmount` fromIntegral (length coltotals)
in in
(coltotals, grandtotal, grandavg) (coltotals, grandtotal, grandavg)
colspans =
case namedsubreports of
(_, MultiBalanceReport (ds,_,_)):_ -> ds
[] -> []
cbr = cbr =
(title (title
,colspans
,namedsubreports ,namedsubreports
,overalltotals ,overalltotals
) )
@ -207,7 +212,9 @@ compoundBalanceCommandSingleColumnReport ropts userq j subreporttitle subreportq
-- --
-- * an overall title -- * an overall title
-- --
-- * one or more named multi balance reports, with the same column headings -- * the period (date span) of each column
--
-- * one or more named multi balance reports, with columns corresponding to the above
-- --
-- * a list of overall totals for each column, and their grand total and average -- * a list of overall totals for each column, and their grand total and average
-- --
@ -215,6 +222,7 @@ compoundBalanceCommandSingleColumnReport ropts userq j subreporttitle subreportq
-- cashflow and incomestatement. -- cashflow and incomestatement.
type CompoundBalanceReport = type CompoundBalanceReport =
( String ( String
, [DateSpan]
, [(String, MultiBalanceReport)] , [(String, MultiBalanceReport)]
, ([MixedAmount], MixedAmount, MixedAmount) , ([MixedAmount], MixedAmount, MixedAmount)
) )
@ -258,7 +266,7 @@ Balance Sheet
-} -}
compoundBalanceReportAsText :: ReportOpts -> CompoundBalanceReport -> String compoundBalanceReportAsText :: ReportOpts -> CompoundBalanceReport -> String
compoundBalanceReportAsText ropts (title, subreports, (coltotals, grandtotal, grandavg)) = compoundBalanceReportAsText ropts (title, _colspans, subreports, (coltotals, grandtotal, grandavg)) =
title ++ "\n\n" ++ title ++ "\n\n" ++
renderBalanceReportTable ropts bigtable' renderBalanceReportTable ropts bigtable'
where where
@ -311,7 +319,7 @@ ghci> :main -f examples/sample.journal bs -Y -O csv -AT
"Total","0","0","0" "Total","0","0","0"
-} -}
compoundBalanceReportAsCsv :: ReportOpts -> CompoundBalanceReport -> CSV compoundBalanceReportAsCsv :: ReportOpts -> CompoundBalanceReport -> CSV
compoundBalanceReportAsCsv ropts (title, subreports, (coltotals, grandtotal, grandavg)) = compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grandtotal, grandavg)) =
addtotals $ addtotals $
padRow title : padRow title :
concatMap (subreportAsCsv ropts singlesubreport) subreports concatMap (subreportAsCsv ropts singlesubreport) subreports