the big SX kvp renaming, and date-time bugfixes for sx-from-trans

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5277 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Robert Graham Merkel 2001-09-04 07:26:41 +00:00
parent d9053adcce
commit 5e6aa950ed
11 changed files with 97 additions and 48 deletions

View File

@ -1,3 +1,15 @@
2001-09-04 Robert Graham Merkel <rgmerk@mira.net>
* several SX-related .c files: replaced use of kvp_frame_{set,get}_slot,
with {set,get}_slot_path, replaced literals with #defines.
* src/engine/SchedXaction.h: #define names for kvp_frame keys.
* src/engine/dialog-sx-from-trans.h: fix freqspec and date/time setting bugs.
* src/gnome/glade/sched-xact.glade: rename several items in editor dialog
to match UI code.
2001-09-02 Dave Peticolas <dave@krondo.com>
* src/backend/file/sixtp-dom-generators.c (add_kvp_value_node):

View File

@ -187,6 +187,7 @@ xaccSchedXactionSetFreqSpec( SchedXaction *sx, FreqSpec *fs )
{
g_return_if_fail( fs );
DEBUG("Called xaccSchedXactionSetFreqSpec");
xaccFreqSpecFree( sx->freq );
sx->freq = fs;
sx->dirty = TRUE;
@ -420,6 +421,8 @@ xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays )
sx->advanceRemindDays = reminderDays;
}
/* FIXME: there is a bug in this, I think */
GDate
xaccSchedXactionGetNextInstance( SchedXaction *sx )
{
@ -526,8 +529,8 @@ pack_split_info(TTSplitInfo *s_info, Account *parent_acct)
kvp_frame_set_slot_path(split_frame,
tmp_value,
"sched-xaction",
"credit-formula");
GNC_SX_ID,
GNC_SX_CREDIT_FORMULA);
kvp_value_delete(tmp_value);
tmp_value
@ -535,8 +538,8 @@ pack_split_info(TTSplitInfo *s_info, Account *parent_acct)
kvp_frame_set_slot_path(split_frame,
tmp_value,
"sched-xaction",
"debit-formula");
GNC_SX_ID,
GNC_SX_DEBIT_FORMULA);
kvp_value_delete(tmp_value);
@ -546,8 +549,8 @@ pack_split_info(TTSplitInfo *s_info, Account *parent_acct)
kvp_frame_set_slot_path(split_frame,
tmp_value,
"sched-xaction",
"xfrm");
GNC_SX_ID,
GNC_SX_ACCOUNT);
kvp_value_delete(tmp_value);

View File

@ -34,6 +34,19 @@
#include "kvp_frame.h"
#include "gnc-book.h"
/*
* #defines for kvp_frame strings
* FIXME: Is this the right spot for them <rgmerk>?
*/
#define GNC_SX_ID "sched-xaction"
#define GNC_SX_ACCOUNT "account"
#define GNC_SX_CREDIT_FORMULA "credit-formula"
#define GNC_SX_DEBIT_FORMULA "debit-formula"
#define GNC_SX_SHARES "shares"
#define GNC_SX_AMOUNT "amnt"
#define GNC_SX_FROM_SCHED_XACTION "from-sched-xaction"
/**
* A single scheduled transaction.
*

View File

@ -151,7 +151,7 @@ Entities: Split in a SchedXaction
Use: Storage for the various fields of a scheduled transaction's
template Splits.
Name: sched-xaction/xfrm
Name: sched-xaction/account
Type: GUID
Entities: Split associated with a SchedXaction
Use: The GUID of this Split's xfrm account.

View File

@ -319,9 +319,9 @@ create_each_transaction( Transaction *t, void *d )
GUID *acct_guid;
Account *acct;
/* contains the guid of the split's actual account. */
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/xfrm" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_ACCOUNT );
if ( kvp_val == NULL ) {
PERR( "Null kvp_val for xfrm\n" );
PERR( "Null kvp_val for account\n" );
}
acct_guid = kvp_value_get_guid( kvp_val );
acct = xaccAccountLookup( acct_guid );
@ -338,7 +338,7 @@ create_each_transaction( Transaction *t, void *d )
gnc_numeric final;
int gncn_error;
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/credit_formula" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_CREDIT_FORMULA );
str = kvp_value_get_string( kvp_val );
credit_num = gnc_numeric_create( 0, 1 );
if ( str != NULL ) {
@ -354,7 +354,7 @@ create_each_transaction( Transaction *t, void *d )
str, gnc_numeric_to_string( credit_num ) );
}
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/debit_formula" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_DEBIT_FORMULA );
str = kvp_value_get_string( kvp_val );
debit_num = gnc_numeric_create( 0, 1 );
@ -384,8 +384,8 @@ create_each_transaction( Transaction *t, void *d )
xaccSplitSetValue( split, final );
}
#if 0
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/shares" );
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/amnt" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_SHARES );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_AMNT );
#endif /* 0 */
} while ( (sList = sList->next) && (osList = osList->next) );

