gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Sat Jan 19 12:04:51 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/72ef48cb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d02c65e7 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f7173c34 (commit)



commit 72ef48cbf267ef8f8e01ce9f7d8dfce73088590c
Merge: f7173c3 d02c65e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 19 17:47:30 2019 +0100

    Merge branch 'bugs_icv' of https://github.com/ekinonnakapito/gnucash into maint


commit d02c65e76a2c70d0b4718d8348c0a34ad2ddf77e
Author: Rob Laan <rob.laan at chello.nl>
Date:   Sat Jan 12 17:39:44 2019 +0100

    Fixes for bugs 797029 7970331 797030 in Import Customers & Vendors
    
    797029 Import Customer & Vendors: blank name and company in import data row crashes GnuCash
    797031 Import customer & Vendors: import can create customer and vendors without address data
    797030 Import Customer & Vendors: several issues with the matching of data rows

diff --git a/gnucash/import-export/customer-import/dialog-customer-import-gui.c b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
index 5293721..c2308de 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
@@ -109,7 +109,7 @@ gnc_plugin_customer_import_showGUI(GtkWindow *parent)
 
     gtk_window_set_transient_for (GTK_WINDOW (gui->dialog), parent);
 
-    gui->regexp = g_string_new ( "^(?<id>[^;]+);(?<company>[^;]*);(?<name>[^;]+);(?<addr1>[^;]+);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipaddr4>[^;]*);?(?<shipphone>[^;]*);?(?<shipfax>[^;]*);?(?<shipemail>[^;]*)");
+    gui->regexp = g_string_new ( "^(\\x{FEFF})?(?<id>[^;]*);(?<company>[^;]*);(?<name>[^;]*);(?<addr1>[^;]*);(?<addr2>[^;]*);(?<addr3>[^;]*);(?<addr4>[^;]*);(?<phone>[^;]*);(?<fax>[^;]*);(?<email>[^;]*);(?<notes>[^;]*);(?<shipname>[^;]*);(?<shipaddr1>[^;]*);(?<shipaddr2>[^;]*);(?<shipaddr3>[^;]*);(?<shipaddr4>[^;]*);(?<shipphone>[^;]*);(?<shipfax>[^;]*);(?<shipemail>[^;]*)$");
     gui->book = gnc_get_current_book();
 
     // create model and bind to view
@@ -284,7 +284,7 @@ void gnc_customer_import_gui_option1_cb (GtkWidget *widget, gpointer data)
     CustomerImportGui *gui = data;
     if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
         return;
-    g_string_assign (gui->regexp, "^(?<id>[^;]*);(?<company>[^;]*);(?<name>[^;]*);(?<addr1>[^;]*);?(?<addr2>[^;]*);?(?<addr3>[^;]*);?(?<addr4>[^;]*);?(?<phone>[^;]*);?(?<fax>[^;]*);?(?<email>[^;]*);?(?<notes>[^;]*);?(?<shipname>[^;]*);?(?<shipaddr1>[^;]*);?(?<shipaddr2>[^;]*);?(?<shipaddr3>[^;]*);?(?<shipaddr4>[^;]*);?(?<shipphone>[^;]*);(?<shipfax>[^;]*);(?<shipemail>[^;]*)"); //;(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)$");
+    g_string_assign (gui->regexp, "^(\\x{FEFF})?(?<id>[^;]*);(?<company>[^;]*);(?<name>[^;]*);(?<addr1>[^;]*);(?<addr2>[^;]*);(?<addr3>[^;]*);(?<addr4>[^;]*);(?<phone>[^;]*);(?<fax>[^;]*);(?<email>[^;]*);(?<notes>[^;]*);(?<shipname>[^;]*);(?<shipaddr1>[^;]*);(?<shipaddr2>[^;]*);(?<shipaddr3>[^;]*);(?<shipaddr4>[^;]*);(?<shipphone>[^;]*);(?<shipfax>[^;]*);(?<shipemail>[^;]*)$");
     gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
 }
 // Comma separated.
