From 7aa201168abf66601b32aaa6181110b1b6496da2 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Fri, 22 Nov 2002 00:29:40 +0000 Subject: [PATCH] Improved date heuristics (punishment if dates are very very far apart). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7522 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/import-export/Transaction-matcher.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/import-export/Transaction-matcher.c b/src/import-export/Transaction-matcher.c index 98d0d11700..a92fa695bf 100644 --- a/src/import-export/Transaction-matcher.c +++ b/src/import-export/Transaction-matcher.c @@ -148,8 +148,8 @@ struct _matchinfo \********************************************************************/ static short module = MOD_IMPORT; -static const double MATCH_ATM_FEE_TRESHOLD=3.00; -static const int MATCH_DATE_TRESHOLD=4; /*within 4 days*/ +static const double MATCH_ATM_FEE_THRESHOLD=3.00; +static const int MATCH_DATE_THRESHOLD=4; /*within 4 days*/ static const int SHOW_TRANSACTIONS_WITH_UNIQUE_ID = FALSE; static const int SHOW_NUMERIC_SCORE = FALSE; @@ -823,7 +823,7 @@ static void split_find_match( struct _transmatcherdialog * matcher, match_info->probability=match_info->probability+3; DEBUG("heuristics: probability + 3 (amount)"); } - else if(fabs(downloaded_split_amount-match_split_amount)<=MATCH_ATM_FEE_TRESHOLD) + else if(fabs(downloaded_split_amount-match_split_amount)<=MATCH_ATM_FEE_THRESHOLD) { /* ATM fees are sometimes added directly in the transaction. So you withdraw 100$ and get charged 101,25$ in the same transaction */ @@ -851,11 +851,19 @@ static void split_find_match( struct _transmatcherdialog * matcher, match_info->probability=match_info->probability+2; DEBUG("heuristics: probability + 2 (date)"); } - else if (datediff_day <= MATCH_DATE_TRESHOLD) + else if (datediff_day <= MATCH_DATE_THRESHOLD) { match_info->probability=match_info->probability+1; DEBUG("heuristics: probability + 1 (date)"); } + else if (datediff_day > 4*MATCH_DATE_THRESHOLD) + { + /* ok, the factor '4' here is kind of arbitrary. Anyway, + there needs to be extra punishment if this transaction + lies awfully far away from this one. */ + match_info->probability=match_info->probability-1; + DEBUG("heuristics: probability - 1 (date)"); + } /* Memo heuristics */