View File

@ -44,7 +44,6 @@
#include "gnc-engine-util.h"
#include "gnc-frequency.h"
#include "gnc-ledger-display.h"
#include "messages.h"
#include "query-user.h"

View File

@ -216,6 +216,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti)
return 0;
}
static guint
sxftd_compute_sx(SXFromTransInfo *sxfti)
{
@ -245,7 +246,8 @@ GtkWidget *w;
trans_t = xaccTransGetDate(sxfti->trans);
g_date_set_julian(&date, trans_t);
g_date_set_time(&date, trans_t);
fs = xaccFreqSpecMalloc();
@ -265,37 +267,46 @@ GtkWidget *w;
g_date_add_days(&date, 1);
xaccFreqSpecSetDaily(fs, &date, 1);
xaccFreqSpecSetUIType(fs, UIFREQ_DAILY);
break;
case FREQ_WEEKLY:
g_date_add_days(&date, 7);
xaccFreqSpecSetWeekly(fs, &date, 1);
xaccFreqSpecSetUIType(fs, UIFREQ_WEEKLY);
break;
case FREQ_MONTHLY:
g_date_add_months(&date, 1);
xaccFreqSpecSetMonthly(fs, &date, 1);
xaccFreqSpecSetUIType(fs, UIFREQ_MONTHLY);
break;
case FREQ_QUARTERLY:
g_date_add_months(&date, 3);
xaccFreqSpecSetMonthly(fs, &date, 3);
xaccFreqSpecSetUIType(fs, UIFREQ_QUARTERLY);
break;
case FREQ_ANNUALLY:
g_date_add_years(&date, 1);
xaccFreqSpecSetMonthly(fs, &date, 12);
xaccFreqSpecSetUIType(fs, UIFREQ_YEARLY);
break;
default:
PWARN("Nonexistent frequency selected. This is a bug.");
PERR("Nonexistent frequency selected. This is a bug.");
/* report fsckup */
sxftd_errno = 1;
break;
}
if (sxftd_errno == 0)
{
xaccSchedXactionSetFreqSpec( sx, fs);
xaccSchedXactionSetStartDate(sx, &date);
}
end_info = sxftd_get_end_info(sxfti);
switch(end_info.type)

View File

