gnucash master: Multiple changes pushed

Mike Alexander mta at code.gnucash.org
Fri May 8 17:19:36 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/0a4347bd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a4e35f3c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/478112d8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/870c02b0 (commit)
	from  https://github.com/Gnucash/gnucash/commit/32e19170 (commit)



commit 0a4347bd5ef155193a1d5b18f9ed8596283e488d
Author: Mike Alexander <mta at umich.edu>
Date:   Thu Jan 9 02:03:08 2020 -0500

    Initially select the last account chosen in the account picker dialogs.
    
    Separately keeps track of last investment account, security account,
    and income account.  One issue is that gnc_import_select_account
    doesn't tell the caller if it put up a dialog or found the online ID
    on an existing account.  This means the last account may be one the
    user didn't manually select.  This may or may not be the right thing
    to do.

diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c
index 2681ef682..578f20d49 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.c
+++ b/gnucash/import-export/ofx/gnc-ofx-import.c
@@ -71,6 +71,9 @@ typedef struct _ofx_info
     GSList* statement;
     GtkWindow* parent;
     GNCImportMainMatcher *gnc_ofx_importer_gui;
+    Account *last_import_account;
+    Account *last_investment_account;
+    Account *last_income_account;
     GList *created_commodites   ;
 } ofx_info ;
 
@@ -434,12 +437,13 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
     account = gnc_import_select_account(gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
                                         data.account_id,
 					0, NULL, NULL, ACCT_TYPE_NONE,
-					NULL, NULL);
+					info->last_import_account, NULL);
     if (account == NULL)
     {
         PERR("Unable to find account for id %s", data.account_id);
         return 0;
     }
+    info->last_import_account = account;
     /***** Validate the input strings to ensure utf8 *****/
     if (data.name_valid)
         gnc_utf8_strip_invalid(data.name);
@@ -652,8 +656,10 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                                      investment_account_text,
                                      investment_commodity,
                                      ACCT_TYPE_STOCK,
-                                     NULL,
+                                     info->last_investment_account,
                                      NULL);
+                if (investment_account)
+                    info->last_investment_account = investment_account;
 
                 // but use it only if that's really the right commodity
                 if (investment_account
@@ -681,8 +687,10 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                                                  investment_account_text,
                                                  investment_commodity,
                                                  ACCT_TYPE_STOCK,
-                                                 NULL,
+                                                 info->last_investment_account,
                                                  &choosing_account);
+                        if (investment_account)
+                            info->last_investment_account = investment_account;
                     }
                     // Does the chosen account have the right commodity?
                     if (investment_account && xaccAccountGetCommodity(investment_account) != investment_commodity)
@@ -817,10 +825,11 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                                              investment_account_text,
                                              currency,
                                              ACCT_TYPE_INCOME,
-                                             NULL,
+                                             info->last_income_account,
                                              NULL);
                         if (income_account != NULL)
                         {
+                            info->last_income_account = income_account;
                             set_associated_income_account(investment_account,
                                                           income_account);
                             DEBUG("KVP written");
@@ -1005,7 +1014,11 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data)
         account = gnc_import_select_account (GTK_WIDGET(info->parent),
                                              data.account_id, 1,
                                              account_description, default_commodity,
-                                             default_type, NULL, NULL);
+                                             default_type, info->last_import_account, NULL);
+        if (account)
+        {
+            info->last_import_account = account;
+        }
         g_free(account_description);
     }
     else
@@ -1053,7 +1066,7 @@ void gnc_file_ofx_import (GtkWindow *parent)
     GtkFileFilter* filter = gtk_file_filter_new ();
     GSList *iter = NULL;
     // Create the structure we're using to gather reconciliation information.
-    ofx_info info = {0, NULL, parent, NULL, NULL};
+    ofx_info info = {0, NULL, parent, NULL, NULL, NULL, NULL, NULL};
 
     ofx_PARSER_msg = false;
     ofx_DEBUG_msg = false;

commit a4e35f3cea7ce68d6f76bac0431b531f7bb21aad
Author: Mike Alexander <mta at umich.edu>
Date:   Sun May 3 23:59:00 2020 -0400

    Remove some globals by moving them into the struct passed to callbacks.
    No functional changes.

diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c
index ef39d5d66..2681ef682 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.c
+++ b/gnucash/import-export/ofx/gnc-ofx-import.c
@@ -62,9 +62,6 @@ static QofLogModule log_module = GNC_MOD_IMPORT;
  * Entry point
 \********************************************************************/
 
-/* CS: Store the reference to the created importer gui so that the
-   ofx_proc_transaction_cb can use it. */
-GNCImportMainMatcher *gnc_ofx_importer_gui = NULL;
 static gboolean auto_create_commodity = FALSE;
 static Account *ofx_parent_account = NULL;
 // Structure we use to gather information about statement balance/account etc.
