From 73ba78f0920f4c457a2c13a7ff94bbbd3897d18b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 14 Jan 2018 17:51:10 -0800 Subject: [PATCH] bs/bse/cf/is: don't repeat the headings row for each subreport --- hledger/Hledger/Cli/CompoundBalanceCommand.hs | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 7fc9b6a15..c0a7e81c3 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -304,30 +304,25 @@ concatTables (Table hLeft hTop dat) (Table hLeft' _ dat') = Table (T.Group DoubleLine [hLeft, hLeft']) hTop (dat ++ dat') -- | Render a compound balance report as CSV. -{- Eg: -ghci> :main -f examples/sample.journal bs -Y -O csv -AT -"Balance Sheet","","","","","" -"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" --} +-- Subreports' CSV is concatenated, with the headings rows replaced by a +-- subreport title row, and an overall title row, one headings row, and an +-- optional overall totals row is added. compoundBalanceReportAsCsv :: ReportOpts -> CompoundBalanceReport -> CSV compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grandtotal, grandavg)) = addtotals $ padRow title : + ("Account" : + map showDateSpan colspans + ++ (if row_total_ ropts then ["Total"] else []) + ++ (if average_ ropts then ["Average"] else []) + ) : concatMap (subreportAsCsv ropts singlesubreport) subreports where singlesubreport = length subreports == 1 + -- | Add a subreport title row and drop the heading row. subreportAsCsv ropts singlesubreport (subreporttitle, multibalreport) = padRow subreporttitle : - multiBalanceReportAsCsv ropts' multibalreport + tail (multiBalanceReportAsCsv ropts' multibalreport) where -- unless there's only one section, always show the subtotal row ropts' | singlesubreport = ropts @@ -346,7 +341,7 @@ compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grand addtotals | no_total_ ropts || length subreports == 1 = id | otherwise = (++ - ["Total" : + ["Grand total" : map showMixedAmountOneLineWithoutPrice ( coltotals ++ (if row_total_ ropts then [grandtotal] else [])