lib: Sorting accounts by amount should also consider account name after amounts.

This commit is contained in:
Stephen Morgan 2020-12-14 17:41:19 +11:00 committed by Simon Michael
parent e5a236e9dc
commit 92645cca14
2 changed files with 6 additions and 5 deletions

View File

@ -203,8 +203,9 @@ sortAccountTreeByAmount :: NormalSign -> Account -> Account
sortAccountTreeByAmount normalsign = mapAccounts $ \a -> a{asubs=sortSubs $ asubs a}
where
sortSubs = case normalsign of
NormallyPositive -> sortOn (Down . normaliseMixedAmountSquashPricesForDisplay . aibalance)
NormallyNegative -> sortOn ( normaliseMixedAmountSquashPricesForDisplay . aibalance)
NormallyPositive -> sortOn (\a -> (Down $ amt a, aname a))
NormallyNegative -> sortOn (\a -> (amt a, aname a))
amt = normaliseMixedAmountSquashPricesForDisplay . aibalance
-- | Add extra info for this account derived from the Journal's
-- account directives, if any (comment, tags, declaration order..).

View File

@ -528,9 +528,9 @@ sortRows ropts j
-- Sort the report rows, representing a flat account list, by row total.
sortFlatMBRByAmount :: [MultiBalanceReportRow] -> [MultiBalanceReportRow]
sortFlatMBRByAmount = case normalbalance_ ropts of
Just NormallyNegative -> sortOn amt
_ -> sortOn (Down . amt)
sortFlatMBRByAmount = case fromMaybe NormallyPositive $ normalbalance_ ropts of
NormallyPositive -> sortOn (\r -> (Down $ amt r, prrFullName r))
NormallyNegative -> sortOn (\r -> (amt r, prrFullName r))
where amt = normaliseMixedAmountSquashPricesForDisplay . prrTotal
-- Sort the report rows by account declaration order then account name.