r20306 - gnucash/trunk/src/business/business-ledger - Fix invoice line ordering mismatch between register window and reports.

Christian Stimming cstim at code.gnucash.org
Wed Feb 16 15:47:49 EST 2011


Author: cstim
Date: 2011-02-16 15:47:49 -0500 (Wed, 16 Feb 2011)
New Revision: 20306
Trac: http://svn.gnucash.org/trac/changeset/20306

Modified:
   gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
Log:
Fix invoice line ordering mismatch between register window and reports.

The new code was missing the call to gncInvoiceSortEntries.

Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2011-02-16 20:16:35 UTC (rev 20305)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2011-02-16 20:47:49 UTC (rev 20306)
@@ -941,6 +941,20 @@
     if (!target || target == blank)
         return;
 
+    /* Also, only continue if both have the same date, because the
+     * "standard ordering" is tied to the date anyway. Note: This
+     * unfortunately prevents the user from changing the ordering if
+     * he has chosen a different sort order and the sort key happens
+     * to be equal among the two entries. But I don't know how to look
+     * up the current sort ordering from here, so I cowardly refuse to
+     * tweak the EntryDate in this case. */
+    {
+        Timespec t1 = gncEntryGetDate(current),
+                 t2 = gncEntryGetDate(target);
+        if (!timespec_equal(&t1, &t2))
+            return;
+    }
+
     /*g_warning("Ok, current desc='%s' target desc='%s'",
               gncEntryGetDescription(current),
               gncEntryGetDescription(target));*/
@@ -971,6 +985,11 @@
         /* Write the new DateEntered. */
         gncEntrySetDateEntered(current, time_target);
         gncEntrySetDateEntered(target, time_current);
+
+        /* And finally let the GncInvoice sort its entries
+         * accordingly, so that the invoice reports will give the same
+         * ordering as the register window. */
+        gncInvoiceSortEntries(ledger->invoice);
     }
 
     gnc_resume_gui_refresh ();



More information about the gnucash-changes mailing list