mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-01 13:09:41 -06:00
* src/business/business-core/gncEmployee.[ch]: added APIs to
store a Credit Card account for the employee. * src/business/business-core/file/gnc-employee-xml-v2.c: store the employee's CC Account in the XML file. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8048 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ef78bbefe6
commit
0087033ae2
@ -1,3 +1,10 @@
|
||||
2003-03-09 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/business/business-core/gncEmployee.[ch]: added APIs to
|
||||
store a Credit Card account for the employee.
|
||||
* src/business/business-core/file/gnc-employee-xml-v2.c:
|
||||
store the employee's CC Account in the XML file.
|
||||
|
||||
2003-03-08 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/import-export/import-backend.c:
|
||||
|
@ -66,6 +66,7 @@ const gchar *employee_version_string = "2.0.0";
|
||||
#define employee_workday_string "employee:workday"
|
||||
#define employee_rate_string "employee:rate"
|
||||
#define employee_currency_string "employee:currency"
|
||||
#define employee_ccard_string "employee:ccard"
|
||||
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
|
||||
@ -79,6 +80,7 @@ employee_dom_tree_create (GncEmployee *employee)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
gnc_numeric num;
|
||||
Account* ccard_acc;
|
||||
|
||||
ret = xmlNewNode(NULL, gnc_employee_string);
|
||||
xmlSetProp(ret, "version", employee_version_string);
|
||||
@ -112,6 +114,12 @@ employee_dom_tree_create (GncEmployee *employee)
|
||||
(ret,
|
||||
commodity_ref_to_dom_tree(employee_currency_string,
|
||||
gncEmployeeGetCurrency (employee)));
|
||||
|
||||
ccard_acc = gncEmployeeGetCCard (employee);
|
||||
if (ccard_acc)
|
||||
xmlAddChild(ret, guid_to_dom_tree(employee_ccard_string,
|
||||
xaccAccountGetGUID (ccard_acc)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -258,6 +266,25 @@ employee_currency_handler (xmlNodePtr node, gpointer employee_pdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
employee_ccard_handler (xmlNodePtr node, gpointer employee_pdata)
|
||||
{
|
||||
struct employee_pdata *pdata = employee_pdata;
|
||||
GUID *guid;
|
||||
Account *ccard_acc;
|
||||
|
||||
guid = dom_tree_to_guid(node);
|
||||
g_return_val_if_fail(guid, FALSE);
|
||||
|
||||
ccard_acc = xaccAccountLookup (guid, pdata->book);
|
||||
g_free(guid);
|
||||
|
||||
g_return_val_if_fail (ccard_acc, FALSE);
|
||||
gncEmployeeSetCCard (pdata->employee, ccard_acc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct dom_tree_handler employee_handlers_v2[] = {
|
||||
{ employee_username_string, employee_username_handler, 1, 0 },
|
||||
{ employee_guid_string, employee_guid_handler, 1, 0 },
|
||||
@ -270,6 +297,7 @@ static struct dom_tree_handler employee_handlers_v2[] = {
|
||||
{ employee_rate_string, employee_rate_handler, 1, 0 },
|
||||
{ employee_currency_string, employee_currency_handler, 0, 0 }, /* XXX */
|
||||
{ "employee:commodity", employee_currency_handler, 0, 0 }, /* XXX */
|
||||
{ employee_ccard_string, employee_ccard_handler, 0, 0 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -38,6 +38,8 @@ struct _gncEmployee {
|
||||
gboolean active;
|
||||
gboolean dirty;
|
||||
|
||||
Account * ccard_acc;
|
||||
|
||||
int editlevel;
|
||||
gboolean do_free;
|
||||
};
|
||||
@ -215,6 +217,16 @@ void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
|
||||
gncEmployeeCommitEdit (employee);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* Get Functions */
|
||||
|
||||
GNCBook * gncEmployeeGetBook (GncEmployee *employee)
|
||||
@ -283,6 +295,12 @@ gboolean gncEmployeeGetActive (GncEmployee *employee)
|
||||
return employee->active;
|
||||
}
|
||||
|
||||
Account * gncEmployeeGetCCard (GncEmployee *employee)
|
||||
{
|
||||
if (!employee) return NULL;
|
||||
return employee->ccard_acc;
|
||||
}
|
||||
|
||||
GncEmployee * gncEmployeeLookup (GNCBook *book, const GUID *guid)
|
||||
{
|
||||
if (!book || !guid) return NULL;
|
||||
|
@ -11,6 +11,7 @@ typedef struct _gncEmployee GncEmployee;
|
||||
|
||||
#include "gnc-book.h"
|
||||
#include "gncAddress.h"
|
||||
#include "Account.h"
|
||||
|
||||
#define GNC_EMPLOYEE_MODULE_NAME "gncEmployee"
|
||||
|
||||
@ -29,6 +30,7 @@ void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday);
|
||||
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate);
|
||||
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity * currency);
|
||||
void gncEmployeeSetActive (GncEmployee *employee, gboolean active);
|
||||
void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc);
|
||||
|
||||
/* Get Functions */
|
||||
|
||||
@ -43,6 +45,7 @@ gnc_numeric gncEmployeeGetWorkday (GncEmployee *employee);
|
||||
gnc_numeric gncEmployeeGetRate (GncEmployee *employee);
|
||||
gnc_commodity * gncEmployeeGetCurrency (GncEmployee *employee);
|
||||
gboolean gncEmployeeGetActive (GncEmployee *employee);
|
||||
Account * gncEmployeeGetCCard (GncEmployee *employee);
|
||||
|
||||
GncEmployee * gncEmployeeLookup (GNCBook *book, const GUID *guid);
|
||||
gboolean gncEmployeeIsDirty (GncEmployee *employee);
|
||||
|
Loading…
Reference in New Issue
Block a user