@@ -293,7 +293,7 @@ void gnc_customer_import_gui_option2_cb (GtkWidget *widget, gpointer data)
     CustomerImportGui *gui = data;
     if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
         return;
-    g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipaddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
+    g_string_assign (gui->regexp, "^(\\x{FEFF})?(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),(?<addr2>[^,]*),(?<addr3>[^,]*),(?<addr4>[^,]*),(?<phone>[^,]*),(?<fax>[^,]*),(?<email>[^,]*),(?<notes>[^,]*),(?<shipname>[^,]*),(?<shipaddr1>[^,]*),(?<shipaddr2>[^,]*),(?<shipaddr3>[^,]*),(?<shipaddr4>[^,]*),(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)$");
     gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
 }
 // Semicolon separated with quoted strings.
@@ -302,8 +302,7 @@ void gnc_customer_import_gui_option3_cb (GtkWidget *widget, gpointer data)
     CustomerImportGui *gui = data;
     if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
         return;
-    //g_string_assign (gui->regexp, "^((?<id>[^\";]*)|\"(?<id>[^\"]*)\");((?<company>[^\";]*)|\"(?<company>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<addr1>[^\";]*)|\"(?<addr1>[^\"]*)\");((?<addr2>[^\";]*)|\"(?<addr2>[^\"]*)\");((?<addr3>[^\";]*)|\"(?<addr3>[^\"]*)\");((?<addr4>[^\";]*)|\"(?<addr4>[^\"]*)\");((?<phone>[^\";]*)|\"(?<phone>[^\"]*)\");((?<fax>[^\";]*)|\"(?<fax>[^\"]*)\");((?<email>[^\";]*)|\"(?<email>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<shipname>[^\";]*)|\"(?<shipname>[^\"]*)\");((?<shipaddr1>[^\";]*)|\"(?<shipaddr1>[^\"]*)\");((?<shipaddr2>[^\";]*)|\"(?<shipaddr2>[^\"]*)\");((?<shipaddr3>[^\";]*)|\"(?<shipaddr3>[^\"]*)\");((?<shipaddr4>[^\";]*)|\"(?<shipaddr4>[^\"]*)\");((?<shipphone>[^\";]*)|\"(?<shipphone>[^\"]*)\");((?<shipfax>[^\";]*)|\"(?<shipfax>[^\"]*)\");((?<shipmail>[^\";]*)|\"(?<shipemail>[^\"]*)\")$");
-    g_string_assign (gui->regexp, "^((?<id>[^\";]*)|\"(?<id>[^\"]*)\");((?<company>[^\";]*)|\"(?<company>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<addr1>[^\";]*)|\"(?<addr1>[^\"]*)\");((?<addr2>[^\";]*)|\"(?<addr2>[^\"]*)\");((?<addr3>[^\";]*)|\"(?<addr3>[^\"]*)\");((?<addr4>[^\";]*)|\"(?<addr4>[^\"]*)\");((?<phone>[^\";]*)|\"(?<phone>[^\"]*)\");((?<fax>[^\";]*)|\"(?<fax>[^\"]*)\");((?<email>[^\";]*)|\"(?<email>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<shipname>[^\";]*)|\"(?<shipname>[^\"]*)\");((?<shipaddr1>[^\";]*)|\"(?<shipaddr1>[^\"]*)\");((?<shipaddr2>[^\";]*)|\"(?<shipaddr2>[^\"]*)\");((?<shipaddr3>[^\";]*)|\"(?<shipaddr3>[^\"]*)\");((?<shipaddr4>[^\";]*)|\"(?<shipaddr4>[^\"]*)\");((?<shipphone>[^\";]*)|\"(?<shipphone>[^\"]*)\");((?<shipfax>[^\";]*)|\"(?<shipfax>[^\"]*)\");((?<shipemail>[^\";]*)|\"(?<shipemail>[^\"]*)\")$");
+    g_string_assign (gui->regexp, "^(\\x{FEFF})?((?<id>[^\";]*)|\"(?<id>[^\"]*)\");((?<company>[^\";]*)|\"(?<company>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<addr1>[^\";]*)|\"(?<addr1>[^\"]*)\");((?<addr2>[^\";]*)|\"(?<addr2>[^\"]*)\");((?<addr3>[^\";]*)|\"(?<addr3>[^\"]*)\");((?<addr4>[^\";]*)|\"(?<addr4>[^\"]*)\");((?<phone>[^\";]*)|\"(?<phone>[^\"]*)\");((?<fax>[^\";]*)|\"(?<fax>[^\"]*)\");((?<email>[^\";]*)|\"(?<email>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<shipname>[^\";]*)|\"(?<shipname>[^\"]*)\");((?<shipaddr1>[^\";]*)|\"(?<shipaddr1>[^\"]*)\");((?<shipaddr2>[^\";]*)|\"(?<shipaddr2>[^\"]*)\");((?<shipaddr3>[^\";]*)|\"(?<shipaddr3>[^\"]*)\");((?<shipaddr4>[^\";]*)|\"(?<shipaddr4>[^\"]*)\");((?<shipphone>[^\";]*)|\"(?<shipphone>[^\"]*)\");((?<shipfax>[^\";]*)|\"(?<shipfax>[^\"]*)\");((?<shipemail>[^;]*)|\"(?<shipemail>[^\"]*)\")$");
     gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
 }
 // Comma separated with quoted strings.
