gnucash maint: Multiple changes pushed

Mike Evans mikee at code.gnucash.org
Mon Jun 2 12:09:19 EDT 2014


Updated	 via  https://github.com/Gnucash/gnucash/commit/620114af (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f3e76fb9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/72911a7c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5336a431 (commit)
	from  https://github.com/Gnucash/gnucash/commit/8a45ce41 (commit)



commit 620114af4940eec8edf87de6d61d7255ce706462
Merge: f3e76fb 8a45ce4
Author: Mike Evans <mikee at millstreamcomputing.co.uk>
Date:   Mon Jun 2 17:22:29 2014 +0100

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


commit f3e76fb9df0c4b1276909a8f33421ee6c79f5455
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Jun 1 11:39:31 2014 -0700

    722200 - configure script does not pick the correct am_cv_scanf version
    
    Add -Wall -Werror to CFLAGS to try to force failure.

diff --git a/configure.ac b/configure.ac
index 812da91..0feb2c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -393,11 +393,14 @@ update to latest  darwin])
         LIBS="${saved_LIBS}"
         AC_SUBST(HTMLHELP_LIBS)
 
+	saved_CFLAGS="${CFLAGS}"
+	CFLAGS="${CFLAGS} -Wall -Werror"
 	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
 #include <stdio.h>
 	 ], [
     printf("%lld\n", 3);
          ])],[],[AC_DEFINE([__USE_MINGW_ANSI_STDIO], 1, [MinGW needs ANSI_STDIO hack.])])
+	CFLAGS="${saved_CFLAGS}"
         ;;
       *)
         AC_MSG_RESULT(no)

commit 72911a7caa984e9abb1fe090e8c84b2b33ac8a8b
Author: Mike Evans <mikee at millstreamcomputing.co.uk>
Date:   Mon Jun 2 17:13:32 2014 +0100

    Add some date format checking and make sure generated dates are the
    correct user selected format, not always locale format.

diff --git a/src/plugins/bi_import/dialog-bi-import-helper.c b/src/plugins/bi_import/dialog-bi-import-helper.c
index cddd353..9a0a48c 100644
--- a/src/plugins/bi_import/dialog-bi-import-helper.c
+++ b/src/plugins/bi_import/dialog-bi-import-helper.c
@@ -24,6 +24,7 @@
 #endif
 
 #include "dialog-bi-import-helper.h"
+#include <ctype.h>
 
 //! \brief helper function
 gboolean text2bool( const gchar *text )
@@ -43,6 +44,23 @@ gboolean text2bool( const gchar *text )
     return erg;
 }
 
+
+//! \brief helper function
+// Try to make a valid tm using the user set date format.  Return false if it fails.
+gboolean
+isDateValid(char * date_string)
+{
+    char  *tmp;
+    const gchar* date_format_string = qof_date_format_get_string (qof_date_format_get()); // Get the user set date format string
+    
+    struct tm time_struct;
+    memset(&time_struct, 0, sizeof(struct tm));
+
+   tmp = strptime(date_string, date_format_string, &time_struct);
+   if (tmp == NULL) return FALSE;
+   return TRUE; 
+}
+
 //! \brief helper function
 GncAmountType text2disc_type( const gchar *text )
 {
diff --git a/src/plugins/bi_import/dialog-bi-import-helper.h b/src/plugins/bi_import/dialog-bi-import-helper.h
index 8e7be3a..402752b 100644
--- a/src/plugins/bi_import/dialog-bi-import-helper.h
+++ b/src/plugins/bi_import/dialog-bi-import-helper.h
@@ -31,3 +31,4 @@
 gboolean text2bool( const gchar *text );
 GncAmountType text2disc_type( const gchar *text );
 GncDiscountHow text2disc_how( const gchar *text );
+gboolean isDateValid(char * date_string);
diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c
index a75c9f9..ad91f55 100644
--- a/src/plugins/bi_import/dialog-bi-import.c
+++ b/src/plugins/bi_import/dialog-bi-import.c
@@ -233,11 +233,16 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
 {
     GtkTreeIter iter;
     gboolean valid, row_deleted, row_fixed;
-    gchar *id, *date_opened, *date_posted, *owner_id, *date, *quantity, *price;
+    gchar *id, *date_opened, *date_posted, *due_date, *owner_id, *date, *quantity, *price;
     GString *prev_id, *prev_date_opened, *prev_date_posted, *prev_owner_id, *prev_date;	// needed to fix multi line invoices
     guint dummy;
     gint row = 1;
+    const gchar* date_format_string = qof_date_format_get_string (qof_date_format_get()); // Get the user set date format string
+    
+    
+    //date_format_string = qof_date_format_get_string (qof_date_format_get());	
 
+    DEBUG("date_format_string: %s",date_format_string);
     // allow the call to this function with only GtkListeStore* specified
     if (!fixed)
         fixed = &dummy;
@@ -265,6 +270,7 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
                             ID, &id,
                             DATE_OPENED, &date_opened,
                             DATE_POSTED, &date_posted,
+                            DUE_DATE, &due_date,
                             OWNER_ID, &owner_id,
                             DATE, &date,
                             QUANTITY, &quantity, PRICE, &price, -1);
@@ -279,6 +285,7 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
                                     _("ROW %d DELETED, PRICE_NOT_SET: id=%s\n"),
                                     row, id);
         }
