From caaf9edc45ad573b0692bb1a2cde3a38901a5abf Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 31 Aug 2018 20:57:12 +0200 Subject: [PATCH] Use one single function to determine if an invoice is posted to ensure consistent behaviour While debugging for bug 796054 I found cases where an invoice was unposted, but the toolbar buttons and menu items were configured for a posted invoice. This should now be solved. --- gnucash/gnome/dialog-invoice.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 8c2ece9f8f..c8aa241294 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -1747,7 +1747,6 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget) GtkTextBuffer* text_buffer; const char *string; gchar * tmp_string; - Account *acct; time64 time; gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice)); @@ -1800,16 +1799,13 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget) /* * Next, figure out if we've been posted, and if so set the appropriate - * bits of information.. Then work on hiding or showing as - * necessary. This duplicates the logic in gncInvoiceIsPosted, but we - * need the accout pointer. + * bits of information... Then work on hiding or showing as + * necessary. */ - - acct = gncInvoiceGetPostedAcc (invoice); - if (acct) + is_posted = gncInvoiceIsPosted (invoice); + if (is_posted) { - /* Ok, it's definitely posted. Setup the 'posted-invoice' fields now */ - is_posted = TRUE; + Account *acct = gncInvoiceGetPostedAcc (invoice); /* Can we unpost this invoice? * XXX: right now we always can, but there @@ -1851,7 +1847,7 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget) { GtkWidget *hide, *show; - if (is_posted == TRUE) + if (is_posted) { hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide3")); gtk_widget_hide (hide);