resolve conflicts/explain (Add: filter relevant transactions by account)
Previously, we supported "hledger add [DESCRIPTION]". A DESCRIPTION just pre-filled the description field and bypassed that prompt, after which existing transactions with similar descriptions were offered as defaults/reminders. Now, we support "hledger add [ACCOUNTPATTERN]" instead. After the description prompt, existing transactions with similar descriptions *and* which match ACCOUNTPATTERN are offered as defaults. This can be helpful eg with a multi-person ledger, to match only your own transactions.
This commit is contained in:
parent
20b243a3a3
commit
8310eaa6ff
@ -178,13 +178,13 @@ compareLedgerDescriptions s t = compareStrings s' t'
|
||||
t' = simplify t
|
||||
simplify = filter (not . (`elem` "0123456789"))
|
||||
|
||||
transactionsSimilarTo :: Ledger -> String -> [(Double,LedgerTransaction)]
|
||||
transactionsSimilarTo l s =
|
||||
transactionsSimilarTo :: Ledger -> [String] -> String -> [(Double,Transaction)]
|
||||
transactionsSimilarTo l apats s =
|
||||
sortBy compareRelevanceAndRecency
|
||||
$ filter ((> threshold).fst)
|
||||
[(compareLedgerDescriptions s $ tdescription t, t) | t <- ts]
|
||||
where
|
||||
compareRelevanceAndRecency (n1,t1) (n2,t2) = compare (n2,ltdate t2) (n1,ltdate t1)
|
||||
ts = ledger_txns $ rawledger l
|
||||
compareRelevanceAndRecency (n1,t1) (n2,t2) = compare (n2,tdate t2) (n1,tdate t1)
|
||||
ts = jtxns $ filterJournalTransactionsByAccount apats $ journal l
|
||||
threshold = 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user