diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index ad4846ab0..c1452c923 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -410,7 +410,7 @@ renderComponent opts (acctname, depth, total) (FormatField ljust min max field) Just m -> depth * m Nothing -> depth AccountField -> formatString ljust min max (T.unpack acctname) - TotalField -> fitStringMulti min max True False $ showMixedAmountWithoutPrice (color_ opts) total + TotalField -> fst $ showMixed showAmountWithoutPrice min max (color_ opts) total _ -> "" -- | Render one StringFormat component for a balance report item. @@ -425,9 +425,7 @@ renderComponent1 opts (acctname, depth, total) (FormatField ljust min max field) -- better to indent the account name here rather than use a DepthField component -- so that it complies with width spec. Uses a fixed indent step size. indented = ((replicate (depth*2) ' ')++) - TotalField -> fitStringMulti min max True False $ ((intercalate ", " . map strip . lines) (showamt total)) - where - showamt = showMixedAmountWithoutPrice (color_ opts) + TotalField -> fst $ showMixedOneLine showAmountWithoutPrice min max (color_ opts) total _ -> "" -- rendering multi-column balance reports diff --git a/tests/balance/format.test b/tests/balance/format.test index 6b7efc413..798363199 100644 --- a/tests/balance/format.test +++ b/tests/balance/format.test @@ -1,5 +1,5 @@ -hledger -f sample.journal balance --tree --format="%30(account) %-.20(total)" ->>> +$ hledger -f sample.journal balance --tree --format="%30(account) %-.20(total)" +> assets $-1 bank:saving $1 cash $-2 @@ -12,4 +12,23 @@ hledger -f sample.journal balance --tree --format="%30(account) %-.20(total)" liabilities:debts $1 ---------------------------------- 0 ->>>= 0 +>= 0 + +< +2020-09-01 Test + a -500 AAA + b + +# Test too-small maximum balance widths +$ hledger -f - balance -N --format="%7.7(total) %(account)" +> +1 mor.. a +500 AAA b +>= 0 + +# Check that maximum balance widths works with colour +$ hledger -f - balance -N --format="%8.8(total) %(account)" --color=yes +> +-500 AAA a + 500 AAA b +>= 0