mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Added scheduled-transactions module for logging/output purposes, set to 'debug' level.
Added state-getters for FreqSpec types. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4837 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
65b43535d6
commit
9115885ccc
@ -284,6 +284,7 @@ xaccFreqSpecGetNextInstance(
|
||||
|
||||
case DAILY: {
|
||||
guint32 julian_in_date, julian_next_repeat, complete_intervals;
|
||||
|
||||
julian_in_date = g_date_julian( CONST_HACK in_date );
|
||||
complete_intervals =
|
||||
(julian_in_date - fs->s.daily.offset_from_epoch) /
|
||||
@ -299,6 +300,7 @@ xaccFreqSpecGetNextInstance(
|
||||
* of days, not week epoch offset and day in week offset.
|
||||
* It is very similar to the daily repeat representation. */
|
||||
guint32 julian_in_date, julian_next_repeat, complete_intervals;
|
||||
|
||||
julian_in_date = g_date_julian( CONST_HACK in_date );
|
||||
complete_intervals =
|
||||
(julian_in_date - fs->s.weekly.offset_from_epoch) /
|
||||
@ -334,6 +336,7 @@ xaccFreqSpecGetNextInstance(
|
||||
case MONTHLY: {
|
||||
guint32 in_months_from_epoch, after_repeat_in_month_interval,
|
||||
complete_intervals, next_repeat_months_from_epoch, month, year;
|
||||
|
||||
in_months_from_epoch = (g_date_year( CONST_HACK in_date )-1) * 12 +
|
||||
g_date_month( CONST_HACK in_date ) - 1;
|
||||
complete_intervals =
|
||||
@ -370,6 +373,7 @@ xaccFreqSpecGetNextInstance(
|
||||
guint32 in_months_from_epoch, after_repeat_in_month_interval,
|
||||
complete_intervals, next_repeat_months_from_epoch, month, year,
|
||||
wday_of_1st, day_of_repeat;
|
||||
|
||||
GDate date1;
|
||||
in_months_from_epoch = (g_date_year( CONST_HACK in_date )-1) * 12 +
|
||||
g_date_month( CONST_HACK in_date ) - 1;
|
||||
@ -614,6 +618,47 @@ xaccFreqSpecSetComposite( FreqSpec *fs )
|
||||
fs->s.composites.subSpecs = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
xaccFreqSpecGetOnce( FreqSpec *fs, GDate *outGD )
|
||||
{
|
||||
if ( fs->type != ONCE )
|
||||
return -1;
|
||||
*outGD = fs->s.once.date;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xaccFreqSpecGetDaily( FreqSpec *fs, int *outRepeat )
|
||||
{
|
||||
if ( fs->type != DAILY )
|
||||
return -1;
|
||||
*outRepeat = fs->s.daily.interval_days;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xaccFreqSpecGetWeekly( FreqSpec *fs, int *outRepeat, int *outDayOfWeek )
|
||||
{
|
||||
if ( fs->type != WEEKLY )
|
||||
return -1;
|
||||
*outRepeat = fs->s.weekly.interval_weeks;
|
||||
*outDayOfWeek = fs->s.weekly.offset_from_epoch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xaccFreqSpecGetMonthly( FreqSpec *fs, int *outRepeat, int *outDayOfMonth, int *outMonthOffset )
|
||||
{
|
||||
if ( fs->type != MONTHLY )
|
||||
return -1;
|
||||
*outRepeat = fs->s.monthly.interval_months;
|
||||
*outDayOfMonth = fs->s.monthly.day_of_month;
|
||||
*outMonthOffset = fs->s.monthly.offset_from_epoch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: add month-relative getter
|
||||
|
||||
GList*
|
||||
xaccFreqSpecCompositeGet( FreqSpec *fs )
|
||||
{
|
||||
@ -648,11 +693,11 @@ xaccFreqSpecCompositesClear( FreqSpec *fs )
|
||||
void
|
||||
xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
{
|
||||
GList *list;
|
||||
FreqSpec *tmpFS;
|
||||
int tmpInt;
|
||||
char *tmpStr;
|
||||
int i;
|
||||
GList *list;
|
||||
FreqSpec *tmpFS;
|
||||
int tmpInt;
|
||||
char *tmpStr;
|
||||
int i;
|
||||
|
||||
/* FIXME: fill in. */
|
||||
switch( xaccFreqSpecGetUIType( fs ) ) {
|
||||
@ -675,12 +720,23 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
break;
|
||||
|
||||
case UIFREQ_DAILY_MF:
|
||||
g_string_sprintf( str, "Daily [M-F]" );
|
||||
if ( fs->s.weekly.interval_weeks > 1 ) {
|
||||
g_string_sprintfa( str, " (x%u)",
|
||||
fs->s.weekly.interval_weeks );
|
||||
{
|
||||
FreqSpec *subFS;
|
||||
if ( g_list_length( fs->s.composites.subSpecs ) != 5 ) {
|
||||
PERR( "Invalid Daily[M-F] structure." );
|
||||
g_string_sprintf( str, "Daily[M-F]: error" );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
/* We assume that all of the weekly FreqSpecs that make up
|
||||
the Daily[M-F] FreqSpec have the same interval. */
|
||||
subFS = (FreqSpec*)fs->s.composites.subSpecs->data;
|
||||
g_string_sprintf( str, "Daily [M-F]" );
|
||||
if ( subFS->s.weekly.interval_weeks > 1 ) {
|
||||
g_string_sprintfa( str, " (x%u)",
|
||||
subFS->s.weekly.interval_weeks );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case UIFREQ_WEEKLY:
|
||||
g_string_sprintf( str, "Weekly" );
|
||||
@ -692,6 +748,8 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
|
||||
list = xaccFreqSpecCompositeGet( fs );
|
||||
do {
|
||||
int dowIdx;
|
||||
|
||||
tmpFS = (FreqSpec*)list->data;
|
||||
if ( xaccFreqSpecGetType(tmpFS) != WEEKLY ) {
|
||||
g_string_sprintf( str,
|
||||
@ -702,14 +760,9 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
tmpInt = tmpFS->s.weekly.interval_weeks;
|
||||
}
|
||||
/* put the first letter of the weekday name in
|
||||
the appropriate position.
|
||||
|
||||
FIXME: need the offset from the day-of-week
|
||||
of the Julian epoch */
|
||||
/*
|
||||
tmpStr[tmpFS->specData.dateAnchor[1]] =
|
||||
weekDayNames[tmpFS->specData.dateAnchor[1]][0];
|
||||
*/
|
||||
the appropriate position. */
|
||||
dowIdx = tmpFS->s.weekly.offset_from_epoch;
|
||||
tmpStr[dowIdx] = weekDayNames[dowIdx][0];
|
||||
} while ( (list = g_list_next(list)) );
|
||||
|
||||
if ( tmpInt > 1 ) {
|
||||
@ -719,6 +772,10 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
g_free( tmpStr );
|
||||
break;
|
||||
|
||||
case UIFREQ_BI_WEEKLY:
|
||||
g_string_sprintf( str, "Bi-Weekly, %ss", weekDayNames[fs->s.weekly.offset_from_epoch % 7] );
|
||||
break;
|
||||
|
||||
case UIFREQ_SEMI_MONTHLY:
|
||||
g_string_sprintf( str, "Semi-Monthly" );
|
||||
list = xaccFreqSpecCompositeGet( fs );
|
||||
@ -775,10 +832,9 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
g_string_sprintf( str, "Semi-Yearly" );
|
||||
if ( fs->s.monthly.interval_months != 6 ) {
|
||||
if ( (fs->s.monthly.interval_months % 6) != 0 ) {
|
||||
/* FIXME:error */
|
||||
printf( "ERROR: FreqSpec Semi-Yearly month-interval "
|
||||
"is not a multiple of 6 [%d]",
|
||||
fs->s.monthly.interval_months );
|
||||
PERR( "ERROR: FreqSpec Semi-Yearly month-interval "
|
||||
"is not a multiple of 6 [%d]",
|
||||
fs->s.monthly.interval_months );
|
||||
}
|
||||
g_string_sprintfa( str, " (x%u)",
|
||||
fs->s.monthly.interval_months/6 );
|
||||
@ -791,17 +847,15 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
|
||||
g_string_sprintf( str, "Yearly" );
|
||||
if ( fs->s.monthly.interval_months != 12 ) {
|
||||
if ( (fs->s.monthly.interval_months % 12) != 0 ) {
|
||||
/* FIXME:error */
|
||||
printf( "ERROR: \"Yearly\" FreqSpec month-interval "
|
||||
"is not a multiple of 12 [%d]",
|
||||
fs->s.monthly.interval_months );
|
||||
PERR( "ERROR: \"Yearly\" FreqSpec month-interval "
|
||||
"is not a multiple of 12 [%d]",
|
||||
fs->s.monthly.interval_months );
|
||||
}
|
||||
g_string_sprintfa( str, " (x%u)",
|
||||
fs->s.monthly.interval_months/12 );
|
||||
}
|
||||
g_string_sprintfa( str, ": %s/%u",
|
||||
/* FIXME: need the year-of-month value. */
|
||||
monthInfo[/*fs->specData.dateAnchor[2]*/ 0].dshort,
|
||||
monthInfo[fs->s.monthly.offset_from_epoch].dshort,
|
||||
fs->s.monthly.day_of_month );
|
||||
break;
|
||||
|
||||
|
@ -185,6 +185,13 @@ void xaccFreqSpecSetComposite( FreqSpec *fs );
|
||||
**/
|
||||
void xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str );
|
||||
|
||||
int xaccFreqSpecGetOnce( FreqSpec *fs, GDate *outGD );
|
||||
int xaccFreqSpecGetDaily( FreqSpec *fs, int *outRepeat );
|
||||
int xaccFreqSpecGetWeekly( FreqSpec *fs, int *outRepeat, int *outDayOfWeek );
|
||||
int xaccFreqSpecGetMonthly( FreqSpec *fs, int *outRepeat,
|
||||
int *outDayOfMonth, int *outMonthOffset );
|
||||
// FIXME: add month-relative
|
||||
|
||||
/**
|
||||
* Returns the list of FreqSpecs in a COMPOSITE FreqSpec.
|
||||
* It is an error to use this if the type is not COMPOSITE.
|
||||
|
@ -61,66 +61,50 @@ struct gncp_freq_spec {
|
||||
UIFreqType uift;
|
||||
union u {
|
||||
struct {
|
||||
GDate date; /** The date on which the single event occurs. */
|
||||
/** The date on which the single event occurs. */
|
||||
GDate date;
|
||||
} once;
|
||||
struct {
|
||||
guint interval_days; /** number of days from one repeat to the next. */
|
||||
guint offset_from_epoch; /** epoch is defined by glib to be 1/1/1. Offset measured in days. 0 <= offset < interval */
|
||||
/** number of days from one repeat to the next. */
|
||||
guint interval_days;
|
||||
/** epoch is defined by glib to be 1/1/1. Offset
|
||||
measured in days. 0 <= offset < interval */
|
||||
guint offset_from_epoch;
|
||||
} daily;
|
||||
struct {
|
||||
/* A week here is measured as 7 days. The first week starts at epoch.
|
||||
* 1/1/1 was a ?. */
|
||||
guint interval_weeks; /** number of weeks from one repeat to the next. */
|
||||
guint offset_from_epoch; /* offset measured in days.
|
||||
* This combines the week
|
||||
* offset and the day of the
|
||||
* week offset. */
|
||||
|
||||
/** number of weeks from one repeat to the next. */
|
||||
guint interval_weeks;
|
||||
/* offset measured in days. This combines the week
|
||||
* offset and the day of the week offset. */
|
||||
guint offset_from_epoch;
|
||||
/* guint offset_from_epoch;*/ /* offset measured in weeks, 0 <= offset < interval */
|
||||
/* guint day_of_week;*/ /* I'm not sure what days each value represents, but it's not important. */
|
||||
} weekly;
|
||||
struct {
|
||||
guint interval_months; /** number of months from one repeat to the next. */
|
||||
guint offset_from_epoch; /* offset measured in months */
|
||||
guint day_of_month; /* Which day of the month it occurs on. */
|
||||
/** number of months from one repeat to the next. */
|
||||
guint interval_months;
|
||||
/* offset measured in months */
|
||||
guint offset_from_epoch;
|
||||
/* Which day of the month it occurs on. */
|
||||
guint day_of_month;
|
||||
} monthly;
|
||||
struct {
|
||||
guint interval_months; /** Number of months from one repeat to the next. */
|
||||
guint offset_from_epoch; /* offset measured in months */
|
||||
guint weekday; /* stores a value equivalent to a GDateWeekday. */
|
||||
guint occurrence; /* the 1st occurrence to the 5th occurrence. */
|
||||
/** Number of months from one repeat to the next. */
|
||||
guint interval_months;
|
||||
/* offset measured in months */
|
||||
guint offset_from_epoch;
|
||||
/* stores a value equivalent to a GDateWeekday. */
|
||||
guint weekday;
|
||||
/* the 1st occurrence to the 5th occurrence. */
|
||||
guint occurrence;
|
||||
} month_relative;
|
||||
struct {
|
||||
/** A list of specs for a composite freq. */
|
||||
GList *subSpecs;
|
||||
} composites;
|
||||
/**
|
||||
* The dateAnchor anchors the spec to determinable days.
|
||||
*
|
||||
* ONCE:
|
||||
* dA[0] contains time_t
|
||||
* DAILY:
|
||||
* dA[0] contains day multiplier
|
||||
* dA[1] contains offset from epoch.
|
||||
* WEEKLY:
|
||||
* dA[0] contains week multiplier
|
||||
* dA[1] contains 0..6 [sun-based]
|
||||
* SEMI_MONTHLY: bstanley disused...
|
||||
* dA[0] contains month multiplier
|
||||
* dA[1] contains the first date-of-month,
|
||||
* dA[2] the second.
|
||||
* MONTHLY:
|
||||
* dA[0] contains month multiplier
|
||||
* dA[1] contains the date-of-month
|
||||
* MONTH_RELATIVE:
|
||||
* dA[0] continas month multiplier
|
||||
* dA[1] contains week number [1..5, 6=="last"]
|
||||
* [1..5 is really 1..4.428 [31/7], but it's a UI issue]
|
||||
* dA[2] contains 0..6 [sun-based day of week]
|
||||
* COMPOSITE:
|
||||
* ... list ...
|
||||
* RELATIVE:
|
||||
* ... don't know yet ...
|
||||
**/
|
||||
} s;
|
||||
GUID guid;
|
||||
};
|
||||
|
@ -62,6 +62,7 @@ static gncLogLevel loglevel[MOD_LAST + 1] =
|
||||
GNC_LOG_WARNING, /* EVENT */
|
||||
GNC_LOG_WARNING, /* TXN */
|
||||
GNC_LOG_WARNING, /* KVP */
|
||||
GNC_LOG_DEBUG, /* SX */
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
/** DEBUGGING MACROS ************************************************/
|
||||
/* The debuging macros enable the setting of trace messages */
|
||||
|
||||
/** If you modify this, modify the loglevel table in the .c file. */
|
||||
typedef enum
|
||||
{
|
||||
MOD_DUMMY = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user