r15633 - gnucash/trunk/src - Fixup SX editor consistency check re: FreqSpec/Recurrence; never-runnable bug fix, as well!
Josh Sled
jsled at cvs.gnucash.org
Mon Feb 19 17:22:18 EST 2007
Author: jsled
Date: 2007-02-19 17:22:17 -0500 (Mon, 19 Feb 2007)
New Revision: 15633
Trac: http://svn.gnucash.org/trac/changeset/15633
Modified:
gnucash/trunk/src/doc/sx.rst
gnucash/trunk/src/gnome-utils/gnc-frequency.c
gnucash/trunk/src/gnome/dialog-sx-editor.c
Log:
Fixup SX editor consistency check re: FreqSpec/Recurrence; never-runnable bug fix, as well!
Modified: gnucash/trunk/src/doc/sx.rst
===================================================================
--- gnucash/trunk/src/doc/sx.rst 2007-02-19 22:21:02 UTC (rev 15632)
+++ gnucash/trunk/src/doc/sx.rst 2007-02-19 22:22:17 UTC (rev 15633)
@@ -134,7 +134,7 @@
- [x] clean up, reformat source
- dialog-sx-editor
- [ ] gnc_sxed_check_changed
- - [ ] gnc_sxed_check_consistent
+ - [x] gnc_sxed_check_consistent
- [x] gnc_sxed_update_cal
- [x] gnc_sxed_save_sx
- sx list
Modified: gnucash/trunk/src/gnome/dialog-sx-editor.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-sx-editor.c 2007-02-19 22:21:02 UTC (rev 15632)
+++ gnucash/trunk/src/gnome/dialog-sx-editor.c 2007-02-19 22:22:17 UTC (rev 15633)
@@ -515,7 +515,7 @@
gboolean multi_commodity = FALSE;
gnc_commodity *base_cmdty = NULL;
gint ttVarCount, splitCount;
- FreqSpec *fs;
+ GList *schedule = NULL;
/* Do checks on validity and such, interrupting the user if
* things aren't right.
@@ -798,7 +798,7 @@
/* deal with time. */
{
- GDate startDate, endDate, nextDate;
+ GDate startDate, endDate, nextDate, now;
if ( !gtk_toggle_button_get_active(sxed->optEndDate)
&& !gtk_toggle_button_get_active(sxed->optEndCount)
@@ -839,6 +839,9 @@
}
+ g_date_clear(&now, 1);
+ g_date_set_time_t(&now, time(NULL));
+
g_date_clear( &endDate, 1 );
if ( gtk_toggle_button_get_active(sxed->optEndDate) ) {
g_date_set_time_t( &endDate,
@@ -846,30 +849,25 @@
endDateEntry ) );
}
- /* Now, see if the user is attempting to create a SX that can't exist
- * [will never run]. */
+ g_date_clear(&nextDate, 1);
+ gnc_frequency_save_to_recurrence(sxed->gncfreq, &schedule, &startDate);
+ if (g_list_length(schedule) > 0)
+ {
+ g_date_subtract_days(&startDate, 1);
+ recurrenceListNextInstance(schedule, &startDate, &nextDate);
+ g_list_free(schedule);
+ }
- /* get the frequency spec data */
- fs = xaccFreqSpecMalloc( gnc_get_current_book() );
- gnc_frequency_save_state( sxed->gncfreq, fs, &startDate );
- /* Replicate just a smidgen of the code in the SX
- * ...GetNextInstance routine */
- g_date_subtract_days( &startDate, 1 );
- xaccFreqSpecGetNextInstance( fs, &startDate, &nextDate );
- xaccFreqSpecFree( fs );
-
- if ( !g_date_valid( &nextDate )
- || (g_date_valid( &endDate )
- && (g_date_compare( &nextDate, &endDate ) > 0)) ) {
+ if (!g_date_valid(&nextDate)
+ || (g_date_valid(&endDate) && (g_date_compare(&nextDate, &endDate) > 0))
+ || (g_date_compare(&nextDate, &now) < 0))
+ {
const char *invalid_sx_check_msg =
- _( "You have attempted to create a Scheduled "
- "Transaction which will never run. Do you "
- "really want to do this?" );
- if ( ! gnc_verify_dialog( sxed->dialog, FALSE,
- invalid_sx_check_msg) ) {
-
+ _("You have attempted to create a Scheduled "
+ "Transaction which will never run. Do you "
+ "really want to do this?");
+ if (!gnc_verify_dialog(sxed->dialog, FALSE, invalid_sx_check_msg))
return FALSE;
- }
}
}
return TRUE;
Modified: gnucash/trunk/src/gnome-utils/gnc-frequency.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-frequency.c 2007-02-19 22:21:02 UTC (rev 15632)
+++ gnucash/trunk/src/gnome-utils/gnc-frequency.c 2007-02-19 22:22:17 UTC (rev 15633)
@@ -1116,9 +1116,9 @@
switch (page_index)
{
- case PAGE_NONE:
- g_critical("recurrence can't support none");
- break;
+ case PAGE_NONE: {
+ // empty-recurrence list ~~ none.
+ } break;
case PAGE_ONCE: {
Recurrence *r = g_new0(Recurrence, 1);
recurrenceSet(r, 1, PERIOD_ONCE, &start_date);
More information about the gnucash-changes
mailing list