mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2003-02-10 Benoit Gr�goire <bock@step.polymtl.ca>
* src/import-export/import-backend.c,h: * src/import-export/import-main-matcher.c: Apply most of cmorgan's patch for iterative destination account matching. Optionally restricting to the transactions after the one being edited still need's to be implemented. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7969 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8811d1c8c2
commit
d14b514571
@ -1,3 +1,8 @@
|
|||||||
|
2003-02-10 Benoit Grégoire <bock@step.polymtl.ca>
|
||||||
|
|
||||||
|
* src/import-export/import-backend.c,h:
|
||||||
|
* src/import-export/import-main-matcher.c: Apply most of cmorgan's patch for iterative destination account matching. Optionally restricting to the transactions after the one being edited still need's to be implemented.
|
||||||
|
|
||||||
2003-02-10 Derek Atkins <derek@ihtfp.com>
|
2003-02-10 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
* po/POTFILES.in: fox for the search-param.c move
|
* po/POTFILES.in: fox for the search-param.c move
|
||||||
|
@ -63,6 +63,16 @@ static const int MATCH_DATE_NOT_THRESHOLD = 21;
|
|||||||
performance of the matcher. */
|
performance of the matcher. */
|
||||||
static const int SHOW_TRANSACTIONS_WITH_UNIQUE_ID = TRUE; /* DISABLE once account transfer bug is fixed! */
|
static const int SHOW_TRANSACTIONS_WITH_UNIQUE_ID = TRUE; /* DISABLE once account transfer bug is fixed! */
|
||||||
|
|
||||||
|
/********************************************************************\
|
||||||
|
* Forward declared prototypes *
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
matchmap_store_destination (GncImportMatchMap *matchmap,
|
||||||
|
GNCImportTransInfo *trans_info,
|
||||||
|
gboolean use_match);
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* Structures passed between the functions *
|
* Structures passed between the functions *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
@ -186,6 +196,9 @@ void gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info,
|
|||||||
g_assert (info);
|
g_assert (info);
|
||||||
info->dest_acc = acc;
|
info->dest_acc = acc;
|
||||||
info->dest_acc_selected_manually = selected_manually;
|
info->dest_acc_selected_manually = selected_manually;
|
||||||
|
|
||||||
|
/* Store the mapping to the other account in the MatchMap. */
|
||||||
|
matchmap_store_destination (NULL, info, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -326,6 +339,9 @@ GdkPixmap* gen_probability_pixmap(gint score_original, GNCImportSettings *settin
|
|||||||
/*-************************************************************************
|
/*-************************************************************************
|
||||||
* MatchMap- related functions (storing and retrieving)
|
* MatchMap- related functions (storing and retrieving)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* searches using the GNCImportTransInfo through all existing transactions */
|
||||||
|
/* if there is an exact match of the description and memo */
|
||||||
static Account *
|
static Account *
|
||||||
matchmap_find_destination (GncImportMatchMap *matchmap,
|
matchmap_find_destination (GncImportMatchMap *matchmap,
|
||||||
GNCImportTransInfo *info)
|
GNCImportTransInfo *info)
|
||||||
@ -357,7 +373,7 @@ matchmap_find_destination (GncImportMatchMap *matchmap,
|
|||||||
'use_match' is true, the destination account of the selected
|
'use_match' is true, the destination account of the selected
|
||||||
matching/duplicate transaction is used; otherwise, the stored
|
matching/duplicate transaction is used; otherwise, the stored
|
||||||
destination_acc pointer is used. */
|
destination_acc pointer is used. */
|
||||||
static void
|
static void
|
||||||
matchmap_store_destination (GncImportMatchMap *matchmap,
|
matchmap_store_destination (GncImportMatchMap *matchmap,
|
||||||
GNCImportTransInfo *trans_info,
|
GNCImportTransInfo *trans_info,
|
||||||
gboolean use_match)
|
gboolean use_match)
|
||||||
@ -514,7 +530,7 @@ static void split_find_match (GNCImportTransInfo * trans_info,
|
|||||||
xaccSplitGetMemo(split))
|
xaccSplitGetMemo(split))
|
||||||
==0))
|
==0))
|
||||||
{
|
{
|
||||||
/* An exact match of description gives a +2 */
|
/* An exact match of memo gives a +2 */
|
||||||
prob = prob+2;
|
prob = prob+2;
|
||||||
/* DEBUG("heuristics: probability + 2 (memo)"); */
|
/* DEBUG("heuristics: probability + 2 (memo)"); */
|
||||||
}
|
}
|
||||||
@ -671,9 +687,6 @@ gnc_import_process_trans_clist (GtkCList *clist,
|
|||||||
xaccTransGetCurrency
|
xaccTransGetCurrency
|
||||||
(gnc_import_TransInfo_get_trans (trans_info)));
|
(gnc_import_TransInfo_get_trans (trans_info)));
|
||||||
xaccSplitSetMemo (split, _("Auto-Balance split"));
|
xaccSplitSetMemo (split, _("Auto-Balance split"));
|
||||||
|
|
||||||
/* Store the mapping to the other account in the MatchMap. */
|
|
||||||
matchmap_store_destination (matchmap, trans_info, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xaccSplitSetReconcile(gnc_import_TransInfo_get_fsplit (trans_info), CREC);
|
xaccSplitSetReconcile(gnc_import_TransInfo_get_fsplit (trans_info), CREC);
|
||||||
@ -896,4 +909,41 @@ gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info,
|
|||||||
trans_info->previous_action=trans_info->action;
|
trans_info->previous_action=trans_info->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Try to automatch a transaction to a destination account if the */
|
||||||
|
/* transaction hasn't already been manually assigned to another account */
|
||||||
|
gboolean
|
||||||
|
gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info,
|
||||||
|
GncImportMatchMap *matchmap)
|
||||||
|
{
|
||||||
|
Transaction *transaction;
|
||||||
|
g_assert(transaction_info);
|
||||||
|
|
||||||
|
Account *orig_destacc = gnc_import_TransInfo_get_destacc(transaction_info);
|
||||||
|
Account *new_destacc = NULL;
|
||||||
|
|
||||||
|
/* if we haven't manually selected a destination account for this transaction */
|
||||||
|
if(gnc_import_TransInfo_get_destacc_selected_manually(transaction_info) == FALSE)
|
||||||
|
{
|
||||||
|
/* Try to find a previous selected destination account string match for the ADD action */
|
||||||
|
new_destacc = matchmap_find_destination(matchmap, transaction_info);
|
||||||
|
gnc_import_TransInfo_set_destacc(transaction_info, new_destacc, FALSE);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
new_destacc = orig_destacc;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction = gnc_import_TransInfo_get_trans(transaction_info);
|
||||||
|
|
||||||
|
/* account has changed */
|
||||||
|
if(new_destacc != orig_destacc)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
} else /* account is the same */
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -216,6 +216,11 @@ gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info,
|
|||||||
Account *acc,
|
Account *acc,
|
||||||
gboolean selected_manually);
|
gboolean selected_manually);
|
||||||
|
|
||||||
|
/** Try to automatch a given transaction to a destination account */
|
||||||
|
gboolean
|
||||||
|
gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info,
|
||||||
|
GncImportMatchMap *matchmap);
|
||||||
|
|
||||||
/** Returns if the currently selected destination account for auto-matching was selected by the user. */
|
/** Returns if the currently selected destination account for auto-matching was selected by the user. */
|
||||||
gboolean
|
gboolean
|
||||||
gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info);
|
gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info);
|
||||||
|
@ -68,6 +68,11 @@ struct _main_matcher_info
|
|||||||
#define DOWNLOADED_CLIST_ACTION_INFO 8
|
#define DOWNLOADED_CLIST_ACTION_INFO 8
|
||||||
static short module = MOD_IMPORT;
|
static short module = MOD_IMPORT;
|
||||||
|
|
||||||
|
/* Local prototypes */
|
||||||
|
static void automatch_clist_transactions(GNCImportMainMatcher *info, GtkCList *clist);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static char * fleche_xpm[] = {
|
static char * fleche_xpm[] = {
|
||||||
"17 22 41 1",
|
"17 22 41 1",
|
||||||
" c None",
|
" c None",
|
||||||
@ -265,6 +270,9 @@ run_account_picker_dialog (GNCImportMainMatcher *info,
|
|||||||
gnc_import_TransInfo_set_destacc (trans_info,
|
gnc_import_TransInfo_set_destacc (trans_info,
|
||||||
new_acc,
|
new_acc,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
|
/* Iterate through the transactions in a given clist to auto match them */
|
||||||
|
automatch_clist_transactions(info, (GtkCList*)info->clist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,4 +831,22 @@ void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans)
|
|||||||
return;
|
return;
|
||||||
}/* end gnc_import_add_trans() */
|
}/* end gnc_import_add_trans() */
|
||||||
|
|
||||||
|
/* Iterate through the rows of the clist and try to automatch each of them */
|
||||||
|
static void automatch_clist_transactions(GNCImportMainMatcher *info, GtkCList *clist)
|
||||||
|
{
|
||||||
|
int row;
|
||||||
|
GNCImportTransInfo *trans_info;
|
||||||
|
|
||||||
|
for(row = 0; row < clist->rows; row++)
|
||||||
|
{
|
||||||
|
trans_info = gtk_clist_get_row_data(clist, row);
|
||||||
|
|
||||||
|
/* returns TRUE if we changed this row, so update it */
|
||||||
|
if(gnc_import_TransInfo_refresh_destacc(trans_info, NULL))
|
||||||
|
{
|
||||||
|
refresh_clist_row(info, row, trans_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
Loading…
Reference in New Issue
Block a user