r19547 - gnucash/trunk/src/engine - Fix counting of occurrence number w.r.t. the first valid date in the SX state.

Christian Stimming cstim at code.gnucash.org
Sat Sep 4 16:44:59 EDT 2010


Author: cstim
Date: 2010-09-04 16:44:59 -0400 (Sat, 04 Sep 2010)
New Revision: 19547
Trac: http://svn.gnucash.org/trac/changeset/19547

Modified:
   gnucash/trunk/src/engine/SchedXaction.c
Log:
Fix counting of occurrence number w.r.t. the first valid date in the SX state.

Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2010-09-04 20:00:15 UTC (rev 19546)
+++ gnucash/trunk/src/engine/SchedXaction.c	2010-09-04 20:44:59 UTC (rev 19547)
@@ -693,6 +693,7 @@
 {
     gint result = 0;
     SXTmpStateData *tmpState;
+    gboolean countFirstDate;
 
     /* SX still active? If not, return now. */
     if ((xaccSchedXactionHasOccurDef(sx)
@@ -705,6 +706,12 @@
 
     tmpState = gnc_sx_create_temporal_state (sx);
 
+    /* Should we count the first valid date we encounter? Only if the
+     * SX has not yet occurred so far, or if its last valid date was
+     * before the start date. */
+    countFirstDate = !g_date_valid(&tmpState->last_date)
+        || (g_date_compare(&tmpState->last_date, start_date) < 0);
+
     /* No valid date? SX has never occurred so far. */
     if (!g_date_valid(&tmpState->last_date))
     {
@@ -748,6 +755,11 @@
         }
     }
 
+    /* If the first valid date shouldn't be counted, decrease the
+     * result number by one. */
+    if (!countFirstDate && result > 0)
+        --result;
+
     gnc_sx_destroy_temporal_state (tmpState);
     return result;
 }



More information about the gnucash-changes mailing list