ui, web: show fewer other accounts in acct register

To reduce noise in the "other accounts" field of hledger-ui's and
hledger-web's account register: if there are both real and virtual
postings to other accounts, show only the accounts posted to by real
postings.

Use case: in many transactions I have extra balanced-virtual postings
which adjust budget envelopes (subaccounts of checking). These clutter
up the register's other accounts field making it useless. Excluding them
(when there are also real postings) makes it more useful for me and
probably others.
This commit is contained in:
Simon Michael 2015-08-28 11:58:57 -07:00
parent 61f994e162
commit 8673332c8e

View File

@ -201,8 +201,14 @@ accountTransactionsReportItems query thisacctquery bal signfn (torig:ts) =
-- (froms,tos) = partition (fromMaybe False . isNegativeMixedAmount . pamount) ps
-- | Generate a simplified summary of some postings' accounts.
-- To reduce noise, if there are both real and virtual postings, show only the real ones.
summarisePostingAccounts :: [Posting] -> String
summarisePostingAccounts = intercalate ", " . map accountSummarisedName . nub . map paccount
summarisePostingAccounts ps =
(intercalate ", " . map accountSummarisedName . nub . map paccount) displayps
where
realps = filter isReal ps
displayps | null realps = ps
| otherwise = realps
filterTransactionPostings :: Query -> Transaction -> Transaction
filterTransactionPostings m t@Transaction{tpostings=ps} = t{tpostings=filter (m `matchesPosting`) ps}