From 05dfc2119f8dbd69f27d6bf15c3a7ffbd1027459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoit=20Gr=C3=A9goire?= Date: Tue, 10 Dec 2002 08:54:39 +0000 Subject: [PATCH] =?UTF-8?q?2002-12-10=20=20Benoit=20Gr=EF=BF=BDgoire=20=20?= =?UTF-8?q?=20=09*=20src/import-export/*:=20Add=20us?= =?UTF-8?q?er=20pref=20to=20allow=20HBCI=20users=20to=20select=20if=20they?= =?UTF-8?q?=20want=20Christian's=20matcher=20or=20mine.=20=20Update=20OFX?= =?UTF-8?q?=20readme.=20=20Update=20column=20width=20in=20account-picker.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7669 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 6 +++ src/import-export/generic-import.glade | 3 +- src/import-export/generic-import.scm | 10 ++-- src/import-export/hbci/gnc-hbci-gettrans.c | 61 +++++++++++++++++----- src/import-export/hbci/hbci.scm | 6 +++ src/import-export/import-account-matcher.c | 9 +++- src/import-export/import-main-matcher.c | 32 ++++++------ src/import-export/import-main-matcher.h | 24 +++------ src/import-export/import-settings.c | 14 ++--- src/import-export/ofx/README | 19 ++++--- src/import-export/ofx/gnc-ofx-import.c | 2 +- 11 files changed, 116 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbd9acd91b..db1310a114 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-12-10 Benoit Grégoire + * src/import-export/*: Add user pref to allow HBCI users + to select if they want Christian's matcher or mine. + Update OFX readme. + Update column width in account-picker. + 2002-12-09 Christian Stimming * po/nl.po: Updated translation by Hendrik-Jan Heins diff --git a/src/import-export/generic-import.glade b/src/import-export/generic-import.glade index 82fbf977e2..9f94b2c874 100644 --- a/src/import-export/generic-import.glade +++ b/src/import-export/generic-import.glade @@ -499,12 +499,13 @@ -Select "R" to Reconcile a matching transaction -Select neither to Skip (The transaction won't be imported at all) -"Select Import Action" allows you to change the matching transaction to reconcile, or the destination account of the auto-balance split (if required). - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_FILL False 0.5 0.5 0 0 + matcher_ok 0 False diff --git a/src/import-export/generic-import.scm b/src/import-export/generic-import.scm index 9a2254893f..30f8d1232a 100644 --- a/src/import-export/generic-import.scm +++ b/src/import-export/generic-import.scm @@ -6,11 +6,11 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Register Preferences -(gnc:register-configuration-option - (gnc:make-simple-boolean-option - (N_ "Transaction Matcher") (N_ "Enable SKIP transaction action") - "b" (N_ "Enable the SKIP action in the transaction matcher. If enabled, a transaction whose best match's score is in the yellow zone (above the Auto-ADD threshold but below the Auto-CLEAR threshold) will be SKIPed by default.") - #t)) +;(gnc:register-configuration-option +; (gnc:make-simple-boolean-option +; (N_ "Transaction Matcher") (N_ "Enable SKIP transaction action") +; "b" (N_ "Enable the SKIP action in the transaction matcher. If enabled, a transaction whose best match's score is in the yellow zone (above the Auto-ADD threshold but below the Auto-CLEAR threshold) will be SKIPed by default.") +; #t)) (gnc:register-configuration-option (gnc:make-simple-boolean-option diff --git a/src/import-export/hbci/gnc-hbci-gettrans.c b/src/import-export/hbci/gnc-hbci-gettrans.c index 5c5e50eb48..7b5b1e9e65 100644 --- a/src/import-export/hbci/gnc-hbci-gettrans.c +++ b/src/import-export/hbci/gnc-hbci-gettrans.c @@ -31,7 +31,10 @@ #include "date.h" #include "Transaction.h" #include "gnc-engine-util.h" + #include "gnc-gen-transaction.h" +#include "import-main-matcher.h" +#include "global-options.h" #include "hbci-interaction.h" #include "gnc-hbci-utils.h" @@ -41,12 +44,16 @@ /* static short module = MOD_IMPORT; */ +static const gboolean DEFAULT_USE_GENERIC_MATCHER = FALSE; + static void *trans_list_cb (const HBCI_Transaction *trans, void *user_data); struct trans_list_data { Account *gnc_acc; GNCGenTransaction *importer; + GNCImportMainMatcher *importer_generic; + gboolean use_generic_matcher; }; @@ -183,21 +190,43 @@ gnc_hbci_gettrans (GtkWidget *parent, Account *gnc_acc) if (list_HBCI_Transaction_size(trans_list) > 0) { struct trans_list_data data; - GNCGenTransaction *importer_gui; - - importer_gui = gnc_gen_trans_new (NULL, NULL); - gnc_gen_trans_freeze (importer_gui); - gnc_gen_trans_set_fuzzy_amount (importer_gui, 0.0); - + GNCGenTransaction *importer_gui = NULL; + GNCImportMainMatcher *importer_generic_gui = NULL; + + data.use_generic_matcher = gnc_lookup_boolean_option("Online Banking & Importing", + "HBCI Use generic import matcher", + DEFAULT_USE_GENERIC_MATCHER); + + if(data.use_generic_matcher) + { + importer_gui = gnc_gen_trans_new (NULL, NULL); + gnc_gen_trans_freeze (importer_gui); + gnc_gen_trans_set_fuzzy_amount (importer_gui, 0.0); + data.importer = importer_gui; + } + else + { + importer_generic_gui = gnc_gen_trans_list_new(NULL, NULL, TRUE); + data.importer_generic = importer_generic_gui; + } data.gnc_acc = gnc_acc; - data.importer = importer_gui; - + + list_HBCI_Transaction_foreach (trans_list, trans_list_cb, &data); - gnc_gen_trans_thaw (importer_gui); + if(data.use_generic_matcher==FALSE) + { + gnc_gen_trans_thaw (importer_gui); + } GNCInteractor_hide (interactor); - - gnc_gen_trans_run (importer_gui); + if(data.use_generic_matcher) + { + gnc_gen_trans_list_run (importer_generic_gui); + } + else + { + gnc_gen_trans_run (importer_gui); + } } else { GNCInteractor_hide (interactor); @@ -299,7 +328,13 @@ static void *trans_list_cb (const HBCI_Transaction *h_trans, /* Instead of xaccTransCommitEdit(gnc_trans) */ /*gnc_import_add_trans(gnc_trans);*/ - gnc_gen_trans_add_trans (data->importer, gnc_trans); - + if(data->use_generic_matcher) + { + gnc_gen_trans_list_add_trans (data->importer_generic, gnc_trans); + } + else + { + gnc_gen_trans_add_trans (data->importer, gnc_trans); + } return NULL; } diff --git a/src/import-export/hbci/hbci.scm b/src/import-export/hbci/hbci.scm index a6838d2eef..c4a2a795b6 100644 --- a/src/import-export/hbci/hbci.scm +++ b/src/import-export/hbci/hbci.scm @@ -40,3 +40,9 @@ (gnc:register-configuration-option (gnc:make-internal-option "__gui" "hbci_close_on_finish" 1)) + +(gnc:register-configuration-option + (gnc:make-simple-boolean-option + (N_ "Online Banking & Importing") (N_ "HBCI Use generic import matcher") + "b" (N_ "Use the transaction matcher from the generic import infrastructure instead of the HBCI specific one") + #f)) \ No newline at end of file diff --git a/src/import-export/import-account-matcher.c b/src/import-export/import-account-matcher.c index a18f62c1f6..0ed1720a0e 100644 --- a/src/import-export/import-account-matcher.c +++ b/src/import-export/import-account-matcher.c @@ -144,8 +144,15 @@ build_acct_tree(struct _accountpickerdialog * picker) { acct_tree_add_accts(picker, picker->acct_group, GTK_CTREE(picker->treeview), NULL); - gtk_clist_columns_autosize (GTK_CLIST (picker->treeview)); + gtk_clist_column_titles_passive (GTK_CLIST (picker->treeview)); + gtk_clist_set_column_auto_resize (GTK_CLIST (picker->treeview), + CLIST_NAME, + TRUE); + gtk_clist_set_column_auto_resize (GTK_CLIST (picker->treeview), + CLIST_TYPE, + TRUE); + gtk_clist_columns_autosize (GTK_CLIST (picker->treeview)); gtk_clist_thaw (GTK_CLIST(picker->treeview)); } diff --git a/src/import-export/import-main-matcher.c b/src/import-export/import-main-matcher.c index 167f156ef5..b4de7a433c 100644 --- a/src/import-export/import-main-matcher.c +++ b/src/import-export/import-main-matcher.c @@ -41,7 +41,7 @@ #include "import-backend.h" #include "import-account-matcher.h" -struct _generic_transaction_info +struct _main_matcher_info { GtkWidget *dialog; GtkWidget *clist; @@ -211,10 +211,10 @@ static char * checkbox_unchecked_xpm[] = { "............"}; static void -refresh_clist_row (GNCGenTransaction *gui, +refresh_clist_row (GNCImportMainMatcher *gui, int row_number, GNCImportTransInfo *info); -void gnc_gen_trans_list_delete (GNCGenTransaction *info) +void gnc_gen_trans_list_delete (GNCImportMainMatcher *info) { if (info == NULL) return; @@ -228,7 +228,7 @@ static void on_matcher_ok_clicked (GtkButton *button, gpointer user_data) { - GNCGenTransaction *info = user_data; + GNCImportMainMatcher *info = user_data; g_assert (info); /* DEBUG ("Begin") */ gnc_import_process_trans_clist (GTK_CLIST (info->clist), NULL); @@ -241,12 +241,12 @@ static void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data) { - GNCGenTransaction *info = user_data; + GNCImportMainMatcher *info = user_data; gnc_gen_trans_list_delete (info); } static void -run_account_picker_dialog (GNCGenTransaction *info, +run_account_picker_dialog (GNCImportMainMatcher *info, gint row, GNCImportTransInfo *trans_info) { Account *old_acc, *new_acc; @@ -269,7 +269,7 @@ run_account_picker_dialog (GNCGenTransaction *info, } static void -run_match_dialog (GNCGenTransaction *info, +run_match_dialog (GNCImportMainMatcher *info, gint row, GNCImportTransInfo *trans_info) { gnc_import_match_picker_run_and_close (trans_info); @@ -282,7 +282,7 @@ clist_select_row_cb (GtkCList *clist, GdkEventButton *event, gpointer user_data) { - GNCGenTransaction *gui = user_data; + GNCImportMainMatcher *gui = user_data; GNCImportTransInfo *trans_info; gboolean should_refresh = TRUE; DEBUG("row_number: %d%s%d",row_number,", column: ",column); @@ -358,29 +358,29 @@ clist_select_row_cb (GtkCList *clist, column); } -void gnc_gen_trans_list_freeze (GNCGenTransaction *gui) +static void gnc_gen_trans_list_freeze (GNCImportMainMatcher *gui) { g_assert (gui); gtk_clist_freeze (GTK_CLIST (gui->clist)); } -void gnc_gen_trans_list_thaw (GNCGenTransaction *gui) +static void gnc_gen_trans_list_thaw (GNCImportMainMatcher *gui) { g_assert (gui); gtk_clist_thaw (GTK_CLIST (gui->clist)); } -GNCGenTransaction *gnc_gen_trans_list_new (GtkWidget *parent, +GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, const gchar* heading, gboolean all_from_same_account) { - GNCGenTransaction *info; + GNCImportMainMatcher *info; GladeXML *xml; GtkWidget *heading_label; gnc_should_log(MOD_IMPORT, GNC_LOG_TRACE); - info = g_new0 (GNCGenTransaction, 1); + info = g_new0 (GNCImportMainMatcher, 1); /* Initialize user Settings. */ info->user_settings = gnc_import_Settings_new (); @@ -483,7 +483,7 @@ GNCGenTransaction *gnc_gen_trans_list_new (GtkWidget *parent, return info; } -gboolean gnc_gen_trans_list_run (GNCGenTransaction *info) +gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info) { gboolean result; @@ -522,7 +522,7 @@ static char ** gen_clist_row_text (GNCImportTransInfo *info) static void -refresh_clist_row (GNCGenTransaction *gui, +refresh_clist_row (GNCImportMainMatcher *gui, int row_number, GNCImportTransInfo *info) { char *text[NUM_COLUMNS_DOWNLOADED_CLIST]; @@ -759,7 +759,7 @@ refresh_clist_row (GNCGenTransaction *gui, } -void gnc_gen_trans_list_add_trans(GNCGenTransaction *gui, Transaction *trans) +void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans) { GNCImportTransInfo * transaction_info = NULL; gint row_number; diff --git a/src/import-export/import-main-matcher.h b/src/import-export/import-main-matcher.h index 0dd4871423..49d0b3f458 100644 --- a/src/import-export/import-main-matcher.h +++ b/src/import-export/import-main-matcher.h @@ -24,13 +24,13 @@ @author Christian Stimming */ -#ifndef GNC_GEN_TRANSACTION_H -#define GNC_GEN_TRANSACTION_H +#ifndef GNC_IMPORT_MAIN_MATCHER_H +#define GNC_IMPORT_MAIN_MATCHER_H #include #include "Transaction.h" -typedef struct _generic_transaction_info GNCGenTransaction; +typedef struct _main_matcher_info GNCImportMainMatcher; /** Create a new generic transaction dialog window and return it. @param parent The parent GtkWidget. May be NULL. @@ -39,12 +39,12 @@ typedef struct _generic_transaction_info GNCGenTransaction; that will be added with gnc_gen_trans_list_add_trans are from the same source account. This will cause the account column to be hidden. */ -GNCGenTransaction *gnc_gen_trans_list_new (GtkWidget *parent, +GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, const gchar* heading, gboolean all_from_same_account); /** Deletes the given object. */ -void gnc_gen_trans_list_delete (GNCGenTransaction *info); +void gnc_gen_trans_list_delete (GNCImportMainMatcher *info); /** Add a newly imported Transaction to the Transaction Importer. @param gui The Transaction Importer to use. @@ -53,23 +53,13 @@ void gnc_gen_trans_list_delete (GNCGenTransaction *info); Only the first split will be used for matching. The transaction must NOT be commited. */ -void gnc_gen_trans_list_add_trans(GNCGenTransaction *gui, Transaction *trans); +void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans); /** Run this dialog and return only after the user pressed Ok, Cancel, or closed the window. This means that all actual importing will have been finished upon returning. */ -gboolean gnc_gen_trans_list_run (GNCGenTransaction *info); - -/** Freeze the underlying GtkCList. Do this before you add a lot of - transactions. */ -void gnc_gen_trans_list_freeze (GNCGenTransaction *gui); - -/** Thaw the underlying GtkCList. Do this after you added a lot of - transactions. */ -void gnc_gen_trans_list_thaw (GNCGenTransaction *gui); - - +gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info); #endif /**@}*/ diff --git a/src/import-export/import-settings.c b/src/import-export/import-settings.c index 2e68a35f96..ee36374da9 100644 --- a/src/import-export/import-settings.c +++ b/src/import-export/import-settings.c @@ -38,6 +38,8 @@ * If you modify the value of any of these, you must do the same in * * generic-import.scm * \********************************************************************/ +#define MATCHER_PREF_PAGE "Transaction Matcher" + /** Transaction who's best match probability is equal or higher than this will reconcile their best match by default */ #define DEFAULT_CLEAR_THRESHOLD 5 @@ -98,27 +100,27 @@ gnc_import_Settings_new (void) settings->action_skip_enabled = - gnc_lookup_boolean_option("Transaction Matcher", + gnc_lookup_boolean_option(MATCHER_PREF_PAGE, "Enable SKIP transaction action", DEFAULT_ACTION_SKIP_ENABLED); settings->action_edit_enabled = - gnc_lookup_boolean_option("Transaction Matcher", + gnc_lookup_boolean_option(MATCHER_PREF_PAGE, "Enable EDIT match action", DEFAULT_ACTION_EDIT_ENABLED); settings->action_add_enabled=DEFAULT_ACTION_ADD_ENABLED; settings->action_clear_enabled=DEFAULT_ACTION_CLEAR_ENABLED; - settings->clear_threshold=gnc_lookup_number_option("Transaction Matcher", + settings->clear_threshold=gnc_lookup_number_option(MATCHER_PREF_PAGE, "Auto-CLEAR threshold", DEFAULT_CLEAR_THRESHOLD); - settings->add_threshold=gnc_lookup_number_option("Transaction Matcher", + settings->add_threshold=gnc_lookup_number_option(MATCHER_PREF_PAGE, "Auto-ADD threshold", DEFAULT_ADD_THRESHOLD); settings->display_threshold = - gnc_lookup_number_option("Transaction Matcher","Match display threshold", + gnc_lookup_number_option(MATCHER_PREF_PAGE,"Match display threshold", DEFAULT_DISPLAY_THRESHOLD); settings->fuzzy_amount = - gnc_lookup_number_option("Transaction Matcher","Commercial ATM fees threshold", + gnc_lookup_number_option(MATCHER_PREF_PAGE,"Commercial ATM fees threshold", DEFAULT_ATM_FEE_THRESHOLD); return settings; diff --git a/src/import-export/ofx/README b/src/import-export/ofx/README index f564f8affc..6439e6f7e6 100644 --- a/src/import-export/ofx/README +++ b/src/import-export/ofx/README @@ -1,23 +1,22 @@ -This is the new OFX import module. It's still very young, but it is now ready for other people to test. -Note: You should also read src/import-export/generic-import-design.txt +This is the new OFX import module. Implemented features (some of these are from the generic import module): -OFX file selection -Account matching, using unique OFX account ID -Account creation --Transaction duplicate matching, using the unique OFX transaction ID only. +-Transaction duplicate detection, using the unique OFX transaction ID. -Saving of ALL transaction data currently supported by LibOFX. When no gnucash equivalent, it is put in the Transaction's Note field. You must have double-line mode enabled to view the notes field. +-Full OFX investment transaction support, including commodity import and matching. Unimplemented features: -Account currency compatibility check --Automaticaly set sane defaults when creating new account (parent account, sibling, currency, etc.) --Transaction fuzzy matching and split balancing To compile: -./autogen.sh --enable-ofx +Add --enable-ofx to ./autogen.sh (for CVS) or ./configure (for tarballs) make -If sucessfull, an item will apear in Gnucash's File/Import submenu. +If successfull, an item will apear in Gnucash's File/Import submenu. -You must have LibOFX > 0.23 installed. http://step.polymtl.ca/~bock/libofx/ -LibOFX depends on OpenSP , read LibOFX's "INSTALL" file. LibOFX needs a recent version (1.5pre5 as of this writing, 1.4 might work). -I suggest you first run your ofx file thru ofxdump before you try it from GnuCash.diff -up 'gnucash_orig/src/import-export/ofx/gnc-ofx-import.c' 'gnucash_test/src/import-export/ofx/gnc-ofx-import.c' +You must have LibOFX > 0.32 installed. http://libofx.sourceforge.net/ +LibOFX depends on OpenSP , read LibOFX's "INSTALL" file. LibOFX needs a recent version (1.5pre5 as of this writing, 1.4 will probably work fine, 1.3.x MIGHT work, but is very buggy and depends on horrible kludges in the LibOFX code. You have been warned.). + +You may want to first run your ofx file thru ofxdump to test your libofx installation before you try it from GnuCash. diff --git a/src/import-export/ofx/gnc-ofx-import.c b/src/import-export/ofx/gnc-ofx-import.c index 8b09bbe151..2704a46e38 100644 --- a/src/import-export/ofx/gnc-ofx-import.c +++ b/src/import-export/ofx/gnc-ofx-import.c @@ -69,7 +69,7 @@ SCM scm_gnc_file_ofx_import () /* CS: Store the reference to the created importer gui so that the ofx_proc_transaction_cb can use it. */ -GNCGenTransaction *gnc_ofx_importer_gui = NULL; +GNCImportMainMatcher *gnc_ofx_importer_gui = NULL; void gnc_file_ofx_import (void) {