r22432 - gnucash/trunk/src/plugins/customer_import - Fix bug in customer/vendor importer where new customers/vendors

Mike Evans mikee at code.gnucash.org
Tue Oct 2 17:42:22 EDT 2012


Author: mikee
Date: 2012-10-02 17:42:22 -0400 (Tue, 02 Oct 2012)
New Revision: 22432
Trac: http://svn.gnucash.org/trac/changeset/22432

Modified:
   gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c
Log:
Fix bug in customer/vendor importer where new customers/vendors
were always created even if one with a matching ID already exists.
The intended behaviour is to update customer or vendor data if
one already exists with a matching ID.

Modified: gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c
===================================================================
--- gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c	2012-10-02 20:12:49 UTC (rev 22431)
+++ gnucash/trunk/src/plugins/customer_import/dialog-customer-import.c	2012-10-02 21:42:22 UTC (rev 22432)
@@ -345,25 +345,29 @@
 
         // Now save it off after checking if a vend/cust number doesn't already exist
         {
-            if (g_ascii_strcasecmp (type, "CUSTOMER") == 0)customer = gnc_search_customer_on_id (book, id);
-            else if (g_ascii_strcasecmp (type, "VENDOR") == 0)vendor = gnc_search_vendor_on_id (book, id);
-            if (!customer || !vendor)
+            if (g_ascii_strcasecmp (type, "CUSTOMER") == 0)
             {
-                if (g_ascii_strcasecmp (type, "CUSTOMER") == 0)
-                {
-                    customer = gncCustomerCreate( book );
-                    gncCustomerSetCurrency( customer, gnc_default_currency() );
+              customer = gnc_search_customer_on_id (book, id);
+              if (!customer)
+              {
+                customer = gncCustomerCreate( book );
+                gncCustomerSetCurrency( customer, gnc_default_currency() );
+                (*n_customers_created)++;
                 }
-                else if (g_ascii_strcasecmp (type, "VENDOR") == 0)
-                {
-                    vendor = gncVendorCreate( book );
-                    gncVendorSetCurrency( vendor, gnc_default_currency() );
+              else (*n_customers_updated)++;
+            }
+            else if (g_ascii_strcasecmp (type, "VENDOR") == 0)
+            {
+              vendor = gnc_search_vendor_on_id (book, id);
+              if ( !vendor)
+              {
+                vendor = gncVendorCreate( book );
+                gncVendorSetCurrency( vendor, gnc_default_currency() );
+                (*n_customers_created)++;
                 }
-
-                (*n_customers_created)++;
+              else (*n_customers_updated)++;
             }
-            else
-                (*n_customers_updated)++;
+            
             if (g_ascii_strcasecmp (type, "CUSTOMER") == 0)
             {
                 gncCustomerBeginEdit (customer);



More information about the gnucash-changes mailing list