r21562 - gnucash/trunk/src/business/business-ledger - Fix occasional not working "up / down" arrow in invoice window.

Christian Stimming cstim at code.gnucash.org
Fri Nov 11 16:58:37 EST 2011


Author: cstim
Date: 2011-11-11 16:58:36 -0500 (Fri, 11 Nov 2011)
New Revision: 21562
Trac: http://svn.gnucash.org/trac/changeset/21562

Modified:
   gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
Log:
Fix occasional not working "up / down" arrow in invoice window.

This was because the "date" field was indeed be set with a different
time of day (noon vs. start of day), depending on the various code
places.

Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2011-11-11 21:58:21 UTC (rev 21561)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.c	2011-11-11 21:58:36 UTC (rev 21562)
@@ -1004,10 +1004,26 @@
      * 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);
+        Timespec t1, t2;
+        GDate d1 = gncEntryGetDateGDate(current),
+              d2 = gncEntryGetDateGDate(target);
+        if (g_date_compare(&d1, &d2) != 0)
+            return;
+
+        /* Special treatment if the equality doesn't hold if we access the
+        dates as timespec. See the comment in gncEntrySetDateGDate() for the
+        reason: Some code used the timespec at noon for the EntryDate, other
+        code used the timespec at the start of day. */
+        t1 = gncEntryGetDate(current);
+        t2 = gncEntryGetDate(target);
         if (!timespec_equal(&t1, &t2))
-            return;
+        {
+            /* Timespecs are not equal, even though the GDates were equal? Then
+            we set the GDates again. This will force the timespecs to be equal
+            as well. */
+            gncEntrySetDateGDate(current, &d1);
+            gncEntrySetDateGDate(target, &d2);
+        }
     }
 
     /*g_warning("Ok, current desc='%s' target desc='%s'",



More information about the gnucash-changes mailing list