+        // TODO: QTY get set to 1 later if field is empty.  Delete this section?
         else if (strlen (quantity) == 0)
         {
             // invalid row (no quantity given)
@@ -324,7 +331,7 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
         {
             // the row is valid (price and id are valid)
 
-            if (strlen (date_opened) == 0)
+            if(!isDateValid(date_opened))
             {
                 if (prev_date_opened->len == 0)
                 {
@@ -333,7 +340,7 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
                     GDate date;
                     g_date_clear (&date, 1);
                     gnc_gdate_set_today (&date);
-                    g_date_strftime (temp, 20, "%x", &date);	// create a locale specific date string
+                    g_date_strftime (temp, 20, date_format_string, &date);	// Create a user specified date string.
                     g_string_assign (prev_date_opened, temp);
                 }
                 // fix this by using the previous date_opened value (multi line invoice)
@@ -349,8 +356,8 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
 
             // date_opened is valid
 
-            if (strlen (date_posted) == 0)
-            {
+             if(!isDateValid(date_posted))
+             {
                 if (prev_date_posted->len == 0)
                 {
                     // this invoice will have to get posted manually
@@ -370,13 +377,25 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
             }
 
             // date_posted is valid
-
+            /*
+            // Check if due date is valid.  Set it to date_posted if not valid or missing.
+            if(!isDateValid(due_date))
+            {
+                gtk_list_store_set (store, &iter, DUE_DATE,
+                                        date_posted, -1);
+                row_fixed = TRUE;
+                
+            }
+            
+            // due_date is valid
+            */
             if (strlen (quantity) == 0)
             {
                 // quantity is unset => set to 1
                 gtk_list_store_set (store, &iter, QUANTITY, "1", -1);
                 row_fixed = TRUE;
             }
+            
 
             // quantity is valid
 
@@ -566,12 +585,12 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
             invoice = gnc_search_bill_on_id (book, id);
         else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
             invoice = gnc_search_invoice_on_id (book, id);
-        PINFO( "Existing %s ID: %s\n", type, gncInvoiceGetID(invoice));
+        DEBUG( "Existing %s ID: %s\n", type, gncInvoiceGetID(invoice));
 
         // If the search is empty then there is no existing invoice so make a new one
         if (invoice == NULL)
         {
-             PINFO( "Creating a new : %s\n", type );
+             DEBUG( "Creating a new : %s\n", type );
             // new invoice
             invoice = gncInvoiceCreate (book);
             /* Protect against thrashing the DB and trying to write the invoice
@@ -756,14 +775,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                                          text2bool (accumulatesplits),
                                          auto_pay);
             }
-            else
-            {
-                PERR("Date format invalid in invoice import CSV.");
-                // Also report to user in dialog.
-                g_string_append_printf (info,
-                                        _("Date format invalid in invoice import CSV.")
-                                        );
-            }
+
         }
         g_free (new_id);
         

commit 5336a43118c5f189a64b51d297e37fa5703be8be
Author: Mike Evans <mikee at millstreamcomputing.co.uk>
Date:   Mon Jun 2 13:15:09 2014 +0100

    Relax requirements for booleans in invoice line.
    
    Accept 'y' as well as 'yes', 't' as well as true.

diff --git a/src/plugins/bi_import/dialog-bi-import-gui.c b/src/plugins/bi_import/dialog-bi-import-gui.c
index 9541eec..6c3c772 100644
--- a/src/plugins/bi_import/dialog-bi-import-gui.c
+++ b/src/plugins/bi_import/dialog-bi-import-gui.c
@@ -205,7 +205,7 @@ gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
         if (info->len > 0)
             gnc_info_dialog (gui->dialog, "%s", info->str);
         g_string_free( info, TRUE );
-        gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type, gui->open_mode);
+        gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type, gui->open_mode, info);
         gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n   %u fixes\n   %u ignored (not fixable)\n\n   %u created\n   %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
 
         if (stats.n_ignored > 0)
diff --git a/src/plugins/bi_import/dialog-bi-import-helper.c b/src/plugins/bi_import/dialog-bi-import-helper.c
index 7e74a4e..cddd353 100644
--- a/src/plugins/bi_import/dialog-bi-import-helper.c
+++ b/src/plugins/bi_import/dialog-bi-import-helper.c
@@ -36,7 +36,7 @@ gboolean text2bool( const gchar *text )
 
     temp = g_strdup( text );
     g_strstrip( temp );
-    if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
+    if ((g_ascii_strncasecmp( temp, "y",1 ) == 0) || (g_ascii_strncasecmp( temp, "t",1 ) == 0) ||
             (g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
         erg = TRUE;
     g_free( temp );
diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c
index c990413..a75c9f9 100644
--- a/src/plugins/bi_import/dialog-bi-import.c
+++ b/src/plugins/bi_import/dialog-bi-import.c
@@ -289,7 +289,7 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
                                     row, id);
         }
         else
-        {
+        {   // TODO: If id is empty get the next one in the series.  Bug 731105 
             if (strlen (id) == 0)
             {
                 // no invoice id specified
@@ -488,7 +488,7 @@ void
 gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                           guint * n_invoices_created,
                           guint * n_invoices_updated,
-                          gchar * type, gchar * open_mode )
+                          gchar * type, gchar * open_mode, GString * info)
 {
     gboolean valid;
     GtkTreeIter iter;
@@ -508,6 +508,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
     GtkWidget *dialog;
     Timespec today;
     InvoiceWindow *iw;
+    gchar *new_id = NULL;
 
     // these arguments are needed
     g_return_if_fail (store && book);
@@ -726,38 +727,46 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
         valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
 
         // handle auto posting of invoices
+    
+        
+        if (valid)
+            gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &new_id, -1);
+        if (g_strcmp0 (id, new_id) != 0)
         {
-            gchar *new_id = NULL;
-            if (valid)
-                gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, ID, &new_id, -1);
-            if (g_strcmp0 (id, new_id) != 0)
+            // the next invoice id is different => try to autopost this invoice
+            if (qof_scan_date (date_posted, &day, &month, &year))
             {
-                // the next invoice id is different => try to autopost this invoice
-                if (qof_scan_date (date_posted, &day, &month, &year))
-                {
-                    // autopost this invoice
-                    gboolean auto_pay;
-                    Timespec d1, d2;
-
-                    if (g_ascii_strcasecmp (type, "INVOICE") == 0)
-                        auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_AUTO_PAY);
-                    else
-                        auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
-
-                    d1 = gnc_dmy2timespec (day, month, year);
-                    // FIXME: Must check for the return value of qof_scan_date!
-                    qof_scan_date (due_date, &day, &month, &year);	// obtains the due date, or leaves it at date_posted
-                    d2 = gnc_dmy2timespec (day, month, year);
-                    acc = gnc_account_lookup_for_register
-                          (gnc_get_current_root_account (), account_posted);
-                    gncInvoicePostToAccount (invoice, acc, &d1, &d2,
-                                             memo_posted,
-                                             text2bool (accumulatesplits),
-                                             auto_pay);
-                }
+                // autopost this invoice
+                gboolean auto_pay;
+                Timespec d1, d2;
+
+                if (g_ascii_strcasecmp (type, "INVOICE") == 0)
+                    auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_AUTO_PAY);
+                else
+                    auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
+
+                d1 = gnc_dmy2timespec (day, month, year);
+                // FIXME: Must check for the return value of qof_scan_date!
+                qof_scan_date (due_date, &day, &month, &year);	// obtains the due date, or leaves it at date_posted
+                d2 = gnc_dmy2timespec (day, month, year);
+                acc = gnc_account_lookup_for_register
+                      (gnc_get_current_root_account (), account_posted);
+                gncInvoicePostToAccount (invoice, acc, &d1, &d2,
+                                         memo_posted,
+                                         text2bool (accumulatesplits),
+                                         auto_pay);
+            }
+            else
+            {
+                PERR("Date format invalid in invoice import CSV.");
+                // Also report to user in dialog.
+                g_string_append_printf (info,
+                                        _("Date format invalid in invoice import CSV.")
+                                        );
             }
-            g_free (new_id);
         }
+        g_free (new_id);
+        
 
         // cleanup
         g_free (id);
diff --git a/src/plugins/bi_import/dialog-bi-import.h b/src/plugins/bi_import/dialog-bi-import.h
index 162abf8..f03af05 100644
--- a/src/plugins/bi_import/dialog-bi-import.h
+++ b/src/plugins/bi_import/dialog-bi-import.h
@@ -68,7 +68,7 @@ void
 gnc_bi_import_fix_bis (GtkListStore *store, guint *fixed, guint *deleted, GString *info, gchar *type);
 
 void
-gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated,	gchar *type, gchar *open_mode);
+gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated,	gchar *type, gchar *open_mode, GString * info);
 
 
 G_END_DECLS



Summary of changes:
 src/plugins/bi_import/dialog-bi-import-gui.c    |  2 +-
 src/plugins/bi_import/dialog-bi-import-helper.c | 20 ++++-
 src/plugins/bi_import/dialog-bi-import-helper.h |  1 +
 src/plugins/bi_import/dialog-bi-import.c        | 97 +++++++++++++++----------
 src/plugins/bi_import/dialog-bi-import.h        |  2 +-
 5 files changed, 81 insertions(+), 41 deletions(-)



More information about the gnucash-changes mailing list