mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-10-12 17:32:00 -05:00
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:
1 parent
ee1b205286
commit
b2f5d19660
6 files changed
+56
-45
No files matched your search
@@ -5,7 +5,7 @@ Main Scheduled Transaction todo list
|
|||||||
|
|
||||||
. Engine ...Init() functions should be private.
|
. Engine ...Init() functions should be private.
|
||||||
. FreqSpec.c
|
. 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 add the ...GetFreqStr() code for the complex composite FreqSpecs
|
||||||
X fix the ...GetNextInstance() code
|
X fix the ...GetNextInstance() code
|
||||||
@@ -47,6 +47,7 @@ X fix GetNextInstance and GetInstanceAfter, mostly for composite FreqSpecs
|
|||||||
template-creation time.
|
template-creation time.
|
||||||
. GNCFrequency
|
. GNCFrequency
|
||||||
. initial-settings synchronization [start date, optionmenus]
|
. initial-settings synchronization [start date, optionmenus]
|
||||||
|
. only a couple left; which ones?
|
||||||
. backend support
|
. backend support
|
||||||
. PostgreSQL
|
. PostgreSQL
|
||||||
. others?
|
. others?
|
||||||
@@ -57,9 +58,9 @@ Bugs:
|
|||||||
. transitioning to a new tab doesn't correctly setup the agreement between
|
. transitioning to a new tab doesn't correctly setup the agreement between
|
||||||
the startdate and the page elements.
|
the startdate and the page elements.
|
||||||
. Scheduled Transaction Editor
|
. 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
|
. Scheduled Transaction List
|
||||||
. Dates earlier than the start date/today are listed in the "next" column.
|
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
. SX name should be default value for template transaction description
|
. SX name should be default value for template transaction description
|
||||||
|
|||||||
@@ -436,12 +436,18 @@ xaccFreqSpecGetNextInstance(
|
|||||||
/* This implements || composites. */
|
/* This implements || composites. */
|
||||||
guint32 min_julian = 0xFFFFFFFF; /* the biggest unsigned 32 bit number */
|
guint32 min_julian = 0xFFFFFFFF; /* the biggest unsigned 32 bit number */
|
||||||
guint32 this_julian;
|
guint32 this_julian;
|
||||||
|
char tmpBuf[25];
|
||||||
|
DEBUG( "List length: %d", g_list_length( list ) );
|
||||||
do {
|
do {
|
||||||
GDate next_repeat;
|
GDate next_repeat;
|
||||||
xaccFreqSpecGetNextInstance(
|
xaccFreqSpecGetNextInstance(
|
||||||
(FreqSpec*) list->data,
|
(FreqSpec*) list->data,
|
||||||
in_date,
|
in_date,
|
||||||
&next_repeat );
|
&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 );
|
this_julian = g_date_julian( &next_repeat );
|
||||||
|
|
||||||
min_julian = min( min_julian, this_julian );
|
min_julian = min( min_julian, this_julian );
|
||||||
|
|||||||
@@ -279,17 +279,49 @@ xaccSchedXactionGetManual( SchedXaction *sx )
|
|||||||
GDate
|
GDate
|
||||||
xaccSchedXactionGetNextInstance( SchedXaction *sx )
|
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 ) ) {
|
if ( g_date_valid( &sx->last_date ) ) {
|
||||||
last_occur = 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 {
|
} 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 );
|
xaccFreqSpecGetNextInstance( sx->freq, &last_occur, &next_occur );
|
||||||
return next_occur;
|
return next_occur;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,27 +234,6 @@ editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed )
|
|||||||
|
|
||||||
g_date_free( gdate );
|
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 */
|
/* add to list */
|
||||||
putSchedXactionInClist( sxed->sx, sxed->sxd );
|
putSchedXactionInClist( sxed->sx, sxed->sxd );
|
||||||
if ( sxed->new ) {
|
if ( sxed->new ) {
|
||||||
@@ -907,7 +886,6 @@ putSchedXactionInClist( gpointer data, gpointer user_data )
|
|||||||
time_t nextTime;
|
time_t nextTime;
|
||||||
GString *nextDate;
|
GString *nextDate;
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *nowTm;
|
|
||||||
gint row;
|
gint row;
|
||||||
int i;
|
int i;
|
||||||
GDate gd;
|
GDate gd;
|
||||||
@@ -921,28 +899,21 @@ putSchedXactionInClist( gpointer data, gpointer user_data )
|
|||||||
xaccFreqSpecGetFreqStr( xaccSchedXactionGetFreqSpec(sx), freqStr );
|
xaccFreqSpecGetFreqStr( xaccSchedXactionGetFreqSpec(sx), freqStr );
|
||||||
|
|
||||||
gd = xaccSchedXactionGetNextInstance( sx );
|
gd = xaccSchedXactionGetNextInstance( sx );
|
||||||
nowTm = g_new0( struct tm, 1 );
|
|
||||||
if ( ! g_date_valid( &gd ) ) {
|
if ( ! g_date_valid( &gd ) ) {
|
||||||
g_string_sprintf( nextDate, "not scheduled" );
|
g_string_sprintf( nextDate, "not scheduled" );
|
||||||
} else {
|
} else {
|
||||||
g_date_to_struct_tm( &gd, nowTm );
|
char tmpBuf[26];
|
||||||
nextTime = mktime( nowTm );
|
|
||||||
g_free( nowTm );
|
g_date_strftime( tmpBuf, 25, "%a, %b %e, %Y", &gd );
|
||||||
if ( nextTime == 0 ) {
|
g_string_sprintf( nextDate, "%s", tmpBuf );
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text[0] = xaccSchedXactionGetName( sx );
|
text[0] = xaccSchedXactionGetName( sx );
|
||||||
text[1] = freqStr->str;
|
text[1] = freqStr->str;
|
||||||
text[2] = nextDate->str;
|
text[2] = nextDate->str;
|
||||||
|
|
||||||
/* FIXME: leaky */
|
/* FIXME: leaky? */
|
||||||
g_string_free( freqStr, FALSE );
|
g_string_free( freqStr, FALSE );
|
||||||
g_string_free( nextDate, FALSE );
|
g_string_free( nextDate, FALSE );
|
||||||
|
|
||||||
|
|||||||
@@ -2788,8 +2788,8 @@ December
|
|||||||
<spacing>0</spacing>
|
<spacing>0</spacing>
|
||||||
<child>
|
<child>
|
||||||
<padding>0</padding>
|
<padding>0</padding>
|
||||||
<expand>True</expand>
|
<expand>False</expand>
|
||||||
<fill>True</fill>
|
<fill>False</fill>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
|
|||||||
@@ -637,6 +637,7 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outStartDate )
|
|||||||
str = CHECKBOX_NAMES[i];
|
str = CHECKBOX_NAMES[i];
|
||||||
o = glade_xml_get_widget( gf->gxml, str );
|
o = glade_xml_get_widget( gf->gxml, str );
|
||||||
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) {
|
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) {
|
||||||
|
|
||||||
tmpFS = xaccFreqSpecMalloc();
|
tmpFS = xaccFreqSpecMalloc();
|
||||||
xaccFreqSpecSetUIType( tmpFS, uift );
|
xaccFreqSpecSetUIType( tmpFS, uift );
|
||||||
/* struct-copy is expected to work, here */
|
/* struct-copy is expected to work, here */
|
||||||
|
|||||||
Reference in new issue
Block a user