gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Fri Aug 31 15:01:49 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/caaf9edc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/baf933ac (commit)
	from  https://github.com/Gnucash/gnucash/commit/1239876b (commit)



commit caaf9edc45ad573b0692bb1a2cde3a38901a5abf
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Fri Aug 31 20:57:12 2018 +0200

    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.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 8c2ece9..c8aa241 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);

commit baf933acf2c088e149bc00c90865f5e8ae08dd3d
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Fri Aug 31 20:24:39 2018 +0200

    Bug 796054 - unposting and reposting invoice doubles amounts
    
    Add scrub function to unblock the double post transaction

diff --git a/libgnucash/engine/ScrubBusiness.c b/libgnucash/engine/ScrubBusiness.c
index a2f421e..44e0eb4 100644
--- a/libgnucash/engine/ScrubBusiness.c
+++ b/libgnucash/engine/ScrubBusiness.c
@@ -518,7 +518,6 @@ gncScrubBusinessLot (GNCLot *lot)
 gboolean
 gncScrubBusinessSplit (Split *split)
 {
-    const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
     Transaction *txn;
     gboolean deleted_split = FALSE;
 
@@ -532,6 +531,8 @@ gncScrubBusinessSplit (Split *split)
         const gchar *read_only = xaccTransGetReadOnly (txn);
         gboolean is_void = xaccTransGetVoidStatus (txn);
         GNCLot *lot = xaccSplitGetLot (split);
+        GncInvoice *invoice = gncInvoiceGetInvoiceFromTxn (txn);
+        Transaction *posted_txn = gncInvoiceGetPostedTxn (invoice);
 
         /* Look for transactions as a result of double posting an invoice or bill
          * Refer to https://bugs.gnucash.org/show_bug.cgi?id=754209
@@ -544,6 +545,7 @@ gncScrubBusinessSplit (Split *split)
          */
         if ((txntype == TXN_TYPE_NONE) && read_only && !is_void && lot)
         {
+            const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
             gchar *txn_date = qof_print_date (xaccTransGetDateEntered (txn));
             xaccTransClearReadOnly (txn);
             xaccSplitSetMemo (split, memo);
@@ -554,6 +556,28 @@ gncScrubBusinessSplit (Split *split)
                   txn_date);
             g_free (txn_date);
         }
+        /* Next check for transactions which claim to be the posted transaction of
+         * an invoice but the invoice disagrees. In that case
+         */
+        else if (invoice && (txn != posted_txn))
+        {
+            const gchar *memo = _("Please delete this transaction. Explanation at https://wiki.gnucash.org/wiki/Business_Features_Issues#Double_posting");
+            gchar *txn_date = qof_print_date (xaccTransGetDateEntered (txn));
+            xaccTransClearReadOnly (txn);
+            xaccTransSetTxnType (txn, TXN_TYPE_NONE);
+            xaccSplitSetMemo (split, memo);
+            if (lot)
+            {
+                gnc_lot_remove_split (lot, split);
+                gncInvoiceDetachFromLot (lot);
+                gncOwnerAttachToLot (gncInvoiceGetOwner(invoice), lot);
+            }
+            PWARN("Cleared double post status of transaction \"%s\", dated %s. "
+            "Please delete transaction and verify balance.",
+            xaccTransGetDescription (txn),
+                  txn_date);
+            g_free (txn_date);
+        }
         /* Next delete any empty splits that aren't part of an invoice transaction
          * Such splits may be the result of scrubbing the business lots, which can
          * merge splits together while reducing superfluous lot links



Summary of changes:
 gnucash/gnome/dialog-invoice.c    | 16 ++++++----------
 libgnucash/engine/ScrubBusiness.c | 26 +++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 11 deletions(-)



More information about the gnucash-changes mailing list