2001-06-30 Joshua Sled <jsled@asynchronous.org>

* src/gnome/dialog-scheduledxaction.c (putSchedXactionInClist):
	Fix for next-occurance processing.

	* src/engine/SchedXaction.c (xaccSchedXactionGetNextInstance):
	Better handling of start date/last-occur date/current dates when
	generating the next occurance date.  Gotta remember to clear those
	g_dates, lest the come up 'valid' due to stack trash... :(


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4841 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2001-07-01 00:50:24 +00:00
parent ee1b205286
commit b2f5d19660
6 changed files with 56 additions and 45 deletions

View File

@ -5,7 +5,7 @@ Main Scheduled Transaction todo list
. Engine ...Init() functions should be private.
. FreqSpec.c
. xaccFreqSpecGetFreqStr [display] needs to go away
. xaccFreqSpecGetFreqStr [display] needs to go away [?]
X add the ...GetFreqStr() code for the complex composite FreqSpecs
X fix the ...GetNextInstance() code
@ -47,6 +47,7 @@ X fix GetNextInstance and GetInstanceAfter, mostly for composite FreqSpecs
template-creation time.
. GNCFrequency
. initial-settings synchronization [start date, optionmenus]
. only a couple left; which ones?
. backend support
. PostgreSQL
. others?
@ -57,9 +58,9 @@ Bugs:
. transitioning to a new tab doesn't correctly setup the agreement between
the startdate and the page elements.
. Scheduled Transaction Editor
. auto-shrink on window create [the register is too wide]
. auto-shrink on window create [the register is too wide, leading to too
much whitespace on the two top panels]
. Scheduled Transaction List
. Dates earlier than the start date/today are listed in the "next" column.
Enhancements:
. SX name should be default value for template transaction description

View File

@ -436,12 +436,18 @@ xaccFreqSpecGetNextInstance(
/* This implements || composites. */
guint32 min_julian = 0xFFFFFFFF; /* the biggest unsigned 32 bit number */
guint32 this_julian;
char tmpBuf[25];
DEBUG( "List length: %d", g_list_length( list ) );
do {
GDate next_repeat;
xaccFreqSpecGetNextInstance(
(FreqSpec*) list->data,
in_date,
&next_repeat );
g_date_strftime( tmpBuf, 25, "%a, %b %e, %Y", in_date );
DEBUG( "in date: %s", tmpBuf );
g_date_strftime( tmpBuf, 25, "%a, %b %e, %Y", &next_repeat );
DEBUG( "next repeat: %s", tmpBuf );
this_julian = g_date_julian( &next_repeat );
min_julian = min( min_julian, this_julian );

View File

@ -279,17 +279,49 @@ xaccSchedXactionGetManual( SchedXaction *sx )
GDate
xaccSchedXactionGetNextInstance( SchedXaction *sx )
{
GDate last_occur, next_occur;
GDate last_occur, next_occur, tmpDate;
g_date_clear( &last_occur, 1 );
g_date_clear( &next_occur, 1 );
g_date_clear( &tmpDate, 1 );
if ( g_date_valid( &sx->last_date ) ) {
last_occur = sx->last_date;
} else {
if ( g_date_valid( &sx->start_date ) ) {
last_occur = sx->start_date;
}
if ( g_date_valid( &sx->start_date ) ) {
if ( g_date_valid(&last_occur) ) {
last_occur =
( g_date_compare( &last_occur,
&sx->start_date ) > 0 ?
last_occur : sx->start_date );
} else {
g_date_set_time( &last_occur, time(NULL) );
last_occur = sx->start_date;
}
}
if ( g_date_valid( &last_occur ) ) {
g_date_set_time( &tmpDate, time(NULL) );
last_occur =
( g_date_compare( &last_occur,
&tmpDate ) > 0 ?
last_occur : tmpDate );
} else {
g_date_set_time( &last_occur, time(NULL) );
}
if ( g_date_valid( &sx->start_date )
&& ! g_date_valid( &sx->last_date ) ) {
// Think about this for a second, and you realize
// that if the start date is _today_, we need a
// last-occur date such that the 'next instance' is
// after that date... one day should be good.
//
// This only holds for the first instance [read: if the
// last[-occur]_date is invalid.
g_date_subtract_days( &last_occur, 1 );
}
xaccFreqSpecGetNextInstance( sx->freq, &last_occur, &next_occur );
return next_occur;
}

View File

@ -234,27 +234,6 @@ editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed )
g_date_free( gdate );
/* get the new Split list. */
#if 0
{
GList *splitList;
GList *iter;
splitList = xaccAccountGetSplitList( gncGetTemplateAccount() );
if ( splitList != NULL ) {
printf( "Got the following splits: \n" );
iter = splitList;
do {
printf( "__split: \"%s\"\n",
xaccSplitGetMemo( (Split*)iter->data ) );
} while ((iter = iter->next));
} else {
printf( "Got no splits\n" );
}
xaccSchedXactionSetSplits( sxed->sx, splitList );
}
#endif /* 0 */
/* add to list */
putSchedXactionInClist( sxed->sx, sxed->sxd );
if ( sxed->new ) {
@ -907,7 +886,6 @@ putSchedXactionInClist( gpointer data, gpointer user_data )
time_t nextTime;
GString *nextDate;
time_t now;
struct tm *nowTm;
gint row;
int i;
GDate gd;
@ -921,28 +899,21 @@ putSchedXactionInClist( gpointer data, gpointer user_data )
xaccFreqSpecGetFreqStr( xaccSchedXactionGetFreqSpec(sx), freqStr );
gd = xaccSchedXactionGetNextInstance( sx );
nowTm = g_new0( struct tm, 1 );
if ( ! g_date_valid( &gd ) ) {
g_string_sprintf( nextDate, "not scheduled" );
} else {
g_date_to_struct_tm( &gd, nowTm );
nextTime = mktime( nowTm );
g_free( nowTm );
if ( nextTime == 0 ) {
g_string_sprintf( nextDate, "not scheduled" );
} else {
tmpStr = g_new0( char, 25 );
strftime( tmpStr, 25, "%a, %b %e, %Y", localtime(&nextTime) );
g_string_sprintf( nextDate, "%s", tmpStr );
g_free( tmpStr );
}
char tmpBuf[26];
g_date_strftime( tmpBuf, 25, "%a, %b %e, %Y", &gd );
g_string_sprintf( nextDate, "%s", tmpBuf );
}
text[0] = xaccSchedXactionGetName( sx );
text[1] = freqStr->str;
text[2] = nextDate->str;
/* FIXME: leaky */
/* FIXME: leaky? */
g_string_free( freqStr, FALSE );
g_string_free( nextDate, FALSE );

View File

@ -2788,8 +2788,8 @@ December
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>

View File

@ -637,6 +637,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
str = CHECKBOX_NAMES[i];
o = glade_xml_get_widget( gf->gxml, str );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) {
tmpFS = xaccFreqSpecMalloc();
xaccFreqSpecSetUIType( tmpFS, uift );
/* struct-copy is expected to work, here */