@@ -73,10 +70,10 @@ typedef struct _ofx_info
     gint num_trans_processed;
     GSList* statement;
     GtkWindow* parent;
+    GNCImportMainMatcher *gnc_ofx_importer_gui;
+    GList *created_commodites   ;
 } ofx_info ;
 
-GList *ofx_created_commodites = NULL;
-
 /*
 int ofx_proc_status_cb(struct OfxStatusData data)
 {
@@ -233,6 +230,8 @@ int ofx_proc_security_cb(const struct OfxSecurityData data, void * security_user
     char* default_fullname = NULL;
     char* default_mnemonic = NULL;
 
+    ofx_info* info = (ofx_info*) security_user_data;
+
     if (data.unique_id_valid)
     {
         cusip = gnc_utf8_strip_invalid_strdup (data.unique_id);
@@ -287,7 +286,7 @@ int ofx_proc_security_cb(const struct OfxSecurityData data, void * security_user
             gnc_commodity_table_insert(gnc_get_current_commodities(), commodity);
 
             /* Remember this new commodity for us as well */
-            ofx_created_commodites = g_list_prepend(ofx_created_commodites, commodity);
+            info->created_commodites = g_list_prepend(info->created_commodites, commodity);
 	    g_free (commodity_namespace);
 
         }
@@ -422,7 +421,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
     ofx_info* info = (ofx_info*) user_data;
     GtkWindow *parent = GTK_WINDOW (info->parent);
 
