bs/bse/cf/is: don't repeat the headings row for each subreport
This commit is contained in:
parent
a26f7a9f51
commit
73ba78f092
@ -304,30 +304,25 @@ concatTables (Table hLeft hTop dat) (Table hLeft' _ dat') =
|
|||||||
Table (T.Group DoubleLine [hLeft, hLeft']) hTop (dat ++ dat')
|
Table (T.Group DoubleLine [hLeft, hLeft']) hTop (dat ++ dat')
|
||||||
|
|
||||||
-- | Render a compound balance report as CSV.
|
-- | Render a compound balance report as CSV.
|
||||||
{- Eg:
|
-- Subreports' CSV is concatenated, with the headings rows replaced by a
|
||||||
ghci> :main -f examples/sample.journal bs -Y -O csv -AT
|
-- subreport title row, and an overall title row, one headings row, and an
|
||||||
"Balance Sheet","","","","",""
|
-- optional overall totals row is added.
|
||||||
"Assets","","","","",""
|
|
||||||
"account","short account","indent","2008","total","average"
|
|
||||||
"assets:bank:saving","saving","3","$1","$1","$1"
|
|
||||||
"assets:cash","cash","2","$-2","$-2","$-2"
|
|
||||||
"totals","","","$-1","$-1","$-1"
|
|
||||||
"Liabilities","","","","",""
|
|
||||||
"account","short account","indent","2008","total","average"
|
|
||||||
"liabilities:debts","debts","2","$1","$1","$1"
|
|
||||||
"totals","","","$1","$1","$1"
|
|
||||||
"Total","0","0","0"
|
|
||||||
-}
|
|
||||||
compoundBalanceReportAsCsv :: ReportOpts -> CompoundBalanceReport -> CSV
|
compoundBalanceReportAsCsv :: ReportOpts -> CompoundBalanceReport -> CSV
|
||||||
compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grandtotal, grandavg)) =
|
compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grandtotal, grandavg)) =
|
||||||
addtotals $
|
addtotals $
|
||||||
padRow title :
|
padRow title :
|
||||||
|
("Account" :
|
||||||
|
map showDateSpan colspans
|
||||||
|
++ (if row_total_ ropts then ["Total"] else [])
|
||||||
|
++ (if average_ ropts then ["Average"] else [])
|
||||||
|
) :
|
||||||
concatMap (subreportAsCsv ropts singlesubreport) subreports
|
concatMap (subreportAsCsv ropts singlesubreport) subreports
|
||||||
where
|
where
|
||||||
singlesubreport = length subreports == 1
|
singlesubreport = length subreports == 1
|
||||||
|
-- | Add a subreport title row and drop the heading row.
|
||||||
subreportAsCsv ropts singlesubreport (subreporttitle, multibalreport) =
|
subreportAsCsv ropts singlesubreport (subreporttitle, multibalreport) =
|
||||||
padRow subreporttitle :
|
padRow subreporttitle :
|
||||||
multiBalanceReportAsCsv ropts' multibalreport
|
tail (multiBalanceReportAsCsv ropts' multibalreport)
|
||||||
where
|
where
|
||||||
-- unless there's only one section, always show the subtotal row
|
-- unless there's only one section, always show the subtotal row
|
||||||
ropts' | singlesubreport = ropts
|
ropts' | singlesubreport = ropts
|
||||||
@ -346,7 +341,7 @@ compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grand
|
|||||||
addtotals
|
addtotals
|
||||||
| no_total_ ropts || length subreports == 1 = id
|
| no_total_ ropts || length subreports == 1 = id
|
||||||
| otherwise = (++
|
| otherwise = (++
|
||||||
["Total" :
|
["Grand total" :
|
||||||
map showMixedAmountOneLineWithoutPrice (
|
map showMixedAmountOneLineWithoutPrice (
|
||||||
coltotals
|
coltotals
|
||||||
++ (if row_total_ ropts then [grandtotal] else [])
|
++ (if row_total_ ropts then [grandtotal] else [])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user