From 118bc85726a3f7d930ad47fe4ec631c54dacadb8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 May 2017 10:21:47 -0700 Subject: [PATCH] bs/is: fix "Ratio has zero denominator" error (take 2) (#535) --- hledger/Hledger/Cli/Balance.hs | 4 ++-- hledger/Hledger/Cli/BalanceView.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hledger/Hledger/Cli/Balance.hs b/hledger/Hledger/Cli/Balance.hs index bcc69ea6a..dfb9d99a5 100644 --- a/hledger/Hledger/Cli/Balance.hs +++ b/hledger/Hledger/Cli/Balance.hs @@ -531,8 +531,8 @@ balanceReportAsTable opts (MultiBalanceReport (colspans, items, (coltotals,tot,a addtotalrow | no_total_ opts = id | otherwise = (+----+ (row "" $ coltotals - ++ (if row_total_ opts then [tot] else []) - ++ (if average_ opts then [avg] else []) + ++ (if row_total_ opts && not (null coltotals) then [tot] else []) + ++ (if average_ opts && not (null coltotals) then [avg] else []) )) -- | Figure out the overall date span of a multicolumn balance report. diff --git a/hledger/Hledger/Cli/BalanceView.hs b/hledger/Hledger/Cli/BalanceView.hs index 860968b63..283da0741 100644 --- a/hledger/Hledger/Cli/BalanceView.hs +++ b/hledger/Hledger/Cli/BalanceView.hs @@ -148,8 +148,8 @@ balanceviewReport BalanceView{..} CliOpts{command_=cmd, reportopts_=ropts, rawop mergedTabl +====+ row "Total" - (sumAmts ++ (if row_total_ ropts' then [totsum] else []) - ++ (if average_ ropts' then [totavg] else []) + (sumAmts ++ (if row_total_ ropts' && not (null sumAmts) then [totsum] else []) + ++ (if average_ ropts' && not (null sumAmts) then [totavg] else []) ) putStrLn title putStrLn $ renderBalanceReportTable ropts totTabl