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 |           t' = simplify t | ||||||
|           simplify = filter (not . (`elem` "0123456789")) |           simplify = filter (not . (`elem` "0123456789")) | ||||||
| 
 | 
 | ||||||
| transactionsSimilarTo :: Ledger -> String -> [(Double,LedgerTransaction)] | transactionsSimilarTo :: Ledger -> [String] -> String -> [(Double,Transaction)] | ||||||
| transactionsSimilarTo l s = | transactionsSimilarTo l apats s = | ||||||
|     sortBy compareRelevanceAndRecency |     sortBy compareRelevanceAndRecency | ||||||
|                $ filter ((> threshold).fst) |                $ filter ((> threshold).fst) | ||||||
|                [(compareLedgerDescriptions s $ tdescription t, t) | t <- ts] |                [(compareLedgerDescriptions s $ tdescription t, t) | t <- ts] | ||||||
|     where |     where | ||||||
|       compareRelevanceAndRecency (n1,t1) (n2,t2) = compare (n2,ltdate t2) (n1,ltdate t1) |       compareRelevanceAndRecency (n1,t1) (n2,t2) = compare (n2,tdate t2) (n1,tdate t1) | ||||||
|       ts = ledger_txns $ rawledger l |       ts = jtxns $ filterJournalTransactionsByAccount apats $ journal l | ||||||
|       threshold = 0 |       threshold = 0 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user