@ -1109,9 +1109,9 @@ _create_each_transaction_helper( Transaction *t, void *d )
GUID *acct_guid;
Account *acct;
/* contains the guid of the split's actual account. */
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/xfrm" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_ACCOUNT );
if ( kvp_val == NULL ) {
PERR( "Null kvp_val for xfrm" );
PERR( "Null kvp_val for account" );
}
acct_guid = kvp_value_get_guid( kvp_val );
acct = xaccAccountLookup( acct_guid );
@ -1133,7 +1133,7 @@ _create_each_transaction_helper( Transaction *t, void *d )
gnc_numeric credit_num, debit_num, final;
int gncn_error;
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/credit_formula" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_CREDIT_FORMULA );
str = kvp_value_get_string( kvp_val );
credit_num = gnc_numeric_create( 0, 1 );
if ( str != NULL
@ -1151,7 +1151,7 @@ _create_each_transaction_helper( Transaction *t, void *d )
gnc_numeric_to_string( gnc_numeric_reduce( credit_num ) ) );
}
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/debit_formula" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_DEBIT_FORMULA );
str = kvp_value_get_string( kvp_val );
debit_num = gnc_numeric_create( 0, 1 );
@ -1184,8 +1184,8 @@ _create_each_transaction_helper( Transaction *t, void *d )
}
#if 0
/* NOT [YET] USED */
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/shares" );
kvp_val = kvp_frame_get_slot( split_kvpf, "sched-xaction/amnt" );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_SHARES );
kvp_val = kvp_frame_get_slot_path( split_kvpf, GNC_SX_ID, GNC_SX_AMNT );
#endif /* 0 */
/* FIXME:
@ -1330,7 +1330,7 @@ _sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash )
kvpf = xaccSplitGetSlots(s);
kvp_val = kvp_frame_get_slot( kvpf, "sched-xaction/credit_formula" );
kvp_val = kvp_frame_get_slot_path( kvpf, GNC_SX_ID, GNC_SX_CREDIT_FORMULA );
if ( kvp_val != NULL ) {
str = kvp_value_get_string( kvp_val );
if ( str && strlen(str) != 0 ) {
@ -1338,7 +1338,7 @@ _sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash )
}
}
kvp_val = kvp_frame_get_slot( kvpf, "sched-xaction/debit_formula" );
kvp_val = kvp_frame_get_slot_path( kvpf, GNC_SX_ID, GNC_SX_DEBIT_FORMULA );
if ( kvp_val != NULL ) {
str = kvp_value_get_string( kvp_val );
if ( str && strlen(str) != 0 ) {

View File

@ -415,7 +415,7 @@
<widget>
<class>GtkRadioButton</class>
<name>radiobutton1</name>
<name>rb_noend</name>
<can_focus>True</can_focus>
<label>No End</label>
<active>True</active>
@ -430,7 +430,7 @@
<widget>
<class>GtkRadioButton</class>
<name>radiobutton2</name>
<name>rb_enddate</name>
<can_focus>True</can_focus>
<active>False</active>
<draw_indicator>True</draw_indicator>
@ -466,7 +466,7 @@
<widget>
<class>GnomeDateEdit</class>
<name>dateedit1</name>
<name>sxe_end_date</name>
<show_time>False</show_time>
<use_24_format>True</use_24_format>
<week_start_monday>False</week_start_monday>
@ -483,7 +483,7 @@
<widget>
<class>GtkRadioButton</class>
<name>radiobutton3</name>
<name>rb_num_occur</name>
<can_focus>True</can_focus>
<active>False</active>
<draw_indicator>True</draw_indicator>
@ -530,7 +530,7 @@
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
<name>entry3</name>
<name>end_nentry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>

View File

@ -349,8 +349,11 @@ gnc_split_register_save_template_cells (gpointer save_data,
}
acctGUID = xaccAccountGetGUID (acct);
kvp_frame_set_slot (kvpf, "sched-xaction/xfrm",
kvp_value_new_guid (acctGUID));
/* FIXME: replace these with #defines - is it ok to #include "SchedXaction.h" ?? */
kvp_frame_set_slot_path (kvpf, kvp_value_new_guid(acctGUID), "sched-xaction", "account");
kvpf = xaccSplitGetSlots (split);
cell = gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
@ -385,12 +388,16 @@ gnc_split_register_save_template_cells (gpointer save_data,
/* amountStr = gnc_numeric_to_string( new_amount ); */
value = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL);
kvp_frame_set_slot (kvpf, "sched-xaction/credit_formula",
kvp_value_new_string (value));
kvp_frame_set_slot_path( kvpf,kvp_value_new_string( value ),
"sched-xaction", "credit-formula");
value = gnc_table_layout_get_cell_value (reg->table->layout, FDEBT_CELL);
kvp_frame_set_slot (kvpf, "sched-xaction/debit_formula",
kvp_value_new_string (value));
kvp_frame_set_slot_path( kvpf,
kvp_value_new_string( value ),
"sched-xaction",
"debit_formula");
DEBUG( "kvp_frame after: %s\n", kvp_frame_to_string( kvpf ) );
@ -407,9 +414,12 @@ gnc_split_register_save_template_cells (gpointer save_data,
DEBUG ("kvp_frame before: %s\n", kvp_frame_to_string (kvpf));
/* sharesStr = gnc_numeric_to_string( sharesStr ); */
kvp_frame_set_slot (kvpf, "sched-xaction/shares",
kvp_value_new_string (sharesStr));
DEBUG ("kvp_frame after: %s\n", kvp_frame_to_string (kvpf));
kvp_frame_set_slot_path( kvpf,
kvp_value_new_string( sharesStr ),
"sched-xaction",
"shares");
DEBUG( "kvp_frame after: %s\n", kvp_frame_to_string( kvpf ) );
/* set the shares to an innocuous value */
xaccSplitSetSharePriceAndAmount (split,
gnc_numeric_create(0, 1),

View File

@ -1112,8 +1112,8 @@ gnc_template_register_get_xfrm_entry (VirtualLocation virt_loc,
{
GUID *guid;
guid = kvp_value_get_guid (kvp_frame_get_slot (kvpf,
"sched-xaction/xfrm"));
guid = kvp_value_get_guid (kvp_frame_get_slot_path (kvpf,
"sched-xaction","account"));
name = xaccAccountGetFullName (xaccAccountLookup (guid),
gnc_get_account_separator ());
@ -1138,7 +1138,7 @@ gnc_template_register_get_fdebt_entry (VirtualLocation virt_loc,
kvpf = xaccSplitGetSlots (split);
return kvp_value_get_string
(kvp_frame_get_slot (kvpf, "sched-xaction/debit_formula"));
(kvp_frame_get_slot_path (kvpf, "sched-xaction","debit_formula"));
}
static const char *
@ -1155,7 +1155,7 @@ gnc_template_register_get_fcred_entry (VirtualLocation virt_loc,
kvpf = xaccSplitGetSlots (split);
return kvp_value_get_string
(kvp_frame_get_slot (kvpf, "sched-xaction/credit_formula"));
(kvp_frame_get_slot_path (kvpf, "sched-xaction","credit_formula"));
}
static const char *
@ -1183,8 +1183,9 @@ gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
const char * cell_name;
char *str;
str = kvp_value_get_string (kvp_frame_get_slot (kvpf,
"sched-xaction/amnt"));
PWARN("This code is wrong. Fix it immediately!!!!");
str = kvp_value_get_string (kvp_frame_get_slot_path (kvpf,
"sched-xaction", "amnt"));
amount = gnc_numeric_zero ();
string_to_gnc_numeric (str, &amount);