diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index b8fbc5c14..202207c6e 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -374,7 +374,7 @@ generateMultiBalanceReport rspec@ReportSpec{_rsReportOpts=ropts} j priceoracle u $ buildReportRows ropts displaynames matrix -- Calculate column totals - totalsrow = dbg5 "totalsrow" $ calculateTotalsRow ropts rows + totalsrow = dbg5 "totalsrow" $ calculateTotalsRow ropts rows $ length colps -- Sorted report rows. sortedrows = dbg5 "sortedrows" $ sortRows ropts j rows @@ -501,8 +501,8 @@ sortRows ropts j -- | Build the report totals row. -- -- Calculate the column totals. These are always the sum of column amounts. -calculateTotalsRow :: ReportOpts -> [MultiBalanceReportRow] -> PeriodicReportRow () MixedAmount -calculateTotalsRow ropts rows = +calculateTotalsRow :: ReportOpts -> [MultiBalanceReportRow] -> Int -> PeriodicReportRow () MixedAmount +calculateTotalsRow ropts rows colcount = PeriodicReportRow () coltotals grandtotal grandaverage where isTopRow row = flat_ ropts || not (any (`HM.member` rowMap) parents) @@ -511,7 +511,9 @@ calculateTotalsRow ropts rows = colamts = transpose . map prrAmounts $ filter isTopRow rows - coltotals :: [MixedAmount] = dbg5 "coltotals" $ map maSum colamts + coltotals :: [MixedAmount] = dbg5 "coltotals" $ case colamts of + [] -> replicate colcount nullmixedamt + _ -> map maSum colamts -- Calculate the grand total and average. These are always the sum/average -- of the column totals. diff --git a/hledger/test/balancesheet.test b/hledger/test/balancesheet.test index 95a09318b..69a464d42 100644 --- a/hledger/test/balancesheet.test +++ b/hledger/test/balancesheet.test @@ -19,7 +19,7 @@ Balance Sheet 2016-01-01 Liabilities || -------------++------------ -------------++------------ - || + || 0 =============++============ Net: || 1 @@ -42,7 +42,7 @@ Balance Sheet 2016-01-01 Liabilities || -------------++------------ -------------++------------ - || + || 0 =============++============ Net: || 1 @@ -171,7 +171,7 @@ Balance Sheet 2017-01-01 Liabilities || -------------++------------ -------------++------------ - || + || 0 =============++============ Net: || 1 @@ -193,7 +193,7 @@ Balance Sheet 2017-01-01 Liabilities || -------------++------------ -------------++------------ - || + || 0 =============++============ Net: || 1 @@ -215,7 +215,7 @@ Balance Sheet 2017-12-31 Liabilities || -------------++--------------------- -------------++--------------------- - || + || 0 0 =============++===================== Net: || $1 $1 @@ -238,7 +238,7 @@ Balance Sheet 2016-01-31 Liabilities ║ ─────────────╫──────────── ─────────────╫──────────── - ║ + ║ 0 ═════════════╬════════════ Net: ║ 1 @@ -276,7 +276,7 @@ Balance Sheet 2018-10-03 Liabilities || -------------------------------------++------------ -------------------------------------++------------ - || + || 0 =====================================++============ Net: || $120 @@ -303,7 +303,7 @@ Balance Sheet 2020-03-25 Liabilities || -------------++------------ -------------++------------ - || + || 0 =============++============ Net: || $1 @@ -315,7 +315,7 @@ $ hledger -f - balancesheet --tree --output-format=csv "assets:a","$1" "total","$1" "Liabilities","" -"total" +"total","0" "Net:","$1" # ** 13. CSV output supports --drop. @@ -326,7 +326,7 @@ $ hledger -f - balancesheet --tree --output-format=csv --drop 1 "a","$1" "total","$1" "Liabilities","" -"total" +"total","0" "Net:","$1" < @@ -342,7 +342,7 @@ $ hledger -f - balancesheet --output-format=csv "assets:a","$-10000.00" "total","$-10000.00" "Liabilities","" -"total" +"total","0" "Net:","$-10000.00" # ** 15. In compound reports like balancesheet, parent accounts might not have diff --git a/hledger/test/cashflow.test b/hledger/test/cashflow.test index 5bd81f942..f27977758 100644 --- a/hledger/test/cashflow.test +++ b/hledger/test/cashflow.test @@ -89,7 +89,7 @@ Cashflow Statement 2016-10 Cash flows || ------------++----- ------------++----- - || + || 0 >2 >= 0 diff --git a/hledger/test/cli/multiple-files.test b/hledger/test/cli/multiple-files.test index 06f49e862..6395ab3e5 100644 --- a/hledger/test/cli/multiple-files.test +++ b/hledger/test/cli/multiple-files.test @@ -10,7 +10,7 @@ Income Statement 2014-01-01..2014-01-02 Revenues || --------------------------++------------------------ --------------------------++------------------------ - || + || 0 ==========================++======================== Expenses || --------------------------++------------------------ diff --git a/hledger/test/incomestatement.test b/hledger/test/incomestatement.test index 978a28729..a9d6043ab 100644 --- a/hledger/test/incomestatement.test +++ b/hledger/test/incomestatement.test @@ -18,7 +18,7 @@ Income Statement 2016-01-01 Expenses || ----------++------------ ----------++------------ - || + || 0 ==========++============ Net: || -1 @@ -138,7 +138,7 @@ Income Statement 2015-10 Expenses || -------------------++------------ -------------------++------------ - || + || 0 ===================++============ Net: || $10,000.00 @@ -171,14 +171,14 @@ Income Statement 2016-10 Revenues || ----------++----- ----------++----- - || + || 0 ==========++===== Expenses || ----------++----- ----------++----- - || + || 0 ==========++===== - Net: || + Net: || 0 # ** 6. Multicolumn test # old (arithmetic sign):