mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
change address to use entity instead of naked guid
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9579 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
0bcc7874a0
commit
6444e8169b
@ -20,8 +20,7 @@
|
||||
struct _gncAddress
|
||||
{
|
||||
QofBook * book;
|
||||
const GUID * parent_guid;
|
||||
QofIdType parent_type;
|
||||
QofEntity * parent;
|
||||
gboolean dirty;
|
||||
char * name;
|
||||
char * addr1;
|
||||
@ -44,13 +43,13 @@ mark_address (GncAddress *address)
|
||||
{
|
||||
address->dirty = TRUE;
|
||||
|
||||
gnc_engine_generate_event (address->parent_guid, address->parent_type, GNC_EVENT_MODIFY);
|
||||
gnc_engine_gen_event (address->parent, GNC_EVENT_MODIFY);
|
||||
}
|
||||
|
||||
/* Create/Destroy functions */
|
||||
|
||||
GncAddress *
|
||||
gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype)
|
||||
gncAddressCreate (QofBook *book, QofEntity *prnt)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
@ -59,8 +58,7 @@ gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype)
|
||||
addr = g_new0 (GncAddress, 1);
|
||||
addr->book = book;
|
||||
addr->dirty = FALSE;
|
||||
addr->parent_guid = parent;
|
||||
addr->parent_type = ptype;
|
||||
addr->parent = prnt;
|
||||
|
||||
addr->name = CACHE_INSERT ("");
|
||||
addr->addr1 = CACHE_INSERT ("");
|
||||
@ -84,8 +82,7 @@ gncCloneAddress (GncAddress *from, QofBook *book)
|
||||
addr = g_new0 (GncAddress, 1);
|
||||
addr->book = book;
|
||||
addr->dirty = TRUE;
|
||||
addr->parent_guid = from->parent_guid;
|
||||
addr->parent_type = from->parent_type;
|
||||
addr->parent = from->parent;
|
||||
|
||||
addr->name = CACHE_INSERT (from->name);
|
||||
addr->addr1 = CACHE_INSERT (from->addr1);
|
||||
|
@ -8,13 +8,14 @@
|
||||
#define GNC_ADDRESS_H_
|
||||
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
|
||||
#define GNC_ADDRESS_MODULE_NAME "gncAddress"
|
||||
|
||||
typedef struct _gncAddress GncAddress;
|
||||
|
||||
/* Create/Destroy functions */
|
||||
GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype);
|
||||
GncAddress * gncAddressCreate (QofBook *book, QofEntity *parent);
|
||||
|
||||
/** make a copy of the address, but associate it with a different book */
|
||||
GncAddress * gncCloneAddress (GncAddress *from, QofBook *book);
|
||||
|
@ -113,14 +113,14 @@ GncCustomer *gncCustomerCreate (QofBook *book)
|
||||
cust->id = CACHE_INSERT ("");
|
||||
cust->name = CACHE_INSERT ("");
|
||||
cust->notes = CACHE_INSERT ("");
|
||||
cust->addr = gncAddressCreate (book, &cust->inst.entity.guid, _GNC_MOD_NAME);
|
||||
cust->addr = gncAddressCreate (book, &cust->inst.entity);
|
||||
cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
cust->active = TRUE;
|
||||
cust->jobs = NULL;
|
||||
|
||||
cust->discount = gnc_numeric_zero();
|
||||
cust->credit = gnc_numeric_zero();
|
||||
cust->shipaddr = gncAddressCreate (book, &cust->inst.entity.guid, _GNC_MOD_NAME);
|
||||
cust->shipaddr = gncAddressCreate (book, &cust->inst.entity);
|
||||
|
||||
gnc_engine_gen_event (&cust->inst.entity, GNC_EVENT_CREATE);
|
||||
|
||||
|
@ -100,7 +100,7 @@ GncEmployee *gncEmployeeCreate (QofBook *book)
|
||||
employee->username = CACHE_INSERT ("");
|
||||
employee->language = CACHE_INSERT ("");
|
||||
employee->acl = CACHE_INSERT ("");
|
||||
employee->addr = gncAddressCreate (book, &employee->inst.entity.guid, _GNC_MOD_NAME);
|
||||
employee->addr = gncAddressCreate (book, &employee->inst.entity);
|
||||
employee->workday = gnc_numeric_zero();
|
||||
employee->rate = gnc_numeric_zero();
|
||||
employee->active = TRUE;
|
||||
|
@ -103,7 +103,7 @@ GncVendor *gncVendorCreate (QofBook *book)
|
||||
vendor->id = CACHE_INSERT ("");
|
||||
vendor->name = CACHE_INSERT ("");
|
||||
vendor->notes = CACHE_INSERT ("");
|
||||
vendor->addr = gncAddressCreate (book, &vendor->inst.entity.guid, _GNC_MOD_NAME);
|
||||
vendor->addr = gncAddressCreate (book, &vendor->inst.entity);
|
||||
vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
vendor->active = TRUE;
|
||||
vendor->jobs = NULL;
|
||||
|
@ -17,13 +17,18 @@ test_string_fcn (GncAddress *address, const char *message,
|
||||
static void
|
||||
test_address (void)
|
||||
{
|
||||
QofEntity ent;
|
||||
GncAddress *address;
|
||||
QofBook *book = qof_book_new ();
|
||||
|
||||
ent.e_type = "asdf";
|
||||
ent.guid = *guid_null();
|
||||
|
||||
/* Test creation/destruction */
|
||||
{
|
||||
do_test (gncAddressCreate (NULL, NULL, NULL) == NULL, "address create NULL");
|
||||
address = gncAddressCreate (book, NULL, "x");
|
||||
do_test (gncAddressCreate (NULL, NULL) == NULL, "address create NULL");
|
||||
|
||||
address = gncAddressCreate (book, &ent);
|
||||
do_test (address != NULL, "address create");
|
||||
|
||||
gncAddressDestroy (address);
|
||||
@ -32,7 +37,7 @@ test_address (void)
|
||||
|
||||
/* Test setting routines */
|
||||
{
|
||||
address = gncAddressCreate (book, NULL, "x");
|
||||
address = gncAddressCreate (book, &ent);
|
||||
test_string_fcn (address, "Name", gncAddressSetName, gncAddressGetName);
|
||||
test_string_fcn (address, "Addr1", gncAddressSetAddr1, gncAddressGetAddr1);
|
||||
test_string_fcn (address, "Addr2", gncAddressSetAddr2, gncAddressGetAddr2);
|
||||
|
Loading…
Reference in New Issue
Block a user