r19757 - gnucash/trunk/src/engine - Fix error in sx_get_num_occur for SX which are limited by num_occur.

Christian Stimming cstim at code.gnucash.org
Fri Nov 5 17:36:58 EDT 2010


Author: cstim
Date: 2010-11-05 17:36:58 -0400 (Fri, 05 Nov 2010)
New Revision: 19757
Trac: http://svn.gnucash.org/trac/changeset/19757

Modified:
   gnucash/trunk/src/engine/SchedXaction.c
Log:
Fix error in sx_get_num_occur for SX which are limited by num_occur.

The last occurrence wasn't counted because it was still valid
but turned num_occur_rem to zero, hence the counting stopped one too early.

Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2010-11-05 21:36:41 UTC (rev 19756)
+++ gnucash/trunk/src/engine/SchedXaction.c	2010-11-05 21:36:58 UTC (rev 19757)
@@ -738,21 +738,21 @@
     }
 
     /* Now we are in our interval of interest. Increment the
-     * occurrence date until we are beyond the end of our interval. */
-    while ((g_date_compare(&tmpState->last_date, end_date) <= 0)
-            && (!xaccSchedXactionHasEndDate(sx)
-                || g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0))
+     * occurrence date until we are beyond the end of our
+     * interval. Make sure to check for invalid dates here: It means
+     * the SX has ended. */
+    while (g_date_valid(&tmpState->last_date)
+           && (g_date_compare(&tmpState->last_date, end_date) <= 0)
+           && (!xaccSchedXactionHasEndDate(sx)
+               || g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0)
+           && (!xaccSchedXactionHasOccurDef(sx)
+               /* The >=0 (i.e. the ==) is important here, otherwise
+                * we miss the last valid occurrence of a SX which is
+                * limited by num_occur */
+               || tmpState->num_occur_rem >= 0))
     {
         ++result;
         gnc_sx_incr_temporal_state (sx, tmpState);
-        /* Make sure to check for invalid dates here: It means the SX
-         * has ended. */
-        if (!g_date_valid(&tmpState->last_date)
-                || (xaccSchedXactionHasOccurDef(sx)
-                    && tmpState->num_occur_rem <= 0))
-        {
-            break;
-        }
     }
 
     /* If the first valid date shouldn't be counted, decrease the



More information about the gnucash-changes mailing list