2003-10-16 23:40:59 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* gncEmployee.c -- the Core Employee Interface *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-16 23:35:02 -06:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2003-10-16 23:40:59 -05:00
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
/*
|
2002-02-03 14:01:08 -06:00
|
|
|
* Copyright (C) 2001,2002 Derek Atkins
|
2003-10-20 08:34:03 -05:00
|
|
|
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
2001-11-16 19:17:06 -06:00
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-10-21 00:12:38 -05:00
|
|
|
#include "Account.h"
|
|
|
|
#include "gnc-commodity.h"
|
|
|
|
#include "gncAddressP.h"
|
2001-11-16 19:17:06 -06:00
|
|
|
#include "gncEmployee.h"
|
|
|
|
#include "gncEmployeeP.h"
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
struct _gncEmployee
|
|
|
|
{
|
2003-10-20 08:34:03 -05:00
|
|
|
QofInstance inst;
|
2003-10-14 16:20:55 -05:00
|
|
|
char * id;
|
|
|
|
char * username;
|
|
|
|
GncAddress * addr;
|
2003-01-12 16:53:02 -06:00
|
|
|
gnc_commodity * currency;
|
2003-10-14 16:20:55 -05:00
|
|
|
gboolean active;
|
2003-10-20 08:34:03 -05:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
char * language;
|
|
|
|
char * acl;
|
|
|
|
gnc_numeric workday;
|
|
|
|
gnc_numeric rate;
|
2003-03-09 16:51:04 -06:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
Account * ccard_acc;
|
2001-11-16 19:17:06 -06:00
|
|
|
};
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
2002-11-03 14:21:42 -06:00
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
#define _GNC_MOD_NAME GNC_ID_EMPLOYEE
|
2001-11-24 23:34:34 -06:00
|
|
|
|
2002-03-02 12:55:01 -06:00
|
|
|
G_INLINE_FUNC void mark_employee (GncEmployee *employee);
|
2005-11-01 21:32:36 -06:00
|
|
|
void mark_employee (GncEmployee *employee)
|
2002-03-02 12:55:01 -06:00
|
|
|
{
|
2006-05-02 21:28:18 -05:00
|
|
|
qof_instance_set_dirty(&employee->inst);
|
2006-03-08 21:48:49 -06:00
|
|
|
qof_event_gen (&employee->inst.entity, QOF_EVENT_MODIFY, NULL);
|
2002-03-02 12:55:01 -06:00
|
|
|
}
|
|
|
|
|
2003-10-20 08:34:03 -05:00
|
|
|
/* ============================================================== */
|
2001-11-16 19:17:06 -06:00
|
|
|
/* Create/Destroy Functions */
|
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
GncEmployee *gncEmployeeCreate (QofBook *book)
|
2001-11-16 19:17:06 -06:00
|
|
|
{
|
|
|
|
GncEmployee *employee;
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
if (!book) return NULL;
|
2001-11-16 19:17:06 -06:00
|
|
|
|
|
|
|
employee = g_new0 (GncEmployee, 1);
|
2003-10-14 16:20:55 -05:00
|
|
|
qof_instance_init (&employee->inst, _GNC_MOD_NAME, book);
|
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
employee->id = CACHE_INSERT ("");
|
|
|
|
employee->username = CACHE_INSERT ("");
|
|
|
|
employee->language = CACHE_INSERT ("");
|
|
|
|
employee->acl = CACHE_INSERT ("");
|
2003-10-19 10:45:30 -05:00
|
|
|
employee->addr = gncAddressCreate (book, &employee->inst.entity);
|
2001-11-16 19:17:06 -06:00
|
|
|
employee->workday = gnc_numeric_zero();
|
|
|
|
employee->rate = gnc_numeric_zero();
|
|
|
|
employee->active = TRUE;
|
|
|
|
|
2006-03-08 21:48:49 -06:00
|
|
|
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
|
2002-03-02 12:55:01 -06:00
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
return employee;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeDestroy (GncEmployee *employee)
|
2002-11-03 14:21:42 -06:00
|
|
|
{
|
|
|
|
if (!employee) return;
|
2003-10-14 16:20:55 -05:00
|
|
|
employee->inst.do_free = TRUE;
|
2002-11-03 14:21:42 -06:00
|
|
|
gncEmployeeCommitEdit(employee);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gncEmployeeFree (GncEmployee *employee)
|
2001-11-16 19:17:06 -06:00
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
|
2006-03-08 21:48:49 -06:00
|
|
|
qof_event_gen (&employee->inst.entity, QOF_EVENT_DESTROY, NULL);
|
2002-03-02 12:55:01 -06:00
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
CACHE_REMOVE (employee->id);
|
|
|
|
CACHE_REMOVE (employee->username);
|
|
|
|
CACHE_REMOVE (employee->language);
|
|
|
|
CACHE_REMOVE (employee->acl);
|
|
|
|
gncAddressDestroy (employee->addr);
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
qof_instance_release (&employee->inst);
|
2001-11-16 19:17:06 -06:00
|
|
|
g_free (employee);
|
|
|
|
}
|
|
|
|
|
2003-10-20 08:34:03 -05:00
|
|
|
GncEmployee *
|
|
|
|
gncCloneEmployee (GncEmployee *from, QofBook *book)
|
|
|
|
{
|
|
|
|
GncEmployee *employee;
|
|
|
|
if (!book || !from) return NULL;
|
|
|
|
|
|
|
|
employee = g_new0 (GncEmployee, 1);
|
|
|
|
qof_instance_init(&employee->inst, _GNC_MOD_NAME, book);
|
|
|
|
qof_instance_gemini (&employee->inst, &from->inst);
|
|
|
|
|
|
|
|
employee->id = CACHE_INSERT (from->id);
|
|
|
|
employee->username = CACHE_INSERT (from->username);
|
|
|
|
employee->language = CACHE_INSERT (from->language);
|
|
|
|
employee->acl = CACHE_INSERT (from->acl);
|
2003-10-21 00:12:38 -05:00
|
|
|
employee->addr = gncCloneAddress (from->addr, &employee->inst.entity, book);
|
2003-10-20 08:34:03 -05:00
|
|
|
employee->workday = from->workday;
|
|
|
|
employee->rate = from->rate;
|
|
|
|
employee->active = from->active;
|
2003-10-21 00:12:38 -05:00
|
|
|
employee->currency = gnc_commodity_obtain_twin(from->currency, book);
|
2003-10-20 08:34:03 -05:00
|
|
|
employee->ccard_acc =
|
|
|
|
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->ccard_acc), book));
|
|
|
|
|
2006-03-08 21:48:49 -06:00
|
|
|
qof_event_gen (&employee->inst.entity, QOF_EVENT_CREATE, NULL);
|
2003-10-20 08:34:03 -05:00
|
|
|
|
|
|
|
return employee;
|
|
|
|
}
|
|
|
|
|
|
|
|
GncEmployee *
|
|
|
|
gncEmployeeObtainTwin (GncEmployee *from, QofBook *book)
|
|
|
|
{
|
|
|
|
GncEmployee *employee;
|
|
|
|
if (!book) return NULL;
|
|
|
|
|
|
|
|
employee = (GncEmployee *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
|
|
|
if (!employee)
|
|
|
|
{
|
|
|
|
employee = gncCloneEmployee (from, book);
|
|
|
|
}
|
|
|
|
|
|
|
|
return employee;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ============================================================== */
|
2001-11-16 19:17:06 -06:00
|
|
|
/* Set Functions */
|
|
|
|
|
2002-11-03 18:41:01 -06:00
|
|
|
#define SET_STR(obj, member, str) { \
|
2003-10-14 16:20:55 -05:00
|
|
|
char * tmp; \
|
|
|
|
\
|
|
|
|
if (!safe_strcmp (member, str)) return; \
|
|
|
|
gncEmployeeBeginEdit (obj); \
|
|
|
|
tmp = CACHE_INSERT (str); \
|
|
|
|
CACHE_REMOVE (member); \
|
|
|
|
member = tmp; \
|
|
|
|
}
|
2001-11-16 19:17:06 -06:00
|
|
|
|
|
|
|
void gncEmployeeSetID (GncEmployee *employee, const char *id)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (!id) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR(employee, employee->id, id);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (!username) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR(employee, employee->username, username);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (!language) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR(employee, employee->language, language);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (!acl) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
SET_STR(employee, employee->acl, acl);
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (gnc_numeric_equal (workday, employee->workday)) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeBeginEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
employee->workday = workday;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (gnc_numeric_equal (rate, employee->rate)) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeBeginEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
employee->rate = rate;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2003-01-12 16:53:02 -06:00
|
|
|
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity *currency)
|
2002-03-04 13:34:52 -06:00
|
|
|
{
|
2003-01-12 16:53:02 -06:00
|
|
|
if (!employee || !currency) return;
|
|
|
|
if (employee->currency &&
|
|
|
|
gnc_commodity_equal (employee->currency, currency))
|
2002-06-21 14:00:34 -05:00
|
|
|
return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeBeginEdit (employee);
|
2003-01-12 16:53:02 -06:00
|
|
|
employee->currency = currency;
|
2002-03-04 13:34:52 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2002-03-04 13:34:52 -06:00
|
|
|
}
|
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (active == employee->active) return;
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeBeginEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
employee->active = active;
|
2002-03-02 12:55:01 -06:00
|
|
|
mark_employee (employee);
|
2002-11-03 18:41:01 -06:00
|
|
|
gncEmployeeCommitEdit (employee);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2003-03-09 16:51:04 -06:00
|
|
|
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc)
|
|
|
|
{
|
|
|
|
if (!employee) return;
|
|
|
|
if (ccard_acc == employee->ccard_acc) return;
|
|
|
|
gncEmployeeBeginEdit (employee);
|
|
|
|
employee->ccard_acc = ccard_acc;
|
|
|
|
mark_employee (employee);
|
|
|
|
gncEmployeeCommitEdit (employee);
|
|
|
|
}
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
void
|
|
|
|
qofEmployeeSetAddr (GncEmployee *employee, QofEntity *addr_ent)
|
|
|
|
{
|
|
|
|
GncAddress *addr;
|
|
|
|
|
|
|
|
if(!employee || !addr_ent) { return; }
|
|
|
|
addr = (GncAddress*)addr_ent;
|
|
|
|
if(addr == employee->addr) { return; }
|
|
|
|
if(employee->addr != NULL) { gncAddressDestroy(employee->addr); }
|
|
|
|
gncEmployeeBeginEdit(employee);
|
|
|
|
employee->addr = addr;
|
|
|
|
gncEmployeeCommitEdit(employee);
|
|
|
|
}
|
|
|
|
|
2003-10-20 08:34:03 -05:00
|
|
|
/* ============================================================== */
|
2001-11-16 19:17:06 -06:00
|
|
|
/* Get Functions */
|
|
|
|
const char * gncEmployeeGetID (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * gncEmployeeGetUsername (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
GncAddress * gncEmployeeGetAddr (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * gncEmployeeGetLanguage (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->language;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * gncEmployeeGetAcl (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->acl;
|
|
|
|
}
|
|
|
|
|
|
|
|
gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return gnc_numeric_zero();
|
|
|
|
return employee->workday;
|
|
|
|
}
|
|
|
|
|
|
|
|
gnc_numeric gncEmployeeGetRate (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return gnc_numeric_zero();
|
|
|
|
return employee->rate;
|
|
|
|
}
|
|
|
|
|
2003-01-12 16:53:02 -06:00
|
|
|
gnc_commodity * gncEmployeeGetCurrency (GncEmployee *employee)
|
2002-03-04 13:34:52 -06:00
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
2003-01-12 16:53:02 -06:00
|
|
|
return employee->currency;
|
2002-03-04 13:34:52 -06:00
|
|
|
}
|
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
gboolean gncEmployeeGetActive (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return FALSE;
|
|
|
|
return employee->active;
|
|
|
|
}
|
|
|
|
|
2003-03-09 16:51:04 -06:00
|
|
|
Account * gncEmployeeGetCCard (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return NULL;
|
|
|
|
return employee->ccard_acc;
|
|
|
|
}
|
|
|
|
|
2001-11-16 19:17:06 -06:00
|
|
|
gboolean gncEmployeeIsDirty (GncEmployee *employee)
|
|
|
|
{
|
|
|
|
if (!employee) return FALSE;
|
2003-10-14 16:20:55 -05:00
|
|
|
return (employee->inst.dirty || gncAddressIsDirty (employee->addr));
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2002-11-03 14:21:42 -06:00
|
|
|
void gncEmployeeBeginEdit (GncEmployee *employee)
|
2001-11-16 19:17:06 -06:00
|
|
|
{
|
2004-06-13 11:48:32 -05:00
|
|
|
QOF_BEGIN_EDIT (&employee->inst);
|
2002-11-03 14:21:42 -06:00
|
|
|
}
|
2001-11-16 19:17:06 -06:00
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
static inline void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode)
|
2002-11-03 14:21:42 -06:00
|
|
|
{
|
2003-06-26 22:36:02 -05:00
|
|
|
PERR("Employee QofBackend Failure: %d", errcode);
|
2002-11-03 14:21:42 -06:00
|
|
|
}
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
static inline void gncEmployeeOnDone (QofInstance *inst)
|
2002-11-03 14:21:42 -06:00
|
|
|
{
|
2003-10-14 16:20:55 -05:00
|
|
|
GncEmployee *employee = (GncEmployee *) inst;
|
2002-03-04 13:34:52 -06:00
|
|
|
gncAddressClearDirty (employee->addr);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2003-10-14 16:20:55 -05:00
|
|
|
static inline void emp_free (QofInstance *inst)
|
|
|
|
{
|
|
|
|
GncEmployee *employee = (GncEmployee *) inst;
|
|
|
|
gncEmployeeFree (employee);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-03 14:21:42 -06:00
|
|
|
void gncEmployeeCommitEdit (GncEmployee *employee)
|
|
|
|
{
|
2006-04-21 23:42:29 -05:00
|
|
|
if (!qof_commit_edit (QOF_INSTANCE(employee))) return;
|
2006-02-26 12:36:05 -06:00
|
|
|
qof_commit_edit_part2 (&employee->inst, gncEmployeeOnError,
|
2003-10-14 16:20:55 -05:00
|
|
|
gncEmployeeOnDone, emp_free);
|
2002-11-03 14:21:42 -06:00
|
|
|
}
|
|
|
|
|
2003-10-20 08:34:03 -05:00
|
|
|
/* ============================================================== */
|
2001-11-16 19:17:06 -06:00
|
|
|
/* Other functions */
|
|
|
|
|
2002-02-03 14:01:08 -06:00
|
|
|
int gncEmployeeCompare (GncEmployee *a, GncEmployee *b)
|
|
|
|
{
|
|
|
|
if (!a && !b) return 0;
|
|
|
|
if (!a && b) return 1;
|
|
|
|
if (a && !b) return -1;
|
|
|
|
|
|
|
|
return(strcmp(a->username, b->username));
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Package-Private functions */
|
|
|
|
|
|
|
|
static const char * _gncEmployeePrintable (gpointer item)
|
|
|
|
{
|
2003-10-19 00:13:59 -05:00
|
|
|
GncEmployee *v = item;
|
2001-11-16 19:17:06 -06:00
|
|
|
if (!item) return NULL;
|
2003-03-10 23:59:51 -06:00
|
|
|
return gncAddressGetName(v->addr);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2003-10-19 00:13:59 -05:00
|
|
|
static QofObject gncEmployeeDesc =
|
|
|
|
{
|
|
|
|
interface_version: QOF_OBJECT_VERSION,
|
|
|
|
e_type: _GNC_MOD_NAME,
|
|
|
|
type_label: "Employee",
|
2004-08-19 14:47:34 -05:00
|
|
|
create: (gpointer)gncEmployeeCreate,
|
2003-10-19 00:13:59 -05:00
|
|
|
book_begin: NULL,
|
|
|
|
book_end: NULL,
|
|
|
|
is_dirty: qof_collection_is_dirty,
|
|
|
|
mark_clean: qof_collection_mark_clean,
|
|
|
|
foreach: qof_collection_foreach,
|
|
|
|
printable: _gncEmployeePrintable,
|
2004-06-12 15:27:08 -05:00
|
|
|
version_cmp: (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
|
2001-11-16 19:17:06 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
gboolean gncEmployeeRegister (void)
|
|
|
|
{
|
2003-09-27 05:21:27 -05:00
|
|
|
static QofParam params[] = {
|
2004-07-26 07:41:43 -05:00
|
|
|
{ EMPLOYEE_ID, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetID, (QofSetterFunc)gncEmployeeSetID },
|
2004-08-19 14:47:34 -05:00
|
|
|
{ EMPLOYEE_USERNAME, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetUsername,
|
|
|
|
(QofSetterFunc)gncEmployeeSetUsername },
|
|
|
|
{ EMPLOYEE_LANGUAGE, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetLanguage,
|
|
|
|
(QofSetterFunc)gncEmployeeSetLanguage },
|
|
|
|
{ EMPLOYEE_ACL, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetAcl, (QofSetterFunc)gncEmployeeSetAcl },
|
|
|
|
{ EMPLOYEE_WORKDAY, QOF_TYPE_NUMERIC, (QofAccessFunc)gncEmployeeGetWorkday,
|
|
|
|
(QofSetterFunc)gncEmployeeSetWorkday },
|
|
|
|
{ EMPLOYEE_RATE, QOF_TYPE_NUMERIC, (QofAccessFunc)gncEmployeeGetRate, (QofSetterFunc)gncEmployeeSetRate },
|
2005-11-01 21:32:36 -06:00
|
|
|
{ EMPLOYEE_ADDR, GNC_ID_ADDRESS, (QofAccessFunc)gncEmployeeGetAddr, (QofSetterFunc)qofEmployeeSetAddr },
|
|
|
|
{ EMPLOYEE_CC, GNC_ID_ACCOUNT, (QofAccessFunc)gncEmployeeGetCCard, (QofSetterFunc)gncEmployeeSetCCard },
|
2004-07-26 07:41:43 -05:00
|
|
|
{ QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncEmployeeGetActive, (QofSetterFunc)gncEmployeeSetActive },
|
2004-05-23 12:31:40 -05:00
|
|
|
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
|
|
|
|
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
|
2002-02-03 14:01:08 -06:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
2003-09-27 11:33:06 -05:00
|
|
|
qof_class_register (_GNC_MOD_NAME, (QofSortFunc)gncEmployeeCompare,params);
|
2002-02-03 14:01:08 -06:00
|
|
|
|
2003-06-26 22:09:39 -05:00
|
|
|
return qof_object_register (&gncEmployeeDesc);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|
|
|
|
|
2003-06-26 22:05:25 -05:00
|
|
|
gint64 gncEmployeeNextID (QofBook *book)
|
2001-11-16 19:17:06 -06:00
|
|
|
{
|
2003-10-17 00:15:56 -05:00
|
|
|
return qof_book_get_counter (book, _GNC_MOD_NAME);
|
2001-11-16 19:17:06 -06:00
|
|
|
}
|