cli: Make --no-total remove subtotals from CompoundBalanceReport, not just net total.

This commit is contained in:
Stephen Morgan 2020-06-16 16:12:06 +10:00 committed by Simon Michael
parent d5801f382c
commit d2e0312ab1
4 changed files with 7 additions and 32 deletions

View File

@ -303,13 +303,12 @@ compoundBalanceReportAsText ropts (title, _colspans, subreports, (coltotals, gra
title ++ "\n\n" ++
balanceReportTableAsText ropts bigtable'
where
singlesubreport = length subreports == 1
bigtable =
case map (subreportAsTable ropts singlesubreport) subreports of
case map (subreportAsTable ropts) subreports of
[] -> T.empty
r:rs -> foldl' concatTables r rs
bigtable'
| no_total_ ropts || singlesubreport =
| no_total_ ropts || length subreports == 1 =
bigtable
| otherwise =
bigtable
@ -322,13 +321,10 @@ compoundBalanceReportAsText ropts (title, _colspans, subreports, (coltotals, gra
-- | Convert a named multi balance report to a table suitable for
-- concatenating with others to make a compound balance report table.
subreportAsTable ropts singlesubreport (title, r, _) = t
subreportAsTable ropts (title, r, _) = t
where
-- unless there's only one section, always show the subtotal row
ropts' | singlesubreport = ropts
| otherwise = ropts{ no_total_=False }
-- convert to table
Table lefthdrs tophdrs cells = balanceReportAsTable ropts' r
Table lefthdrs tophdrs cells = balanceReportAsTable ropts r
-- tweak the layout
t = Table (T.Group SingleLine [Header title, lefthdrs]) tophdrs ([]:cells)
@ -349,17 +345,12 @@ compoundBalanceReportAsCsv ropts (title, colspans, subreports, (coltotals, grand
++ (if row_total_ ropts then ["Total"] else [])
++ (if average_ ropts then ["Average"] else [])
) :
concatMap (subreportAsCsv ropts singlesubreport) subreports
concatMap (subreportAsCsv ropts) subreports
where
singlesubreport = length subreports == 1
-- | Add a subreport title row and drop the heading row.
subreportAsCsv ropts singlesubreport (subreporttitle, multibalreport, _) =
subreportAsCsv ropts (subreporttitle, multibalreport, _) =
padRow subreporttitle :
tail (multiBalanceReportAsCsv ropts' multibalreport)
where
-- unless there's only one section, always show the subtotal row
ropts' | singlesubreport = ropts
| otherwise = ropts{ no_total_=False }
tail (multiBalanceReportAsCsv ropts multibalreport)
padRow s = take numcols $ s : repeat ""
where
numcols

View File

@ -132,14 +132,10 @@ Balance Sheet 2008-01-31..2008-12-31
assets:bank:checking || $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 $1 0 $1
assets:bank:saving || 0 0 0 0 0 $1 $1 $1 $1 $1 $1 $1 $1
assets:cash || 0 0 0 0 0 $-2 $-2 $-2 $-2 $-2 $-2 $-2 $-1
----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
|| $1 $1 $1 $1 $1 0 0 0 0 0 0 $-1 0
======================++=========================================================================================================================================================
Liabilities ||
----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $-1 0
----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
|| 0 0 0 0 0 0 0 0 0 0 0 $-1 0
>>>= 0
# 5. Tree output still works, #565

View File

@ -295,14 +295,10 @@ Income Statement 2008
-------------------++----------------------------------------------------
income:gifts || 0 100.0 % 0 0 50.0 % 50.0 %
income:salary || 100.0 % 0 0 0 50.0 % 50.0 %
-------------------++----------------------------------------------------
|| 100.0 % 100.0 % 0 0 100.0 % 100.0 %
===================++====================================================
Expenses ||
-------------------++----------------------------------------------------
expenses:food || 0 50.0 % 0 0 50.0 % 50.0 %
expenses:supplies || 0 50.0 % 0 0 50.0 % 50.0 %
-------------------++----------------------------------------------------
|| 0 100.0 % 0 0 100.0 % 100.0 %
>>>= 0

View File

@ -32,15 +32,11 @@ Balance Sheet 2018-01-01
Assets ||
-------------++------------
b:bb || 3
-------------++------------
|| 3
=============++============
Liabilities ||
-------------++------------
asset:a || -1
b || -2
-------------++------------
|| -3
# 3. Tree mode. A little weird, b appears twice.
# It must be shown above bb, but since not an asset, its balance is excluded there.
@ -54,16 +50,12 @@ Balance Sheet 2018-01-01
-------------++------------
b || 3
bb || 3
-------------++------------
|| 3
=============++============
Liabilities ||
-------------++------------
asset || -1
a || -1
b || -2
-------------++------------
|| -3
# TODO
# a trailing : should give a clear error