-    g_assert(gnc_ofx_importer_gui);
+    g_assert(info->gnc_ofx_importer_gui);
 
     if (!data.account_id_valid)
     {
@@ -432,7 +431,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
     else
 	gnc_utf8_strip_invalid (data.account_id);
 
-    account = gnc_import_select_account(gnc_gen_trans_list_widget(gnc_ofx_importer_gui),
+    account = gnc_import_select_account(gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
                                         data.account_id,
 					0, NULL, NULL, ACCT_TYPE_NONE,
 					NULL, NULL);
@@ -647,7 +646,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
 							       data.account_id,
 							       data.unique_id);
                 investment_account = gnc_import_select_account(
-                                     gnc_gen_trans_list_widget(gnc_ofx_importer_gui),
+                                     gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
                                      investment_account_onlineid,
                                      1,
                                      investment_account_text,
@@ -676,7 +675,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                     {
                         // Let the user choose an account
                         investment_account = gnc_import_select_account(
-                                                 gnc_gen_trans_list_widget(gnc_ofx_importer_gui),
+                                                 gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
                                                  data.unique_id,
                                                  TRUE,
                                                  investment_account_text,
@@ -722,7 +721,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                             // whether to continue or abort.
                             choosing_account =
                                 gnc_verify_dialog(
-                                    GTK_WINDOW (gnc_gen_trans_list_widget(gnc_ofx_importer_gui)), TRUE,
+                                    GTK_WINDOW (gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui)), TRUE,
                                     "The chosen account \"%s\" does not have the correct "
                                     "currency/security \"%s\" (it has \"%s\" instead). "
                                     "This account cannot be used. "
@@ -812,7 +811,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
                                                       _("Income account for security \"%s\""),
                                                       sanitize_string (data.security_data_ptr->secname));
                         income_account = gnc_import_select_account(
-                                             gnc_gen_trans_list_widget(gnc_ofx_importer_gui),
+                                             gnc_gen_trans_list_widget(info->gnc_ofx_importer_gui),
                                              NULL,
                                              1,
                                              investment_account_text,
@@ -886,7 +885,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
         if (xaccTransCountSplits(transaction) > 0)
         {
             DEBUG("%d splits sent to the importer gui", xaccTransCountSplits(transaction));
-            gnc_gen_trans_list_add_trans (gnc_ofx_importer_gui, transaction);
+            gnc_gen_trans_list_add_trans (info->gnc_ofx_importer_gui, transaction);
         }
         else
         {
@@ -1054,7 +1053,7 @@ void gnc_file_ofx_import (GtkWindow *parent)
     GtkFileFilter* filter = gtk_file_filter_new ();
     GSList *iter = NULL;
     // Create the structure we're using to gather reconciliation information.
-    ofx_info info = {0, NULL, parent};
+    ofx_info info = {0, NULL, parent, NULL, NULL};
 
     ofx_PARSER_msg = false;
     ofx_DEBUG_msg = false;
@@ -1092,7 +1091,7 @@ void gnc_file_ofx_import (GtkWindow *parent)
         DEBUG("Filename found: %s", selected_filename);
 
         /* Create the Generic transaction importer GUI. */
-        gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42, FALSE);
+        info.gnc_ofx_importer_gui = gnc_gen_trans_list_new (GTK_WIDGET(parent), NULL, FALSE, 42, FALSE);
 
         /* Look up the needed preferences */
         auto_create_commodity =
@@ -1114,21 +1113,21 @@ void gnc_file_ofx_import (GtkWindow *parent)
         DEBUG("Opening selected file");
         libofx_proc_file(libofx_context, selected_filename, AUTODETECT);
         // See whether the view has anything in it and warn the user if not.
-        if(gnc_gen_trans_list_empty(gnc_ofx_importer_gui))
+        if(gnc_gen_trans_list_empty(info.gnc_ofx_importer_gui))
         {
-            gnc_gen_trans_list_delete (gnc_ofx_importer_gui);
+            gnc_gen_trans_list_delete (info.gnc_ofx_importer_gui);
             if(info.num_trans_processed)
                 gnc_info_dialog (parent, _("OFX file imported, %d transactions processed, no transactions to match"), info.num_trans_processed);
         }
         else
         {
-            gnc_gen_trans_list_show_all(gnc_ofx_importer_gui);
+            gnc_gen_trans_list_show_all(info.gnc_ofx_importer_gui);
         }
         // Open a reconcile window for each balance statement found.
         for (iter=info.statement; iter; iter=iter->next)
         {
             struct OfxStatementData* statement = (struct OfxStatementData*) iter->data;
-            Account* account = gnc_import_select_account (gnc_gen_trans_list_widget(gnc_ofx_importer_gui),
+            Account* account = gnc_import_select_account (gnc_gen_trans_list_widget(info.gnc_ofx_importer_gui),
                                                           statement->account_id,
                                                           0, NULL, NULL, ACCT_TYPE_NONE,
                                                           NULL, NULL);
@@ -1151,13 +1150,12 @@ void gnc_file_ofx_import (GtkWindow *parent)
         g_slist_free_full (info.statement,g_free);
     }
 
-    if (ofx_created_commodites)
+    if (info.created_commodites)
     {
         /* FIXME: Present some result window about the newly created
          * commodities */
-        g_warning("Created %d new commodities during import", g_list_length(ofx_created_commodites));
-        g_list_free(ofx_created_commodites);
-        ofx_created_commodites = NULL;
+        g_warning("Created %d new commodities during import", g_list_length(info.created_commodites));
+        g_list_free(info.created_commodites);
     }
     else
     {

commit 478112d8c06b6b0fec506ad6891b3732b5d48be9
Author: Mike Alexander <mta at umich.edu>
Date:   Tue Apr 4 01:49:46 2017 -0400

    Define log_module in gnc-sx-instance-model.c.

diff --git a/libgnucash/app-utils/gnc-sx-instance-model.c b/libgnucash/app-utils/gnc-sx-instance-model.c
index 79d76789d..26a554f41 100644
--- a/libgnucash/app-utils/gnc-sx-instance-model.c
+++ b/libgnucash/app-utils/gnc-sx-instance-model.c
@@ -52,6 +52,7 @@
 
 #undef G_LOG_DOMAIN
 #define G_LOG_DOMAIN "gnc.app-utils.sx"
+static QofLogModule log_module = G_LOG_DOMAIN;
 
 /** Report errors bilingual:
  *  in g_critical untranslated and

commit 870c02b0928f45e4647c676b34a0d10073e8eb78
Author: Mike Alexander <mta at umich.edu>
Date:   Tue Oct 16 23:05:13 2018 -0400

    Add a newline to the GNC_DBD_DIR line in the environment file.

diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 79523cefa..9a4c423ad 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -156,7 +156,7 @@ if (LIBDBI_LIBRARY AND LIBDBI_DRIVERS_DIR)
   get_filename_component(libdir ${LIBDBI_LIBRARY} DIRECTORY)
   string(FIND ${LIBDBI_DRIVERS_DIR} ${libdir} is_subdir)
   if (NOT is_subdir EQUAL 0)
-    file(APPEND ${BUILD_ENV_FILE_OUT} "GNC_DBD_DIR=${LIBDBI_DRIVERS_DIR}")
+    file(APPEND ${BUILD_ENV_FILE_OUT} "GNC_DBD_DIR=${LIBDBI_DRIVERS_DIR}\n")
   endif()
 endif()
 



Summary of changes:
 gnucash/CMakeLists.txt                       |  2 +-
 gnucash/import-export/ofx/gnc-ofx-import.c   | 67 ++++++++++++++++------------
 libgnucash/app-utils/gnc-sx-instance-model.c |  1 +
 3 files changed, 41 insertions(+), 29 deletions(-)



More information about the gnucash-changes mailing list