From 95ced2da80c020378efe757df18bb3226358c119 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 27 Dec 2014 16:44:03 -0800 Subject: [PATCH] balance: fix partially-visible totals row With --no-total in a periodic (non-cumulative, non-historical) balance report, hide the totals row completely, as in the other modes. --- hledger/Hledger/Cli/Balance.hs | 27 ++++++++++++--------------- tests/balance/intervals.test | 2 -- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/hledger/Hledger/Cli/Balance.hs b/hledger/Hledger/Cli/Balance.hs index 1bae22d46..6128a6f9a 100644 --- a/hledger/Hledger/Cli/Balance.hs +++ b/hledger/Hledger/Cli/Balance.hs @@ -422,16 +422,12 @@ periodBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, (coltotal unlines $ ([printf "Balance changes in %s:" (showDateSpan $ multiBalanceReportSpan r)] ++) $ trimborder $ lines $ - render - id - (" "++) - showMixedAmountOneLineWithoutPrice - $ Table - (T.Group NoLine $ map (Header . padright acctswidth) accts) - (T.Group NoLine $ map Header colheadings) - (map rowvals items') - +----+ - totalrow + render id (" "++) showMixedAmountOneLineWithoutPrice $ + addtotalrow $ + Table + (T.Group NoLine $ map (Header . padright acctswidth) accts) + (T.Group NoLine $ map Header colheadings) + (map rowvals items') where trimborder = ("":) . (++[""]) . drop 1 . init . map (drop 1 . init) colheadings = map showDateSpan colspans @@ -447,11 +443,12 @@ periodBalanceReportAsText opts r@(MultiBalanceReport (colspans, items, (coltotal rowvals (_,as,rowtot,rowavg) = as ++ (if row_total_ opts then [rowtot] else []) ++ (if average_ opts then [rowavg] else []) - totalrow | no_total_ opts = row "" [] - | otherwise = row "" $ - coltotals - ++ (if row_total_ opts then [tot] else []) - ++ (if average_ opts then [avg] else []) + addtotalrow | no_total_ opts = id + | otherwise = (+----+ (row "" $ + coltotals + ++ (if row_total_ opts then [tot] else []) + ++ (if average_ opts then [avg] else []) + )) -- | Render a multi-column cumulative balance report as plain text suitable for console output. cumulativeBalanceReportAsText :: ReportOpts -> MultiBalanceReport -> String diff --git a/tests/balance/intervals.test b/tests/balance/intervals.test index 9c9427702..e6058d587 100644 --- a/tests/balance/intervals.test +++ b/tests/balance/intervals.test @@ -21,8 +21,6 @@ Balance changes in 2013q1: assets || 0 1 0 assets:cash || 0 1 0 assets:checking || 0 0 1 ------------------++---------------------------- - || >>>=0