diff --git a/src/doc/TODO-schedxactions b/src/doc/TODO-schedxactions index 6ba614ae2f..306e3b0539 100644 --- a/src/doc/TODO-schedxactions +++ b/src/doc/TODO-schedxactions @@ -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 diff --git a/src/engine/FreqSpec.c b/src/engine/FreqSpec.c index 0f7d5c2305..50db916fbb 100644 --- a/src/engine/FreqSpec.c +++ b/src/engine/FreqSpec.c @@ -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 ); diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c index fcf6445b36..9a86f7b170 100644 --- a/src/engine/SchedXaction.c +++ b/src/engine/SchedXaction.c @@ -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; } diff --git a/src/gnome/dialog-scheduledxaction.c b/src/gnome/dialog-scheduledxaction.c index 1894a6e6c2..a4925f592e 100644 --- a/src/gnome/dialog-scheduledxaction.c +++ b/src/gnome/dialog-scheduledxaction.c @@ -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 ); diff --git a/src/gnome/glade/sched-xact.glade b/src/gnome/glade/sched-xact.glade index 459f2a5319..415102ef1f 100644 --- a/src/gnome/glade/sched-xact.glade +++ b/src/gnome/glade/sched-xact.glade @@ -2788,8 +2788,8 @@ December 0 0 - True - True + False + False diff --git a/src/gnome/gnc-frequency.c b/src/gnome/gnc-frequency.c index 81303863fb..f2902f7833 100644 --- a/src/gnome/gnc-frequency.c +++ b/src/gnome/gnc-frequency.c @@ -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 */