From de2776c99689d94e62622923776cf46f1271fe6e Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Fri, 12 Nov 2021 21:41:05 +1100 Subject: [PATCH] imp!: balance: Stop eliding long amounts. (#1739) This feature has caused a lot of confusion, and we now have better ways of making sure columns don't get too wide. --- hledger/Hledger/Cli/Commands/Balance.hs | 7 ++--- hledger/Hledger/Cli/CompoundBalanceCommand.hs | 2 +- hledger/test/balance/multicommodity.test | 30 +++++++------------ 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 35c2a9d4c..aed98cbfb 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -312,7 +312,7 @@ balancemode = hledgerCommandMode ,flagNone ["related","r"] (setboolopt "related") "show postings' siblings instead" ,flagNone ["row-total","T"] (setboolopt "row-total") "show a row total column (in multicolumn reports)" ,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row" - ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode); don't show only 2 commodities per amount" + ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode)" ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format (in simple reports)" ,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name (in flat mode). With multiple columns, sorts by the row total, or by row average if that is displayed." ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total" @@ -731,10 +731,7 @@ multiBalanceRowAsTableText opts = multiBalanceRowAsWbs (balanceOpts True opts) o -- | Amount display options to use for balance reports balanceOpts :: Bool -> ReportOpts -> AmountDisplayOpts -balanceOpts isTable ReportOpts{..} = oneLine - { displayColour = isTable && color_ - , displayMaxWidth = if isTable && not no_elide_ then Just 32 else Nothing - } +balanceOpts isTable ReportOpts{..} = oneLine {displayColour = isTable && color_} tests_Balance = testGroup "Balance" [ diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 8b231a877..d6517d257 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -80,7 +80,7 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = ,flagNone ["average","A"] (setboolopt "average") "show a row average column (in multicolumn reports)" ,flagNone ["row-total","T"] (setboolopt "row-total") "show a row total column (in multicolumn reports)" ,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row" - ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode); don't show only 2 commodities per amount" + ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode)" ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format (in simple reports)" ,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name" ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total" diff --git a/hledger/test/balance/multicommodity.test b/hledger/test/balance/multicommodity.test index 0432780e0..5974d31cc 100644 --- a/hledger/test/balance/multicommodity.test +++ b/hledger/test/balance/multicommodity.test @@ -1,4 +1,4 @@ -# 1. In tabular balance reports, cap the maximum width and elide if sufficiently large +# 1. In tabular balance reports, display on a single line by default < 2020-01-01 (a) 1.00A @@ -8,16 +8,6 @@ (a) 1.00E (a) 1.00F -$ hledger -f- bal -Y -Balance changes in 2020: - - || 2020 -===++=============================== - a || 1.00A, 1.00B, 1.00C, 3 more.. ----++------------------------------- - || 1.00A, 1.00B, 1.00C, 3 more.. - -# 2. Unless --no-elide is used. $ hledger -f- bal -Y --no-elide Balance changes in 2020: @@ -48,16 +38,16 @@ Balance changes in 2020: ea50865f:3bfb86b7:bf72f75a:a7cad1ac C$ -26.00 ea50865f:325566ed:216fec7e:7b433efb C$ 1.44 -# 3. Make sure all amounts up to the largest fit +# 2. Make sure all amounts up to the largest fit $ hledger -f- bal -Y --color=yes Balance changes in 2020: - || 2020 -=====================================++================================= - 26018c6e:ced6cffd:c3c182f1:7b433efb || $ 9.41, C$ 24.56, 2 more.. - ea50865f:325566ed:216fec7e:7b433efb || $ 0.59, C$ 1.44, £ 0.91, € 0.79 - ea50865f:325566ed:47134948 || £ 18.25 - ea50865f:3bfb86b7:bf72f75a:a7cad1ac || $ -10.00, C$ -26.00, € -10.00 --------------------------------------++--------------------------------- - || 0 + || 2020 +=====================================++==================================== + 26018c6e:ced6cffd:c3c182f1:7b433efb || $ 9.41, C$ 24.56, £ -19.16, € 9.21 + ea50865f:325566ed:216fec7e:7b433efb || $ 0.59, C$ 1.44, £ 0.91, € 0.79 + ea50865f:325566ed:47134948 || £ 18.25 + ea50865f:3bfb86b7:bf72f75a:a7cad1ac || $ -10.00, C$ -26.00, € -10.00 +-------------------------------------++------------------------------------ + || 0 >=0