From f7f6d5f8e590416c17bb8ac34353439ce01a0f68 Mon Sep 17 00:00:00 2001 From: Justin Le Date: Sun, 26 Mar 2017 01:40:34 -0700 Subject: [PATCH] average total for multicolumn bs/is/cf --- hledger/Hledger/Cli/BalanceView.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hledger/Hledger/Cli/BalanceView.hs b/hledger/Hledger/Cli/BalanceView.hs index c45e77e22..705aa2a6a 100644 --- a/hledger/Hledger/Cli/BalanceView.hs +++ b/hledger/Hledger/Cli/BalanceView.hs @@ -121,15 +121,21 @@ balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = d sumAmts = case amts of a1:as -> foldl' (zipWith (+)) a1 as [] -> [] + totavg = totsum `divideMixedAmount` + fromIntegral (length sumAmts) mergedTabl = case tabls of t1:ts -> foldl' merging t1 ts [] -> T.empty - totTabl | no_total_ ropts' = mergedTabl - | otherwise = - mergedTabl - +====+ - row "Total" - (sumAmts ++ if row_total_ ropts' then [totsum] else []) + totTabl + | no_total_ ropts' || length bvqueries == 1 = + mergedTabl + | otherwise = + mergedTabl + +====+ + row "Total" + (sumAmts ++ if row_total_ ropts' then [totsum] else [] + ++ if average_ ropts' then [totavg] else [] + ) putStrLn bvtitle putStrLn $ renderBalanceReportTable totTabl where