gnucash maint: Bug 754209 - Bills can be posted from "find bill" search results even if bill is already posted and results in extra $ posted to A/P

Mike Evans mikee at code.gnucash.org
Wed Mar 16 10:44:26 EDT 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/8117a7c1 (commit)
	from  https://github.com/Gnucash/gnucash/commit/1121cd07 (commit)



commit 8117a7c17f5c993965a5cc2247a18b563af503d7
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Wed Mar 16 12:18:26 2016 +0000

    Bug 754209 - Bills can be posted from "find bill" search results
    even if bill is already posted and results in extra $ posted to A/P
    
    This adds a test in gncInvoice to return NULL it already posted.
    
    Adds checks in dialog-invoice to test for already posted invoices. Messages
    user and refuses to post entire selection if more than one selected.
    
    Translators: This adds a message string.

diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c
index c5b2b6e..b522a94 100644
--- a/src/business/business-gnome/dialog-invoice.c
+++ b/src/business/business-gnome/dialog-invoice.c
@@ -2886,17 +2886,41 @@ static void post_one_invoice_cb(gpointer data, gpointer user_data)
     gnc_invoice_post(iw, post_params);
 }
 
+static void gnc_invoice_is_posted(gpointer inv, gpointer test_value)
+{
+    GncInvoice *invoice = inv;
+    gboolean *test = (gboolean*)test_value;
+      
+    if (gncInvoiceIsPosted (invoice))
+    {
+        *test = TRUE;
+    }
+}
+
+
 static void
 multi_post_invoice_cb (GList *invoice_list, gpointer user_data)
 {
     struct post_invoice_params post_params;
+    gboolean test;
     InvoiceWindow *iw;
 
     if (g_list_length(invoice_list) == 0)
         return;
-
     // Get the posting parameters for these invoices
     iw = gnc_ui_invoice_edit(invoice_list->data);
+    test = FALSE;
+    gnc_suspend_gui_refresh (); // Turn off GUI refresh for the duration.
+    // Check if any of the selected invoices have already been posted.
+    g_list_foreach(invoice_list, gnc_invoice_is_posted, &test);
+    gnc_resume_gui_refresh ();
+    if (test)
+    {
+        gnc_error_dialog (iw_get_window(iw), "%s",
+                          _("One or more selected invoices have already been posted.\nRe-check you selection."));
+        return;
+    }
+    
     if (!gnc_dialog_post_invoice(iw, _("Do you really want to post these invoices?"),
                                  &post_params.ddue, &post_params.postdate,
                                  &post_params.memo, &post_params.acc,
diff --git a/src/engine/gncInvoice.c b/src/engine/gncInvoice.c
index 9b9fed4..50f3373 100644
--- a/src/engine/gncInvoice.c
+++ b/src/engine/gncInvoice.c
@@ -1389,7 +1389,8 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
     const GncOwner *owner;
 
     if (!invoice || !acc) return NULL;
-
+    if (gncInvoiceIsPosted (invoice)) return NULL;
+    
     gncInvoiceBeginEdit (invoice);
     book = qof_instance_get_book(invoice);
 



Summary of changes:
 src/business/business-gnome/dialog-invoice.c | 26 +++++++++++++++++++++++++-
 src/engine/gncInvoice.c                      |  3 ++-
 2 files changed, 27 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list