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" ++ title ++ "\n\n" ++
balanceReportTableAsText ropts bigtable' balanceReportTableAsText ropts bigtable'
where where
singlesubreport = length subreports == 1
bigtable = bigtable =
case map (subreportAsTable ropts singlesubreport) subreports of case map (subreportAsTable ropts) subreports of
[] -> T.empty [] -> T.empty
r:rs -> foldl' concatTables r rs r:rs -> foldl' concatTables r rs
bigtable' bigtable'
| no_total_ ropts || singlesubreport = | no_total_ ropts || length subreports == 1 =
bigtable bigtable
| otherwise = | otherwise =
bigtable bigtable
@ -322,13 +321,10 @@ compoundBalanceReportAsText ropts (title, _colspans, subreports, (coltotals, gra
-- | Convert a named multi balance report to a table suitable for -- | Convert a named multi balance report to a table suitable for
-- concatenating with others to make a compound balance report table. -- concatenating with others to make a compound balance report table.
subreportAsTable ropts singlesubreport (title, r, _) = t subreportAsTable ropts (title, r, _) = t
where where
-- unless there's only one section, always show the subtotal row
ropts' | singlesubreport = ropts
| otherwise = ropts{ no_total_=False }
-- convert to table -- convert to table
Table lefthdrs tophdrs cells = balanceReportAsTable ropts' r Table lefthdrs tophdrs cells = balanceReportAsTable ropts r
-- tweak the layout -- tweak the layout
t = Table (T.Group SingleLine [Header title, lefthdrs]) tophdrs ([]:cells) 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 row_total_ ropts then ["Total"] else [])
++ (if average_ ropts then ["Average"] else []) ++ (if average_ ropts then ["Average"] else [])
) : ) :
concatMap (subreportAsCsv ropts singlesubreport) subreports concatMap (subreportAsCsv ropts) subreports
where where
singlesubreport = length subreports == 1
-- | Add a subreport title row and drop the heading row. -- | Add a subreport title row and drop the heading row.
subreportAsCsv ropts singlesubreport (subreporttitle, multibalreport, _) = subreportAsCsv ropts (subreporttitle, multibalreport, _) =
padRow subreporttitle : padRow subreporttitle :
tail (multiBalanceReportAsCsv ropts' multibalreport) tail (multiBalanceReportAsCsv ropts multibalreport)
where
-- unless there's only one section, always show the subtotal row
ropts' | singlesubreport = ropts
| otherwise = ropts{ no_total_=False }
padRow s = take numcols $ s : repeat "" padRow s = take numcols $ s : repeat ""
where where
numcols 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: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: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 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 ||
----------------------++--------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------++---------------------------------------------------------------------------------------------------------------------------------------------------------
liabilities:debts || 0 0 0 0 0 0 0 0 0 0 0 $-1 0 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 >>>= 0
# 5. Tree output still works, #565 # 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:gifts || 0 100.0 % 0 0 50.0 % 50.0 %
income:salary || 100.0 % 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 ||
-------------------++---------------------------------------------------- -------------------++----------------------------------------------------
expenses:food || 0 50.0 % 0 0 50.0 % 50.0 % expenses:food || 0 50.0 % 0 0 50.0 % 50.0 %
expenses:supplies || 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 >>>= 0

View File

@ -32,15 +32,11 @@ Balance Sheet 2018-01-01
Assets || Assets ||
-------------++------------ -------------++------------
b:bb || 3 b:bb || 3
-------------++------------
|| 3
=============++============ =============++============
Liabilities || Liabilities ||
-------------++------------ -------------++------------
asset:a || -1 asset:a || -1
b || -2 b || -2
-------------++------------
|| -3
# 3. Tree mode. A little weird, b appears twice. # 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. # 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 b || 3
bb || 3 bb || 3
-------------++------------
|| 3
=============++============ =============++============
Liabilities || Liabilities ||
-------------++------------ -------------++------------
asset || -1 asset || -1
a || -1 a || -1
b || -2 b || -2
-------------++------------
|| -3
# TODO # TODO
# a trailing : should give a clear error # a trailing : should give a clear error