From dc840a9ef72c0ff51f1666a6eeb915ce73c8fccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoit=20Gr=C3=A9goire?= Date: Wed, 5 Feb 2003 00:01:16 +0000 Subject: [PATCH] =?UTF-8?q?2003-02-04=20=20Benoit=20Gr=EF=BF=BDgoire=20=20?= =?UTF-8?q??= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/import-export/import-backend.c: Add heuristic for duplicate matching by check number. * doc/README.OFX: Update git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7945 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 5 ++ doc/README.OFX | 14 ++-- src/import-export/import-backend.c | 110 +++++++++++++++++------------ 3 files changed, 78 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a540bf0b3..5487cd6d54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-02-04 Benoit Grégoire + + * src/import-export/import-backend.c: Add heuristic for duplicate matching by check number. + * doc/README.OFX: Update + 2003-02-04 Derek Atkins * src/import-export/qif-import/qif-file.scm: mark "splits" as negative diff --git a/doc/README.OFX b/doc/README.OFX index f35d1add31..f3dea9bab7 100644 --- a/doc/README.OFX +++ b/doc/README.OFX @@ -56,8 +56,8 @@ Implemented features (some of these are from the generic import module): -Commodity import and matching, for investment transactions. -Transaction duplicate detection, using the unique OFX transaction ID. Even if downloaded twice, transactions are only imported once. --Transaction duplicate detection, using amount, date, full or partial memo, - full or partial description. +-Transaction duplicate detection, using amount, date, check number, + full or partial memo, full or partial description. -"Destination" account matching, using exact string match on either memo or description. -Saves ALL transaction data currently supported by LibOFX. @@ -66,7 +66,9 @@ Implemented features (some of these are from the generic import module): -Files containing multiple statements are supported, and transactions can be matched at the same time. -4.The import process and transaction matching---------- + +4.The import process and transaction matching +---------- First, you must successfully download an OFX response file from your bank. @@ -228,9 +230,9 @@ version of GnuCash from. (4) When I import in OFX/HBCI, and change the destination account in the matcher, why doesn't other transaction with the same memo/description change? -The matcher already "learns" where transactions are assigned. The only problem -is thatcurrently, it only uses what it has learned on the next import. -Re-processing the list during the import process is a feature you can hopefor +The matcher already "learns" where transactions are assigned. The only problem +is thatcurrently, it only uses what it has learned on the next import. +Re-processing the list during the import process is a feature you can hopefor early in the 1.8 series. (5) Can GnuCash support QFX files (Quicken Financial eXchange?) diff --git a/src/import-export/import-backend.c b/src/import-export/import-backend.c index f43c79ddbd..7d41d87ab3 100644 --- a/src/import-export/import-backend.c +++ b/src/import-export/import-backend.c @@ -493,68 +493,88 @@ static void split_find_match (GNCImportTransInfo * trans_info, /*DEBUG("heuristics: probability - 10 (date)"); */ } - - /* Memo heuristics */ - if((strcmp(xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit (trans_info)), - xaccSplitGetMemo(split)) - ==0)) - { - /* An exact match of description gives a +2 */ - prob = prob+2; - /* DEBUG("heuristics: probability + 2 (memo)"); */ + /* Check number heuristics */ + if(strlen(xaccTransGetNum(gnc_import_TransInfo_get_trans (trans_info)))!=0) + { + if((strcmp(xaccTransGetNum + (gnc_import_TransInfo_get_trans (trans_info)), + xaccTransGetNum(xaccSplitGetParent(split))) + ==0)) + { + /*An exact match of the Check number gives a +5 */ + prob = prob+5; + /*DEBUG("heuristics: probability + 5 (Check number)");*/ + } } - else if((strncmp(xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit (trans_info)), - xaccSplitGetMemo(split), - strlen(xaccSplitGetMemo(split))/2) - ==0)) + + /* Memo heuristics */ + if(strlen(xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit (trans_info)))!=0) { - /* Very primitive fuzzy match worth +1. This matches the - first 50% of the strings to skip annoying transaction - number some banks seem to include in the memo but someone - should write something more sophisticated */ - prob = prob+1; - /*DEBUG("heuristics: probability + 1 (memo)"); */ + if((strcmp(xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit (trans_info)), + xaccSplitGetMemo(split)) + ==0)) + { + /* An exact match of description gives a +2 */ + prob = prob+2; + /* DEBUG("heuristics: probability + 2 (memo)"); */ + } + else if((strncmp(xaccSplitGetMemo(gnc_import_TransInfo_get_fsplit (trans_info)), + xaccSplitGetMemo(split), + strlen(xaccSplitGetMemo(split))/2) + ==0)) + { + /* Very primitive fuzzy match worth +1. This matches the + first 50% of the strings to skip annoying transaction + number some banks seem to include in the memo but someone + should write something more sophisticated */ + prob = prob+1; + /*DEBUG("heuristics: probability + 1 (memo)"); */ + } } /* Description heuristics */ - if((strcmp(xaccTransGetDescription - (gnc_import_TransInfo_get_trans (trans_info)), - xaccTransGetDescription(xaccSplitGetParent(split))) - ==0)) - { - /*An exact match of Description gives a +2 */ - prob = prob+2; - /*DEBUG("heuristics: probability + 2 (description)");*/ - } - else if((strncmp(xaccTransGetDescription - (gnc_import_TransInfo_get_trans (trans_info)), - xaccTransGetDescription(xaccSplitGetParent(split)), - strlen(xaccTransGetDescription - (gnc_import_TransInfo_get_trans (trans_info)))/2) - ==0)) + if(strlen(xaccTransGetDescription(gnc_import_TransInfo_get_trans (trans_info)))!=0) { - /* Very primitive fuzzy match worth +1. This matches the - first 50% of the strings to skip annoying transaction - number some banks seem to include in the memo but someone - should write something more sophisticated */ - prob = prob+1; - /*DEBUG("heuristics: probability + 1 (description)"); */ + if((strcmp(xaccTransGetDescription + (gnc_import_TransInfo_get_trans (trans_info)), + xaccTransGetDescription(xaccSplitGetParent(split))) + ==0)) + { + /*An exact match of Description gives a +2 */ + prob = prob+2; + /*DEBUG("heuristics: probability + 2 (description)");*/ + } + else if((strncmp(xaccTransGetDescription + (gnc_import_TransInfo_get_trans (trans_info)), + xaccTransGetDescription(xaccSplitGetParent(split)), + strlen(xaccTransGetDescription + (gnc_import_TransInfo_get_trans (trans_info)))/2) + ==0)) + { + /* Very primitive fuzzy match worth +1. This matches the + first 50% of the strings to skip annoying transaction + number some banks seem to include in the memo but someone + should write something more sophisticated */ + prob = prob+1; + /*DEBUG("heuristics: probability + 1 (description)"); */ + } } + /*Online id punishment*/ if ((gnc_import_get_trans_online_id(xaccSplitGetParent(split))!=NULL) && (strlen(gnc_import_get_trans_online_id(xaccSplitGetParent(split)))>0)) { /* If the pref is to show match even with online ID's, - puninsh the transaction with online if */ + puninsh the transaction with online id */ prob = prob-3; } - + /* Is the probability high enough? Otherwise do nothing and return. */ if(prob < display_threshold) { return; } - + /* The probability is high enough, so allocate an object here. Allocating it only when it's actually being used is probably quite some performance gain. */ @@ -563,8 +583,8 @@ static void split_find_match (GNCImportTransInfo * trans_info, match_info->probability = prob; match_info->split = split; match_info->trans = xaccSplitGetParent(split); - - + + /* Append that to the list. */ trans_info->match_list = g_list_append(trans_info->match_list,