@@ -312,8 +311,7 @@ void gnc_customer_import_gui_option4_cb (GtkWidget *widget, gpointer data)
     CustomerImportGui *gui = data;
     if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
         return;
-    //g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipaddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$");
-    g_string_assign (gui->regexp, "^((?<id>[^\",]*)|\"(?<id>[^\"]*)\"),((?<company>[^\",]*)|\"(?<company>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<addr1>[^\",]*)|\"(?<addr1>[^\"]*)\"),((?<addr2>[^\",]*)|\"(?<addr2>[^\"]*)\"),((?<addr3>[^\",]*)|\"(?<addr3>[^\"]*)\"),((?<addr4>[^\",]*)|\"(?<addr4>[^\"]*)\"),((?<phone>[^\",]*)|\"(?<phone>[^\"]*)\"),((?<fax>[^\",]*)|\"(?<fax>[^\"]*)\"),((?<email>[^\",]*)|\"(?<email>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<shipname>[^\",]*)|\"(?<shipname>[^\"]*)\"),((?<shipaddr1>[^\",]*)|\"(?<shipaddr1>[^\"]*)\"),((?<shipaddr2>[^\",]*)|\"(?<shipaddr2>[^\"]*)\"),((?<shipaddr3>[^\",]*)|\"(?<shipaddr3>[^\"]*)\"),((?<shipaddr4>[^\",]*)|\"(?<shipaddr4>[^\"]*)\"),((?<shipphone>[^\",]*)|\"(?<shipphone>[^\"]*)\"),((?<shipfax>[^\",]*)|\"(?<shipfax>[^\"]*)\"),((?<shipemail>[^\",]*)|\"(?<shipemail>[^\"]*)\")$");
+    g_string_assign (gui->regexp, "^(\\x{FEFF})?((?<id>[^\",]*)|\"(?<id>[^\"]*)\"),((?<company>[^\",]*)|\"(?<company>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<addr1>[^\",]*)|\"(?<addr1>[^\"]*)\"),((?<addr2>[^\",]*)|\"(?<addr2>[^\"]*)\"),((?<addr3>[^\",]*)|\"(?<addr3>[^\"]*)\"),((?<addr4>[^\",]*)|\"(?<addr4>[^\"]*)\"),((?<phone>[^\",]*)|\"(?<phone>[^\"]*)\"),((?<fax>[^\",]*)|\"(?<fax>[^\"]*)\"),((?<email>[^\",]*)|\"(?<email>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<shipname>[^\",]*)|\"(?<shipname>[^\"]*)\"),((?<shipaddr1>[^\",]*)|\"(?<shipaddr1>[^\"]*)\"),((?<shipaddr2>[^\",]*)|\"(?<shipaddr2>[^\"]*)\"),((?<shipaddr3>[^\",]*)|\"(?<shipaddr3>[^\"]*)\"),((?<shipaddr4>[^\",]*)|\"(?<shipaddr4>[^\"]*)\"),((?<shipphone>[^\",]*)|\"(?<shipphone>[^\"]*)\"),((?<shipfax>[^\",]*)|\"(?<shipfax>[^\"]*)\"),((?<shipemail>[^\",]*)|\"(?<shipemail>[^\"]*)\")$");
     gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui);
 }
 void gnc_customer_import_gui_option5_cb (GtkWidget *widget, gpointer data)
