Bug #106401: Add SX weekend occurence to be shifted to weekdays

The RFE wanted to specify the date of a scheduled transaction like this:
At the 15th of each month but if that is a saturday or a sunday then
at the next monday after that (or the friday before)

This patch implements this. The contributer writes:
Aside from some combinations being possible that don't make sense (because I
haven't looked at how to hide the extra combo boxes for them), and some awful
code in recurrenceNextInstance to stop it trying to go backwards (it may make
more sense to store the date that was going to be used next before it's changed
back/forward, so that that can be compared instead), it seems to work ok.

Patch by Simon Arlott.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17725 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2008-11-26 21:17:30 +00:00
parent 35129a333c
commit 8cecfea8da
17 changed files with 369 additions and 72 deletions

View File

@@ -57,12 +57,21 @@ typedef enum {
PERIOD_INVALID = -1,
} PeriodType;
typedef enum {
WEEKEND_ADJ_NONE,
WEEKEND_ADJ_BACK, /* Previous weekday */
WEEKEND_ADJ_FORWARD, /* Next weekday */
NUM_WEEKEND_ADJS,
WEEKEND_ADJ_INVALID = -1,
} WeekendAdjust;
/* Recurrences represent both the phase and period of a recurring event. */
typedef struct {
GDate start; /* First date in the recurrence; specifies phase. */
PeriodType ptype; /* see PeriodType enum */
guint16 mult; /* a period multiplier */
GDate start; /* First date in the recurrence; specifies phase. */
PeriodType ptype; /* see PeriodType enum */
guint16 mult; /* a period multiplier */
WeekendAdjust wadj; /* see WeekendAdjust enum */
} Recurrence;
@@ -90,12 +99,13 @@ typedef struct {
*/
void recurrenceSet(Recurrence *r, guint16 mult, PeriodType pt,
const GDate *date);
const GDate *date, WeekendAdjust wadj);
/* get the fields */
PeriodType recurrenceGetPeriodType(const Recurrence *r);
guint recurrenceGetMultiplier(const Recurrence *r);
GDate recurrenceGetDate(const Recurrence *r);
WeekendAdjust recurrenceGetWeekendAdjust(const Recurrence *r);
/* Get the occurence immediately after refDate.
*
@@ -135,9 +145,11 @@ gnc_numeric recurrenceGetAccountPeriodValue(const Recurrence *r,
void recurrenceListNextInstance(const GList *r, const GDate *refDate,
GDate *nextDate);
/* These two functions are only for xml storage, not user presentation. */
/* These four functions are only for xml storage, not user presentation. */
gchar *recurrencePeriodTypeToString(PeriodType pt);
PeriodType recurrencePeriodTypeFromString(const gchar *str);
gchar *recurrenceWeekendAdjustToString(WeekendAdjust wadj);
WeekendAdjust recurrenceWeekendAdjustFromString(const gchar *str);
/* For debugging. Caller owns the returned string. Not intl. */
gchar *recurrenceToString(const Recurrence *r);