mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Simplify handling of sx template_acct column.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18806 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c080f3a8bd
commit
b4172691ea
@ -55,27 +55,27 @@
|
||||
|
||||
#define SX_MAX_NAME_LEN 2048
|
||||
|
||||
static /*@ null @*/ gpointer get_template_act_guid( gpointer pObject );
|
||||
static void set_template_act_guid( gpointer pObject, /*@ null @*/ gpointer pValue );
|
||||
static /*@ null @*/ gpointer get_template_acct( gpointer pObject );
|
||||
static void set_template_acct( gpointer pObject, /*@ null @*/ gpointer pValue );
|
||||
|
||||
static const GncSqlColumnTableEntry col_table[] =
|
||||
{
|
||||
/*@ -full_init_block @*/
|
||||
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
|
||||
{ "name", CT_STRING, SX_MAX_NAME_LEN, 0, "name" },
|
||||
{ "enabled", CT_BOOLEAN, 0, COL_NNUL, "enabled" },
|
||||
{ "start_date", CT_GDATE, 0, 0, "start-date" },
|
||||
{ "end_date", CT_GDATE, 0, 0, "end-date" },
|
||||
{ "last_occur", CT_GDATE, 0, 0, "last-occurance-date" },
|
||||
{ "num_occur", CT_INT, 0, COL_NNUL, "num-occurance" },
|
||||
{ "rem_occur", CT_INT, 0, COL_NNUL, "rem-occurance" },
|
||||
{ "auto_create", CT_BOOLEAN, 0, COL_NNUL, "auto-create" },
|
||||
{ "auto_notify", CT_BOOLEAN, 0, COL_NNUL, "auto-create-notify" },
|
||||
{ "adv_creation", CT_INT, 0, COL_NNUL, "advance-creation-days" },
|
||||
{ "adv_notify", CT_INT, 0, COL_NNUL, "advance-reminder-days" },
|
||||
{ "instance_count", CT_INT, 0, COL_NNUL, "instance-count" },
|
||||
{ "template_act_guid", CT_GUID, 0, COL_NNUL, NULL, NULL,
|
||||
(QofAccessFunc)get_template_act_guid, set_template_act_guid },
|
||||
{ "guid", CT_GUID, 0, COL_NNUL|COL_PKEY, "guid" },
|
||||
{ "name", CT_STRING, SX_MAX_NAME_LEN, 0, "name" },
|
||||
{ "enabled", CT_BOOLEAN, 0, COL_NNUL, "enabled" },
|
||||
{ "start_date", CT_GDATE, 0, 0, "start-date" },
|
||||
{ "end_date", CT_GDATE, 0, 0, "end-date" },
|
||||
{ "last_occur", CT_GDATE, 0, 0, "last-occurance-date" },
|
||||
{ "num_occur", CT_INT, 0, COL_NNUL, "num-occurance" },
|
||||
{ "rem_occur", CT_INT, 0, COL_NNUL, "rem-occurance" },
|
||||
{ "auto_create", CT_BOOLEAN, 0, COL_NNUL, "auto-create" },
|
||||
{ "auto_notify", CT_BOOLEAN, 0, COL_NNUL, "auto-create-notify" },
|
||||
{ "adv_creation", CT_INT, 0, COL_NNUL, "advance-creation-days" },
|
||||
{ "adv_notify", CT_INT, 0, COL_NNUL, "advance-reminder-days" },
|
||||
{ "instance_count", CT_INT, 0, COL_NNUL, "instance-count" },
|
||||
{ "template_act_guid", CT_ACCOUNTREF, 0, COL_NNUL, NULL, NULL,
|
||||
(QofAccessFunc)get_template_acct, set_template_acct },
|
||||
{ NULL }
|
||||
/*@ +full_init_block @*/
|
||||
};
|
||||
@ -83,7 +83,7 @@ static const GncSqlColumnTableEntry col_table[] =
|
||||
/* ================================================================= */
|
||||
|
||||
static gpointer
|
||||
get_template_act_guid( gpointer pObject )
|
||||
get_template_acct( gpointer pObject )
|
||||
{
|
||||
const SchedXaction* pSx;
|
||||
|
||||
@ -91,24 +91,20 @@ get_template_act_guid( gpointer pObject )
|
||||
g_return_val_if_fail( GNC_IS_SX(pObject), NULL );
|
||||
|
||||
pSx = GNC_SX(pObject);
|
||||
return (gpointer)xaccAccountGetGUID( pSx->template_acct );
|
||||
return pSx->template_acct;
|
||||
}
|
||||
|
||||
static void
|
||||
set_template_act_guid( gpointer pObject, gpointer pValue )
|
||||
set_template_acct( gpointer pObject, gpointer pValue )
|
||||
{
|
||||
SchedXaction* pSx;
|
||||
QofBook* pBook;
|
||||
GUID* guid = (GUID*)pValue;
|
||||
Account* pAcct;
|
||||
|
||||
g_return_if_fail( pObject != NULL );
|
||||
g_return_if_fail( GNC_IS_SX(pObject) );
|
||||
g_return_if_fail( pValue != NULL );
|
||||
g_return_if_fail( pObject != NULL && GNC_IS_SX(pObject) );
|
||||
g_return_if_fail( pValue != NULL && GNC_IS_ACCOUNT(pValue) );
|
||||
|
||||
pSx = GNC_SX(pObject);
|
||||
pBook = qof_instance_get_book( QOF_INSTANCE(pSx) );
|
||||
pAcct = xaccAccountLookup( guid, pBook );
|
||||
pAcct = GNC_ACCOUNT(pValue);
|
||||
sx_set_template_account( pSx, pAcct );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user