From 8117a7c17f5c993965a5cc2247a18b563af503d7 Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Wed, 16 Mar 2016 12:18:26 +0000 Subject: [PATCH] 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. --- src/business/business-gnome/dialog-invoice.c | 26 +++++++++++++++++++- src/engine/gncInvoice.c | 3 ++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index c5b2b6e74e..b522a94ffc 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 9b9fed4938..50f3373bfe 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);