mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix counting of occurrence number w.r.t. the first valid date in the SX state.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19547 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a4bb22b23c
commit
cee42d59e5
@ -693,6 +693,7 @@ gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_d
|
||||
{
|
||||
gint result = 0;
|
||||
SXTmpStateData *tmpState;
|
||||
gboolean countFirstDate;
|
||||
|
||||
/* SX still active? If not, return now. */
|
||||
if ((xaccSchedXactionHasOccurDef(sx)
|
||||
@ -705,6 +706,12 @@ gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_d
|
||||
|
||||
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 @@ gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_d
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user