diff --git a/gnucash/import-export/customer-import/dialog-customer-import.c b/gnucash/import-export/customer-import/dialog-customer-import.c
index 758ce8c..322a59d 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import.c
@@ -201,9 +201,7 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del
 {
     GtkTreeIter iter;
     gboolean valid;
-    gchar *company, *name, *addr1, *addr2, *addr3, *addr4, *phone, *fax, *email,
-            *notes, *shipname, *shipaddr1, *shipaddr2, *shipaddr3, *shipaddr4, 
-            *shipphone, *shipfax, *shipemail;
+    gchar *company, *name, *addr1, *addr2, *addr3, *addr4;
     guint dummy;
 
     // allow the call to this function with only GtkListeStore* specified
@@ -226,26 +224,17 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del
                             CI_ADDR2, &addr2,
                             CI_ADDR3, &addr3,
                             CI_ADDR4, &addr4,
-                            CI_PHONE, &phone,
-                            CI_FAX, &fax,
-                            CI_EMAIL, &email,
-                            CI_NOTES, &notes,
-                            CI_SHIPNAME, &shipname,
-                            CI_SHIPADDR1, &shipaddr1,
-                            CI_SHIPADDR2, &shipaddr2,
-                            CI_SHIPADDR3, &shipaddr3,
-                            CI_SHIPADDR4, &shipaddr4,
-                            CI_SHIPPHONE, &shipphone,
-                            CI_SHIPFAX, &shipfax,
-                            CI_SHIPEMAIL, &shipemail,
                             -1);
 
+        // Company name is mandatory.
+        // If not provided, default the company name to the value of the field name.
         if (strlen(company) == 0)
         {
+            //But if the field name is also blank, then delete the row.
             if (strlen(name) == 0)
             {
                 // no fix possible -> delete row
-                gtk_list_store_remove (store, &iter);
+                valid = gtk_list_store_remove (store, &iter);
                 (*deleted)++;
                 continue;
             }
@@ -257,24 +246,21 @@ gnc_customer_import_fix_customers (GtkListStore *store, guint *fixed, guint *del
             }
         }
         
+        // At least one of the address fields must have a value.
+        // If not, then delete the row.
+        if (strlen(addr1) == 0 && strlen(addr2) == 0 && strlen(addr3) == 0 && strlen(addr4) == 0)
+        {
+            valid = gtk_list_store_remove (store, &iter);
+            (*deleted)++;
+            continue;
+        }
+        
         g_free (company);
         g_free (name);
         g_free (addr1);
         g_free (addr2);
         g_free (addr3);
         g_free (addr4);
-        g_free (phone);
-        g_free (fax);
-        g_free (email);
-        g_free (notes);
-        g_free (shipname);
-        g_free (shipaddr1);
-        g_free (shipaddr2);
-        g_free (shipaddr3);
-        g_free (shipaddr4);
-        g_free (shipphone);
-        g_free (shipfax);
-        g_free (shipemail);
 
         valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
     }



Summary of changes:
 .../customer-import/dialog-customer-import-gui.c   | 12 +++----
 .../customer-import/dialog-customer-import.c       | 42 ++++++++--------------
 2 files changed, 19 insertions(+), 35 deletions(-)



More information about the gnucash-changes mailing list