lib: When calculating elisions, don't skip over some amounts.

This commit is contained in:
Stephen Morgan 2020-11-04 13:20:46 +11:00
parent 6d7bd9e475
commit 3abc9f5985
2 changed files with 38 additions and 2 deletions

View File

@ -714,8 +714,9 @@ showMixedOneLineUnnormalised showamt mmin mmax c (Mixed as) =
addElide xs = maybeAppend (snd $ last xs) $ map fst xs
-- Return the elements of the display list which fit within the maximum width
-- (including their elision strings)
takeFitting m = filter (\(_,e) -> maybe True ((m>=) . adTotal) e)
. takeWhile (\(amt,_) -> adTotal amt <= m)
takeFitting m = dropWhileRev (\(a,e) -> m < adTotal (fromMaybe a e))
dropWhileRev p = foldr (\x xs -> if null xs && p x then [] else x:xs) []
-- Add the elision strings (if any) to each amount
withElided = zipWith (\num amt -> (amt, elisionDisplay Nothing sepwidth num amt)) [n-1,n-2..0]

View File

@ -26,3 +26,38 @@ Balance changes in 2020:
a || 1.00A, 1.00B, 1.00C, 1.00D, 1.00E, 1.00F
---++------------------------------------------
|| 1.00A, 1.00B, 1.00C, 1.00D, 1.00E, 1.00F
<
2020-02-22
26018c6e:ced6cffd:c3c182f1:7b433efb $ 9.41
ea50865f:3bfb86b7:bf72f75a:a7cad1ac $ -10.00
ea50865f:325566ed:216fec7e:7b433efb $ 0.59
2020-02-27
26018c6e:ced6cffd:c3c182f1:7b433efb £ -19.16
ea50865f:325566ed:216fec7e:7b433efb £ 0.91
ea50865f:325566ed:47134948 £ 18.25
2020-04-12
26018c6e:ced6cffd:c3c182f1:7b433efb € 9.21
ea50865f:3bfb86b7:bf72f75a:a7cad1ac € -10.00
ea50865f:325566ed:216fec7e:7b433efb € 0.79
2020-05-16
26018c6e:ced6cffd:c3c182f1:7b433efb C$ 24.56
ea50865f:3bfb86b7:bf72f75a:a7cad1ac C$ -26.00
ea50865f:325566ed:216fec7e:7b433efb C$ 1.44
# 3. 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
>=0