r15603 - gnucash/trunk/src - Bug fixing:
Josh Sled
jsled at cvs.gnucash.org
Sun Feb 18 14:32:08 EST 2007
Author: jsled
Date: 2007-02-18 14:32:07 -0500 (Sun, 18 Feb 2007)
New Revision: 15603
Trac: http://svn.gnucash.org/trac/changeset/15603
Modified:
gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c
gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
gnucash/trunk/src/doc/sx.rst
Log:
Bug fixing:
- fix bug in weekly-freqspec parsing
- fix bug in date computation
- fix ages-old bug in "once" FreqSpecs :(
Update todo.
Modified: gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c 2007-02-18 19:30:18 UTC (rev 15602)
+++ gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c 2007-02-18 19:32:07 UTC (rev 15603)
@@ -135,6 +135,7 @@
gint64 day; /* monthly or month-relative */
gint64 occurrence; /* month-relative */
GList *list; /* composite */
+ UIFreqType uift;
} fsParseData;
static void
@@ -302,6 +303,7 @@
for ( i=0; (tmp = uiFreqTypeStrs[i].str) != NULL; i++ ) {
if ( safe_strcmp( nodeTxt, tmp ) == 0 ) {
xaccFreqSpecSetUIType( fspd->fs, uiFreqTypeStrs[i].uift );
+ fspd->uift = uiFreqTypeStrs[i].uift;
g_free( nodeTxt );
return TRUE;
}
@@ -436,14 +438,6 @@
{ NULL, NULL, 0, 0 },
};
-static void
-compute_date(fsParseData *parsed, GDate *date)
-{
- g_date_clear(date, 1);
- g_date_set_dmy(date, 1, 1, 1970);
- g_date_add_days(date, parsed->offset);
-}
-
static gboolean
fs_none_handler( xmlNodePtr node, gpointer data )
{
@@ -472,7 +466,6 @@
return FALSE;
recurrenceSet(fspd->recurrence, 0, PERIOD_ONCE, &fspd->once_day);
-
fspd->fs->type = ONCE;
fspd->fs->s.once.date = fspd->once_day;
return TRUE;
@@ -488,7 +481,8 @@
if (!successful)
return FALSE;
- compute_date(fspd, &offset_date);
+ g_date_clear(&offset_date, 1);
+ g_date_set_julian(&offset_date, fspd->offset);
recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_DAY, &offset_date);
fspd->fs->type = DAILY;
@@ -510,8 +504,9 @@
if ( !successful )
return FALSE;
- compute_date(fspd, &offset_date);
- recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_DAY, &offset_date);
+ g_date_clear(&offset_date, 1);
+ g_date_set_julian(&offset_date, fspd->offset);
+ recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_WEEK, &offset_date);
fspd->fs->type = WEEKLY;
fspd->fs->s.weekly.interval_weeks = fspd->interval;
@@ -532,10 +527,21 @@
fspd );
if ( !successful )
return FALSE;
- compute_date(fspd, &offset_date);
+
+ g_date_clear(&offset_date, 1);
+ g_date_set_julian(&offset_date, 1);
+ g_date_add_months(&offset_date, fspd->offset);
g_date_set_day(&offset_date, fspd->day);
- recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_MONTH, &offset_date);
+ if (fspd->uift == UIFREQ_ONCE)
+ {
+ // hack...
+ recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_ONCE, &offset_date);
+ }
+ else
+ {
+ recurrenceSet(fspd->recurrence, fspd->interval, PERIOD_MONTH, &offset_date);
+ }
fspd->fs->type = MONTHLY;
fspd->fs->s.monthly.interval_months = fspd->interval;
Modified: gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c 2007-02-18 19:30:18 UTC (rev 15602)
+++ gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c 2007-02-18 19:32:07 UTC (rev 15603)
@@ -287,11 +287,10 @@
struct sx_pdata *pdata = sx_pdata;
SchedXaction *sx = pdata->sx;
gchar *tmp = dom_tree_to_text( node );
-
+ g_debug("sx named [%s]", tmp);
g_return_val_if_fail( tmp, FALSE );
xaccSchedXactionSetName( sx, tmp );
g_free( tmp );
-
return TRUE;
}
@@ -431,13 +430,20 @@
g_return_val_if_fail( node, FALSE );
xaccSchedXactionSetFreqSpec(sx, dom_tree_to_freqSpec(node, pdata->book));
-
+
schedule = dom_tree_freqSpec_to_recurrences(node, pdata->book);
gnc_sx_set_schedule(sx, schedule);
- for (; schedule != NULL; schedule = schedule->next)
+ g_debug("parsed from freqspec [%s]", recurrenceListToString(schedule));
+ if (g_list_length(schedule) == 1
+ && recurrenceGetPeriodType((Recurrence*)g_list_nth_data(schedule, 0)) == PERIOD_ONCE)
{
- g_debug("parsed from freqspec [%s]", recurrenceToString((Recurrence*)schedule->data));
+ char date_buf[128];
+ Recurrence *fixup = (Recurrence*)g_list_nth_data(schedule, 0);
+ g_date_strftime(date_buf, 127, "%x", xaccSchedXactionGetStartDate(sx));
+ recurrenceSet(fixup, 1, PERIOD_ONCE, xaccSchedXactionGetStartDate(sx));
+ g_debug("fixed up period=ONCE Recurrence to date [%s]", date_buf);
}
+
pdata->saw_freqspec = TRUE;
return TRUE;
Modified: gnucash/trunk/src/doc/sx.rst
===================================================================
--- gnucash/trunk/src/doc/sx.rst 2007-02-18 19:30:18 UTC (rev 15602)
+++ gnucash/trunk/src/doc/sx.rst 2007-02-18 19:32:07 UTC (rev 15603)
@@ -113,14 +113,16 @@
- use Recurrence instead of FreqSpec
! - [ ] XML migration, handling
- xml:freqSpec -> obj:Recurrence
- - [ ] none (Recurrence doesn't support)
+ - [x] none (Recurrence doesn't support)
- [x] once
+ - [x] if once, fix Recurrence date to be SX start date. :p
- [x] daily
- - [ ] daily [m-f] (composite)
+ - [x] daily [m-f] (composite)
- [x] weekly, single
- - [ ] weekly, multiple (composite)
+ - [x] weekly, multiple (composite)
- [x] monthly (+quarterly, tri-anually, semi-annually, yearly)
- - [ ] semi-monthly (composite)
+ - [x] semi-monthly (composite)
+ - [ ] write Recurrences into new-version SX
- gnc-frequency
! - [x] Support Recurrence
- [x] in
More information about the gnucash-changes
mailing list