diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index a92e9c3bc..e29dab625 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -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 diff --git a/tests/balancesheet.test b/tests/balancesheet.test index 5dc8276af..98caf2550 100644 --- a/tests/balancesheet.test +++ b/tests/balancesheet.test @@ -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 diff --git a/tests/incomestatement.test b/tests/incomestatement.test index a6b08d5b6..5e7a276d6 100644 --- a/tests/incomestatement.test +++ b/tests/incomestatement.test @@ -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 diff --git a/tests/journal/directives-account.test b/tests/journal/directives-account.test index 36eacd582..f4bf0463d 100644 --- a/tests/journal/directives-account.test +++ b/tests/journal/directives-account.test @@ -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