mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Delete qofinstance_gemini and all related functions; they were left over from the clone-the-book-when-closing code abandoned in 2005
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21203 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1028,16 +1028,6 @@ xaccCloneAccountCommon(const Account *from, QofBook *book)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Account *
|
||||
xaccCloneAccount (const Account *from, QofBook *book)
|
||||
{
|
||||
Account *ret = xaccCloneAccountCommon(from, book);
|
||||
qof_instance_gemini (&ret->inst, (QofInstance *) &from->inst);
|
||||
g_assert (ret ==
|
||||
(Account*) qof_instance_lookup_twin (QOF_INSTANCE(from), book));
|
||||
return ret;
|
||||
}
|
||||
|
||||
Account *
|
||||
xaccCloneAccountSimple (const Account *from, QofBook *book)
|
||||
{
|
||||
@@ -4517,58 +4507,6 @@ gnc_account_join_children (Account *to_parent, Account *from_parent)
|
||||
g_list_free(children);
|
||||
LEAVE (" ");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_account_copy_children (Account *to, Account *from)
|
||||
{
|
||||
AccountPrivate *to_priv, *from_priv;
|
||||
GList *node;
|
||||
QofBook *to_book;
|
||||
|
||||
/* errors */
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(to));
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(from));
|
||||
|
||||
/* optimizations */
|
||||
to_priv = GET_PRIVATE(to);
|
||||
from_priv = GET_PRIVATE(from);
|
||||
if (!from_priv->children)
|
||||
return;
|
||||
|
||||
to_book = gnc_account_get_book(to);
|
||||
if (!to_book) return;
|
||||
|
||||
ENTER (" ");
|
||||
xaccAccountBeginEdit(to);
|
||||
xaccAccountBeginEdit(from);
|
||||
for (node = from_priv->children; node; node = node->next)
|
||||
{
|
||||
Account *to_acc, *from_acc = node->data;
|
||||
|
||||
/* This will copy the basic data and the KVP. It will
|
||||
* not copy any splits/transactions. It will gemini. */
|
||||
to_acc = xaccCloneAccount (from_acc, to_book);
|
||||
|
||||
xaccAccountBeginEdit (to_acc);
|
||||
to_priv->children = g_list_append(to_priv->children, to_acc);
|
||||
|
||||
GET_PRIVATE(to_acc)->parent = to;
|
||||
qof_instance_set_dirty(&to_acc->inst);
|
||||
|
||||
/* Copy child accounts too. */
|
||||
if (GET_PRIVATE(from_acc)->children)
|
||||
{
|
||||
gnc_account_copy_children(to_acc, from_acc);
|
||||
}
|
||||
xaccAccountCommitEdit (to_acc);
|
||||
qof_event_gen (&to_acc->inst, QOF_EVENT_CREATE, NULL);
|
||||
/* DRH - Should this send ADD/REMOVE events */
|
||||
}
|
||||
xaccAccountCommitEdit(from);
|
||||
xaccAccountCommitEdit(to);
|
||||
LEAVE (" ");
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
@@ -177,14 +177,6 @@ Account * xaccMallocAccount (QofBook *book);
|
||||
/** Create a new root level account. */
|
||||
Account * gnc_account_create_root (QofBook *book);
|
||||
|
||||
/** The xaccCloneAccount() does the same as xaccCloneAccountSimple(),
|
||||
* except that it also also places a pair of GncGUID-pointers
|
||||
* of each account to the other, in the other's kvp slot.
|
||||
* The guid pointers are stored under the under the kvp
|
||||
* path "gemini".
|
||||
*/
|
||||
Account * xaccCloneAccount (const Account *source, QofBook *book);
|
||||
|
||||
/** The xaccCloneAccountSimple() routine makes a simple copy of the
|
||||
* indicated account, placing it in the indicated book. It copies
|
||||
* the account type, name, description, and the kvp values;
|
||||
@@ -192,8 +184,6 @@ Account * xaccCloneAccount (const Account *source, QofBook *book);
|
||||
* a commodity table in it that has commodities with the same
|
||||
* unique name as the ones being copied in the account (the
|
||||
* commodities in the clone will be those from the book).
|
||||
* Note that this routines does *NOT* use the 'gemini' kvp value
|
||||
* to indicate where it was copied from.
|
||||
*/
|
||||
Account * xaccCloneAccountSimple (const Account *source, QofBook *book);
|
||||
|
||||
@@ -889,15 +879,6 @@ gpointer gnc_account_foreach_descendant_until (const Account *account,
|
||||
*/
|
||||
void gnc_account_join_children (Account *to_parent, Account *from_parent);
|
||||
|
||||
/** The gnc_account_copy_children() subroutine will copy all child
|
||||
* accounts from the "src" account to the "dest" account, preserving
|
||||
* the account hierarchy. It will also take care that the moved
|
||||
* accounts will have the "dest" account's book parent as well. This
|
||||
* routine will *NOT* copy any splits/transactions. It will copy the
|
||||
* KVP trees in each account.
|
||||
*/
|
||||
void gnc_account_copy_children (Account *dest, Account *src);
|
||||
|
||||
/** The gnc_account_merge_children() subroutine will go through an
|
||||
* account, merging all child accounts that have the same name and
|
||||
* description. This function is useful when importing Quicken(TM)
|
||||
|
||||
@@ -357,31 +357,6 @@ qofAddressGetOwner(const GncAddress *addr)
|
||||
return addr->parent;
|
||||
}
|
||||
|
||||
GncAddress *
|
||||
gncCloneAddress (const GncAddress *from, QofInstance *new_parent, QofBook *book)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
addr = g_object_new (GNC_TYPE_ADDRESS, NULL);
|
||||
qof_instance_init_data(&addr->inst, GNC_ID_ADDRESS, book);
|
||||
addr->book = book;
|
||||
addr->dirty = TRUE;
|
||||
addr->parent = new_parent;
|
||||
|
||||
addr->name = CACHE_INSERT (from->name);
|
||||
addr->addr1 = CACHE_INSERT (from->addr1);
|
||||
addr->addr2 = CACHE_INSERT (from->addr2);
|
||||
addr->addr3 = CACHE_INSERT (from->addr3);
|
||||
addr->addr4 = CACHE_INSERT (from->addr4);
|
||||
addr->phone = CACHE_INSERT (from->phone);
|
||||
addr->fax = CACHE_INSERT (from->fax);
|
||||
addr->email = CACHE_INSERT (from->email);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void
|
||||
gncAddressDestroy (GncAddress *addr)
|
||||
{
|
||||
|
||||
@@ -32,8 +32,4 @@
|
||||
|
||||
gboolean gncAddressRegister (void);
|
||||
|
||||
/** Make a copy of the address, setting the parent to 'new_parent' */
|
||||
GncAddress * gncCloneAddress (const GncAddress *from, QofInstance *new_parent, QofBook *book);
|
||||
|
||||
|
||||
#endif /* GNC_ADDRESSP_H_ */
|
||||
|
||||
@@ -302,68 +302,6 @@ static void gncBillTermFree (GncBillTerm *term)
|
||||
g_object_unref (term);
|
||||
}
|
||||
|
||||
GncBillTerm *
|
||||
gncCloneBillTerm (GncBillTerm *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncBillTerm *term;
|
||||
|
||||
if (!book || !from) return NULL;
|
||||
|
||||
term = g_object_new (GNC_TYPE_BILLTERM, NULL);
|
||||
qof_instance_init_data(&term->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&term->inst, &from->inst);
|
||||
|
||||
term->name = CACHE_INSERT (from->name);
|
||||
term->desc = CACHE_INSERT (from->desc);
|
||||
term->type = from->type;
|
||||
term->due_days = from->due_days;
|
||||
term->disc_days = from->disc_days;
|
||||
term->discount = from->discount;
|
||||
term->cutoff = from->cutoff;
|
||||
term->invisible = from->invisible;
|
||||
|
||||
term->refcount = 0;
|
||||
|
||||
/* Make copies of parents and children. Note that this can be
|
||||
* a recursive copy ... treat as doubly-linked list. */
|
||||
if (from->child)
|
||||
{
|
||||
term->child = gncBillTermObtainTwin (from->child, book);
|
||||
term->child->parent = term;
|
||||
}
|
||||
if (from->parent)
|
||||
{
|
||||
term->parent = gncBillTermObtainTwin (from->parent, book);
|
||||
term->parent->child = term;
|
||||
}
|
||||
for (node = g_list_last(from->children); node; node = node->next)
|
||||
{
|
||||
GncBillTerm *btrm = node->data;
|
||||
btrm = gncBillTermObtainTwin (btrm, book);
|
||||
btrm->parent = term;
|
||||
term->children = g_list_prepend(term->children, btrm);
|
||||
}
|
||||
|
||||
addObj (term);
|
||||
qof_event_gen (&term->inst, QOF_EVENT_CREATE, NULL);
|
||||
return term;
|
||||
}
|
||||
|
||||
GncBillTerm *
|
||||
gncBillTermObtainTwin (GncBillTerm *from, QofBook *book)
|
||||
{
|
||||
GncBillTerm *term;
|
||||
if (!from) return NULL;
|
||||
|
||||
term = (GncBillTerm *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!term)
|
||||
{
|
||||
term = gncCloneBillTerm (from, book);
|
||||
}
|
||||
return term;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -40,30 +40,6 @@ void gncBillTermMakeInvisible (GncBillTerm *term);
|
||||
|
||||
gboolean gncBillTermGetInvisible (const GncBillTerm *term);
|
||||
|
||||
/** The gncCloneBillTerm() routine makes a copy of the indicated
|
||||
* bill term, placing it in the indicated book. It copies
|
||||
* the name, description, type, due-days, discount, etc.
|
||||
* It also copies (as needed) both parents and children, so that
|
||||
* the parent-child relationship is correctly mirrored in the
|
||||
* clone.
|
||||
* XXX the refcount is mis-handled. This needs fixin....
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncBillTerm * gncCloneBillTerm (GncBillTerm *from, QofBook *);
|
||||
|
||||
/** The gncBillTermObtainTwin() will find the 'twin' of the
|
||||
* indicated bill term in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneBillTerm()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncBillTerm * gncBillTermObtainTwin (GncBillTerm *from, QofBook *book);
|
||||
|
||||
#define gncBillTermSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
|
||||
|
||||
@@ -276,50 +276,6 @@ GncCustomer *gncCustomerCreate (QofBook *book)
|
||||
return cust;
|
||||
}
|
||||
|
||||
/** Create a copy of a customer, placing the copy into a new book. */
|
||||
GncCustomer *
|
||||
gncCloneCustomer (GncCustomer *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncCustomer *cust;
|
||||
|
||||
cust = g_object_new (GNC_TYPE_CUSTOMER, NULL);
|
||||
|
||||
qof_instance_init_data (&cust->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&cust->inst, &from->inst);
|
||||
|
||||
cust->id = CACHE_INSERT (from->id);
|
||||
cust->name = CACHE_INSERT (from->name);
|
||||
cust->notes = CACHE_INSERT (from->notes);
|
||||
cust->discount = from->discount;
|
||||
cust->credit = from->credit;
|
||||
cust->taxincluded = from->taxincluded;
|
||||
cust->active = from->active;
|
||||
cust->taxtable_override = from->taxtable_override;
|
||||
|
||||
cust->addr = gncCloneAddress (from->addr, &cust->inst, book);
|
||||
cust->shipaddr = gncCloneAddress (from->shipaddr, &cust->inst, book);
|
||||
|
||||
/* Find the matching currency in the new book, assumes
|
||||
* currency has already been copied into new book. */
|
||||
cust->currency = gnc_commodity_obtain_twin (from->currency, book);
|
||||
|
||||
/* Find the matching bill term, tax table in the new book */
|
||||
cust->terms = gncBillTermObtainTwin(from->terms, book);
|
||||
cust->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
|
||||
|
||||
for (node = g_list_last(cust->jobs); node; node = node->next)
|
||||
{
|
||||
GncJob *job = node->data;
|
||||
job = gncJobObtainTwin (job, book);
|
||||
cust->jobs = g_list_prepend(cust->jobs, job);
|
||||
}
|
||||
|
||||
qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return cust;
|
||||
}
|
||||
|
||||
void gncCustomerDestroy (GncCustomer *cust)
|
||||
{
|
||||
if (!cust) return;
|
||||
@@ -354,20 +310,6 @@ static void gncCustomerFree (GncCustomer *cust)
|
||||
g_object_unref (cust);
|
||||
}
|
||||
|
||||
GncCustomer *
|
||||
gncCustomerObtainTwin (GncCustomer *from, QofBook *book)
|
||||
{
|
||||
GncCustomer *cust;
|
||||
if (!from) return NULL;
|
||||
|
||||
cust = (GncCustomer *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!cust)
|
||||
{
|
||||
cust = gncCloneCustomer (from, book);
|
||||
}
|
||||
return cust;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -34,25 +34,6 @@
|
||||
gboolean gncCustomerRegister (void);
|
||||
gchar *gncCustomerNextID (QofBook *book);
|
||||
|
||||
/** The gncCloneCustomer() routine makes a copy of the indicated
|
||||
* customer, placing it in the indicated book. It copies
|
||||
* the addresses, credits, currency, billing terms and jobs.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
GncCustomer * gncCloneCustomer (GncCustomer *from, QofBook *book);
|
||||
|
||||
/** The gncCustomerObtainTwin() will find the 'twin' of the
|
||||
* indicated customer in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneCustomer()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncCustomer * gncCustomerObtainTwin (GncCustomer *from, QofBook *book);
|
||||
|
||||
#define gncCustomerSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_CUSTOMERP_H_ */
|
||||
|
||||
@@ -279,48 +279,6 @@ static void gncEmployeeFree (GncEmployee *employee)
|
||||
g_object_unref (employee);
|
||||
}
|
||||
|
||||
GncEmployee *
|
||||
gncCloneEmployee (GncEmployee *from, QofBook *book)
|
||||
{
|
||||
GncEmployee *employee;
|
||||
if (!book || !from) return NULL;
|
||||
|
||||
employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL);
|
||||
qof_instance_init_data(&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);
|
||||
employee->addr = gncCloneAddress (from->addr, &employee->inst, book);
|
||||
employee->workday = from->workday;
|
||||
employee->rate = from->rate;
|
||||
employee->active = from->active;
|
||||
employee->currency = gnc_commodity_obtain_twin(from->currency, book);
|
||||
employee->ccard_acc =
|
||||
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->ccard_acc), book));
|
||||
|
||||
qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -34,29 +34,6 @@
|
||||
gboolean gncEmployeeRegister (void);
|
||||
gchar *gncEmployeeNextID (QofBook *book);
|
||||
|
||||
/** The gncCloneEmployee() routine makes a copy of the indicated
|
||||
* employee, placing it in the indicated book. It copies
|
||||
* the username, address, currency, ccard account, etc.
|
||||
* It also copies (as needed) both parents and children, so that
|
||||
* the parent-child relationship is correctly mirrored in the
|
||||
* clone.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncEmployee * gncCloneEmployee (GncEmployee *from, QofBook *);
|
||||
|
||||
/** The gncEmployeeObtainTwin() will find the 'twin' of the
|
||||
* indicated employee in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneEmployee()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncEmployee * gncEmployeeObtainTwin (GncEmployee *from, QofBook *book);
|
||||
|
||||
#define gncEmployeeSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_EMPLOYEEP_H_ */
|
||||
|
||||
@@ -418,29 +418,6 @@ static void gncEntryFree (GncEntry *entry)
|
||||
g_object_unref (entry);
|
||||
}
|
||||
|
||||
GncEntry *
|
||||
gncCloneEntry (GncEntry *from, QofBook *book)
|
||||
{
|
||||
/* XXX unfinished */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GncEntry *
|
||||
gncEntryObtainTwin (GncEntry *from, QofBook *book)
|
||||
{
|
||||
GncEntry *entry;
|
||||
if (!book) return NULL;
|
||||
|
||||
entry = (GncEntry *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!entry)
|
||||
{
|
||||
entry = gncCloneEntry (from, book);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================ */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -38,27 +38,6 @@ void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice);
|
||||
void gncEntrySetBill (GncEntry *entry, GncInvoice *bill);
|
||||
void gncEntrySetDirty (GncEntry *entry, gboolean dirty);
|
||||
|
||||
|
||||
/** The gncCloneEntry() routine makes a copy of the indicated
|
||||
* entry, placing it in the indicated book. It copies
|
||||
* the whole kit-n-kaboodle.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncEntry * gncCloneEntry (GncEntry *from, QofBook *);
|
||||
|
||||
/** The gncEntryObtainTwin() will find the 'twin' of the
|
||||
* indicated entry in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneEntry()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncEntry * gncEntryObtainTwin (GncEntry *from, QofBook *book);
|
||||
|
||||
#define gncEntrySetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_ENTRYP_H_ */
|
||||
|
||||
@@ -406,81 +406,6 @@ static void gncInvoiceFree (GncInvoice *invoice)
|
||||
g_object_unref (invoice);
|
||||
}
|
||||
|
||||
GncInvoice *
|
||||
gncCloneInvoice (GncInvoice *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncInvoice *invoice;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
invoice = g_object_new (GNC_TYPE_INVOICE, NULL);
|
||||
qof_instance_init_data (&invoice->inst, _GNC_MOD_NAME, book);
|
||||
|
||||
invoice->id = CACHE_INSERT (from->id);
|
||||
invoice->notes = CACHE_INSERT (from->notes);
|
||||
invoice->billing_id = CACHE_INSERT (from->billing_id);
|
||||
invoice->active = from->active;
|
||||
|
||||
invoice->billto = gncCloneOwner (&from->billto, book);
|
||||
invoice->owner = gncCloneOwner (&from->owner, book);
|
||||
invoice->job = (GncJob*)gncJobObtainTwin (from->job, book);
|
||||
invoice->terms = gncBillTermObtainTwin (from->terms, book);
|
||||
gncBillTermIncRef (invoice->terms);
|
||||
|
||||
|
||||
invoice->to_charge_amount = from->to_charge_amount;
|
||||
invoice->printname = NULL; /* that's right, NULL. See below. */
|
||||
invoice->date_opened = from->date_opened;
|
||||
invoice->date_posted = from->date_posted;
|
||||
|
||||
invoice->currency = gnc_commodity_obtain_twin (from->currency, book);
|
||||
|
||||
invoice->entries = NULL;
|
||||
for (node = g_list_last(from->entries); node; node = node->next)
|
||||
{
|
||||
GncEntry *entry = node->data;
|
||||
entry = gncEntryObtainTwin (entry, book);
|
||||
invoice->entries = g_list_prepend (invoice->entries, entry);
|
||||
}
|
||||
|
||||
invoice->prices = NULL;
|
||||
for (node = g_list_last(from->prices); node; node = node->next)
|
||||
{
|
||||
GNCPrice *price = node->data;
|
||||
price = gnc_price_clone(price, book);
|
||||
invoice->prices = g_list_prepend (invoice->prices, price);
|
||||
}
|
||||
|
||||
/* XXX should probably be obtain-twin not lookup-twin */
|
||||
invoice->posted_acc =
|
||||
GNC_ACCOUNT(qof_instance_lookup_twin(QOF_INSTANCE(from->posted_acc), book));
|
||||
#if 0
|
||||
XXX not done * /
|
||||
Transaction * posted_txn;
|
||||
GNCLot * posted_lot;
|
||||
#endif
|
||||
|
||||
qof_event_gen (&invoice->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return invoice;
|
||||
}
|
||||
|
||||
GncInvoice *
|
||||
gncInvoiceObtainTwin (GncInvoice *from, QofBook *book)
|
||||
{
|
||||
GncInvoice *invoice;
|
||||
if (!book) return NULL;
|
||||
|
||||
invoice = (GncInvoice *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!invoice)
|
||||
{
|
||||
invoice = gncCloneInvoice (from, book);
|
||||
}
|
||||
|
||||
return invoice;
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -41,28 +41,5 @@ void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
|
||||
void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot);
|
||||
void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn);
|
||||
|
||||
|
||||
/** The gncCloneInvoice() routine makes a copy of the indicated
|
||||
* invoice, placing it in the indicated book. It copies
|
||||
* the name, description, type, due-days, discount, etc.
|
||||
* It also copies (as needed) both parents and children, so that
|
||||
* the parent-child relationship is correctly mirrored in the
|
||||
* clone.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncInvoice * gncCloneInvoice (GncInvoice *from, QofBook *);
|
||||
|
||||
/** The gncInvoiceObtainTwin() will find the 'twin' of the
|
||||
* indicated invoice in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneInvoice()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncInvoice * gncInvoiceObtainTwin (GncInvoice *from, QofBook *book);
|
||||
#define gncInvoiceSetGUID(I,G) qof_instance_set_guid(QOF_INSTANCE(I),(G))
|
||||
#endif /* GNC_INVOICEP_H_ */
|
||||
|
||||
@@ -199,29 +199,6 @@ GncJob *gncJobCreate (QofBook *book)
|
||||
return job;
|
||||
}
|
||||
|
||||
GncJob *
|
||||
gncCloneJob (GncJob *from, QofBook *book)
|
||||
{
|
||||
GncJob *job;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
job = g_object_new (GNC_TYPE_JOB, NULL);
|
||||
qof_instance_init_data (&job->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&job->inst, &from->inst);
|
||||
|
||||
job->id = CACHE_INSERT (from->id);
|
||||
job->name = CACHE_INSERT (from->name);
|
||||
job->desc = CACHE_INSERT (from->desc);
|
||||
job->active = from->active;
|
||||
|
||||
job->owner = gncCloneOwner(&from->owner, book);
|
||||
|
||||
qof_event_gen (&job->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
void gncJobDestroy (GncJob *job)
|
||||
{
|
||||
if (!job) return;
|
||||
@@ -255,19 +232,6 @@ static void gncJobFree (GncJob *job)
|
||||
g_object_unref (job);
|
||||
}
|
||||
|
||||
GncJob *
|
||||
gncJobObtainTwin (GncJob *from, QofBook *book)
|
||||
{
|
||||
GncJob *job;
|
||||
if (!from) return NULL;
|
||||
|
||||
job = (GncJob *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!job)
|
||||
{
|
||||
job = gncCloneJob (from, book);
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
@@ -34,25 +34,6 @@
|
||||
gboolean gncJobRegister (void);
|
||||
gchar *gncJobNextID (QofBook *book);
|
||||
|
||||
/** The gncCloneTaxTable() routine makes a copy of the indicated
|
||||
* tax table, placing it in the indicated book. It copies
|
||||
* the id, name description and owner.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
GncJob * gncCloneJob (GncJob *from, QofBook *book);
|
||||
|
||||
/** The gncJobObtainTwin() will find the 'twin' of the
|
||||
* indicated job in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneJob()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncJob * gncJobObtainTwin (GncJob *from, QofBook *book);
|
||||
|
||||
#define gncJobSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
#endif /* GNC_JOBP_H_ */
|
||||
|
||||
@@ -236,57 +236,6 @@ static void gncOrderFree (GncOrder *order)
|
||||
g_object_unref (order);
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
gncCloneOrder (GncOrder *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncOrder *order;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
order = g_object_new (GNC_TYPE_ORDER, NULL);
|
||||
qof_instance_init_data (&order->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&order->inst, &from->inst);
|
||||
|
||||
order->id = CACHE_INSERT (from->id);
|
||||
order->notes = CACHE_INSERT (from->notes);
|
||||
order->reference = CACHE_INSERT (from->reference);
|
||||
|
||||
order->active = from->active;
|
||||
order->printname = NULL; /* yes, null, that's right */
|
||||
order->opened = from->opened;
|
||||
order->closed = from->closed;
|
||||
|
||||
order->owner = gncCloneOwner (&from->owner, book);
|
||||
|
||||
order->entries = NULL;
|
||||
for (node = g_list_last(from->entries); node; node = node->prev)
|
||||
{
|
||||
GncEntry *entry = node->data;
|
||||
entry = gncEntryObtainTwin (entry, book);
|
||||
order->entries = g_list_prepend (order->entries, entry);
|
||||
}
|
||||
|
||||
qof_event_gen (&order->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
gncOrderObtainTwin (GncOrder *from, QofBook *book)
|
||||
{
|
||||
GncOrder *order;
|
||||
if (!book) return NULL;
|
||||
|
||||
order = (GncOrder *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!order)
|
||||
{
|
||||
order = gncCloneOrder (from, book);
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -34,26 +34,6 @@
|
||||
gboolean gncOrderRegister (void);
|
||||
gchar *gncOrderNextID (QofBook *book);
|
||||
|
||||
/** The gncCloneOrder() routine makes a copy of the indicated
|
||||
* order, placing it in the indicated book. It copies
|
||||
* the id, notes, reference, etc.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncOrder * gncCloneOrder (GncOrder *from, QofBook *);
|
||||
|
||||
/** The gncOrderObtainTwin() will find the 'twin' of the
|
||||
* indicated order in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneOrder()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncOrder * gncOrderObtainTwin (GncOrder *from, QofBook *book);
|
||||
|
||||
#define gncOrderSetGUID(O,G) qof_instance_set_guid(QOF_INSTANCE(O),(G))
|
||||
|
||||
#endif /* GNC_ORDERP_H_ */
|
||||
|
||||
@@ -378,36 +378,6 @@ void gncOwnerCopy (const GncOwner *src, GncOwner *dest)
|
||||
memcpy (dest, src, sizeof (*dest));
|
||||
}
|
||||
|
||||
GncOwner
|
||||
gncCloneOwner (const GncOwner *from, QofBook *book)
|
||||
{
|
||||
GncOwner owner = { GNC_OWNER_NONE };
|
||||
if (!from) return owner;
|
||||
owner.type = from->type;
|
||||
switch (from->type)
|
||||
{
|
||||
case GNC_OWNER_NONE:
|
||||
return owner;
|
||||
case GNC_OWNER_UNDEFINED:
|
||||
owner.owner.undefined = from->owner.undefined; /* XXX probably wrong ! */
|
||||
return owner;
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
owner.owner.customer = gncCustomerObtainTwin (from->owner.customer, book);
|
||||
return owner;
|
||||
case GNC_OWNER_JOB:
|
||||
owner.owner.job = gncJobObtainTwin (from->owner.job, book);
|
||||
return owner;
|
||||
case GNC_OWNER_VENDOR:
|
||||
owner.owner.vendor = gncVendorObtainTwin (from->owner.vendor, book);
|
||||
return owner;
|
||||
case GNC_OWNER_EMPLOYEE:
|
||||
owner.owner.employee = gncEmployeeObtainTwin (from->owner.employee, book);
|
||||
return owner;
|
||||
default:
|
||||
return owner;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b)
|
||||
{
|
||||
if (!a || !b) return FALSE;
|
||||
|
||||
@@ -32,9 +32,5 @@
|
||||
|
||||
gboolean gncOwnerRegister (void);
|
||||
|
||||
/** The gncCloneOwner() routine makes a copy of the indicated
|
||||
* owner union structure.
|
||||
*/
|
||||
GncOwner gncCloneOwner (const GncOwner *from, QofBook *);
|
||||
|
||||
#endif /* GNC_OWNERP_H_ */
|
||||
|
||||
@@ -66,8 +66,6 @@ struct _book_info
|
||||
GList * tables; /* visible tables */
|
||||
};
|
||||
|
||||
static GncTaxTableEntry * CloneTaxEntry (const GncTaxTableEntry*, QofBook *);
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_BUSINESS;
|
||||
|
||||
/* =============================================================== */
|
||||
@@ -379,73 +377,6 @@ gncTaxTableCreate (QofBook *book)
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
GncTaxTable *
|
||||
gncCloneTaxTable (GncTaxTable *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncTaxTable *table;
|
||||
if (!book) return NULL;
|
||||
|
||||
table = g_object_new (GNC_TYPE_TAXTABLE, NULL);
|
||||
qof_instance_init_data (&table->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&table->inst, &from->inst);
|
||||
|
||||
table->name = CACHE_INSERT (from->name);
|
||||
table->modtime = from->modtime;
|
||||
table->invisible = from->invisible;
|
||||
|
||||
table->refcount = 0;
|
||||
|
||||
/* Make copies of parents and children. Note that this can be
|
||||
* a recursive copy ... treat as doubly-linked list. */
|
||||
if (from->child)
|
||||
{
|
||||
table->child = gncTaxTableObtainTwin (from->child, book);
|
||||
table->child->parent = table;
|
||||
}
|
||||
if (from->parent)
|
||||
{
|
||||
table->parent = gncTaxTableObtainTwin (from->parent, book);
|
||||
table->parent->child = table;
|
||||
}
|
||||
for (node = g_list_last(from->children); node; node = node->next)
|
||||
{
|
||||
GncTaxTable *tbl = node->data;
|
||||
tbl = gncTaxTableObtainTwin (tbl, book);
|
||||
tbl->parent = table;
|
||||
table->children = g_list_prepend(table->children, tbl);
|
||||
}
|
||||
|
||||
/* Copy tax entries, preserving the order in the list */
|
||||
table->entries = NULL;
|
||||
for (node = g_list_last(from->entries); node; node = node->prev)
|
||||
{
|
||||
GncTaxTableEntry *ent = node->data;
|
||||
ent = CloneTaxEntry (ent, book);
|
||||
table->entries = g_list_prepend (table->entries, ent);
|
||||
}
|
||||
|
||||
addObj (table);
|
||||
qof_event_gen (&table->inst, QOF_EVENT_CREATE, NULL);
|
||||
return table;
|
||||
}
|
||||
|
||||
GncTaxTable *
|
||||
gncTaxTableObtainTwin (const GncTaxTable *from, QofBook *book)
|
||||
{
|
||||
GncTaxTable *table;
|
||||
if (!from) return NULL;
|
||||
|
||||
table = (GncTaxTable *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!table)
|
||||
{
|
||||
table = gncCloneTaxTable (table, book);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gncTaxTableDestroy (GncTaxTable *table)
|
||||
{
|
||||
@@ -507,25 +438,6 @@ void gncTaxTableEntryDestroy (GncTaxTableEntry *entry)
|
||||
g_free (entry);
|
||||
}
|
||||
|
||||
/** Makes a clone. The account is from the appriate book.
|
||||
* Note that the table is left blank (for performance reasons
|
||||
* we set it above, when cloning the table).
|
||||
*/
|
||||
static GncTaxTableEntry *
|
||||
CloneTaxEntry (const GncTaxTableEntry*from, QofBook *book)
|
||||
{
|
||||
QofInstance *acc;
|
||||
GncTaxTableEntry *entry;
|
||||
entry = g_new0 (GncTaxTableEntry, 1);
|
||||
|
||||
entry->type = from->type;
|
||||
entry->amount = from->amount;
|
||||
|
||||
acc = qof_instance_lookup_twin (QOF_INSTANCE(from->account), book);
|
||||
entry->account = (Account *) acc;
|
||||
return entry;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -40,29 +40,6 @@ void gncTaxTableMakeInvisible (GncTaxTable *table);
|
||||
|
||||
gboolean gncTaxTableGetInvisible (const GncTaxTable *table);
|
||||
|
||||
/** The gncCloneTaxTable() routine makes a copy of the indicated
|
||||
* tax table, placing it in the indicated book. It copies
|
||||
* the tax table name and list of entries.
|
||||
* It also copies (as needed) both parents and children, so that
|
||||
* the parent-child relationship is correctly mirrored in the
|
||||
* clone.
|
||||
* XXX the refcount is mis-handled. This needs fixin....
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
GncTaxTable * gncCloneTaxTable (GncTaxTable *from, QofBook *book);
|
||||
|
||||
/** The gncTaxTableObtainTwin() will find the 'twin' of the
|
||||
* indicated tax table in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneTaxTable()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncTaxTable * gncTaxTableObtainTwin (const GncTaxTable *from, QofBook *book);
|
||||
|
||||
GncTaxTable* gncTaxTableEntryGetTable( const GncTaxTableEntry* entry );
|
||||
|
||||
#define gncTaxTableSetGUID(E,G) qof_instance_set_guid(QOF_INSTANCE(E),(G))
|
||||
|
||||
@@ -288,63 +288,6 @@ static void gncVendorFree (GncVendor *vendor)
|
||||
g_object_unref (vendor);
|
||||
}
|
||||
|
||||
/** Create a copy of a vendor, placing the copy into a new book. */
|
||||
GncVendor *
|
||||
gncCloneVendor (GncVendor *from, QofBook *book)
|
||||
{
|
||||
GList *node;
|
||||
GncVendor *vendor;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
vendor = g_object_new (GNC_TYPE_VENDOR, NULL);
|
||||
qof_instance_init_data (&vendor->inst, _GNC_MOD_NAME, book);
|
||||
qof_instance_gemini (&vendor->inst, &from->inst);
|
||||
|
||||
vendor->id = CACHE_INSERT (from->id);
|
||||
vendor->name = CACHE_INSERT (from->name);
|
||||
vendor->notes = CACHE_INSERT (from->notes);
|
||||
vendor->addr = gncCloneAddress (from->addr, &vendor->inst, book);
|
||||
vendor->taxincluded = from->taxincluded;
|
||||
vendor->taxtable_override = from->taxtable_override;
|
||||
vendor->active = from->active;
|
||||
|
||||
vendor->terms = gncBillTermObtainTwin (from->terms, book);
|
||||
gncBillTermIncRef (vendor->terms);
|
||||
|
||||
vendor->currency = gnc_commodity_obtain_twin (from->currency, book);
|
||||
|
||||
vendor->taxtable = gncTaxTableObtainTwin (from->taxtable, book);
|
||||
gncTaxTableIncRef (vendor->taxtable);
|
||||
|
||||
vendor->jobs = NULL;
|
||||
for (node = g_list_last(from->jobs); node; node = node->prev)
|
||||
{
|
||||
GncJob *job = node->data;
|
||||
job = gncJobObtainTwin (job, book);
|
||||
vendor->jobs = g_list_prepend(vendor->jobs, job);
|
||||
}
|
||||
|
||||
qof_event_gen (&vendor->inst, QOF_EVENT_CREATE, NULL);
|
||||
|
||||
return vendor;
|
||||
}
|
||||
|
||||
GncVendor *
|
||||
gncVendorObtainTwin (GncVendor *from, QofBook *book)
|
||||
{
|
||||
GncVendor *vendor;
|
||||
if (!book) return NULL;
|
||||
|
||||
vendor = (GncVendor *) qof_instance_lookup_twin (QOF_INSTANCE(from), book);
|
||||
if (!vendor)
|
||||
{
|
||||
vendor = gncCloneVendor (from, book);
|
||||
}
|
||||
|
||||
return vendor;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
/* Set Functions */
|
||||
|
||||
|
||||
@@ -33,25 +33,6 @@
|
||||
gboolean gncVendorRegister (void);
|
||||
gchar *gncVendorNextID (QofBook *book);
|
||||
|
||||
/** The gncCloneVendor() routine makes a copy of the indicated
|
||||
* vendor, placing it in the indicated book. It copies
|
||||
* the name, notes, address, etc.
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
|
||||
GncVendor * gncCloneVendor (GncVendor *from, QofBook *);
|
||||
|
||||
/** The gncVendorObtainTwin() will find the 'twin' of the
|
||||
* indicated vendor in the indicated book. If the twin doesn't
|
||||
* yet exist in the book, it will be created (by calling
|
||||
* gncCloneVendor()) and placed into the book.
|
||||
*
|
||||
* We called this routine 'Obtain' instead of "Get" to distinguish
|
||||
* it from the other Get routines, which work in fundamentally
|
||||
* different ways.
|
||||
*/
|
||||
GncVendor * gncVendorObtainTwin (GncVendor *from, QofBook *book);
|
||||
#define gncVendorSetGUID(V,G) qof_instance_set_guid(QOF_INSTANCE(V),(G))
|
||||
|
||||
|
||||
|
||||
@@ -815,64 +815,6 @@ void qof_instance_set_idata(gpointer inst, guint32 idata)
|
||||
|
||||
/* ========================================================== */
|
||||
|
||||
void
|
||||
qof_instance_gemini (QofInstance *to, const QofInstance *from)
|
||||
{
|
||||
QofInstancePrivate *from_priv, *to_priv, *fb_priv, *tb_priv;
|
||||
time_t now;
|
||||
|
||||
g_return_if_fail(QOF_IS_INSTANCE(to));
|
||||
g_return_if_fail(QOF_IS_INSTANCE(from));
|
||||
|
||||
from_priv = GET_PRIVATE(from);
|
||||
to_priv = GET_PRIVATE(to);
|
||||
fb_priv = GET_PRIVATE(from_priv->book);
|
||||
tb_priv = GET_PRIVATE(to_priv->book);
|
||||
|
||||
/* Books must differ for a gemini to be meaningful */
|
||||
if (from_priv->book == to_priv->book)
|
||||
return;
|
||||
|
||||
now = time(0);
|
||||
|
||||
/* Make a note of where the copy came from */
|
||||
gnc_kvp_bag_add (to->kvp_data, "gemini", now,
|
||||
"inst_guid", &from_priv->guid,
|
||||
"book_guid", &fb_priv->guid,
|
||||
NULL);
|
||||
gnc_kvp_bag_add (from->kvp_data, "gemini", now,
|
||||
"inst_guid", &to_priv->guid,
|
||||
"book_guid", &tb_priv->guid,
|
||||
NULL);
|
||||
|
||||
to_priv->dirty = TRUE;
|
||||
}
|
||||
|
||||
QofInstance *
|
||||
qof_instance_lookup_twin (const QofInstance *src, QofBook *target_book)
|
||||
{
|
||||
QofCollection *col;
|
||||
KvpFrame *fr;
|
||||
GncGUID * twin_guid;
|
||||
QofInstance * twin;
|
||||
QofInstancePrivate *bpriv;
|
||||
|
||||
if (!src || !target_book) return NULL;
|
||||
ENTER (" ");
|
||||
|
||||
bpriv = GET_PRIVATE(QOF_INSTANCE(target_book));
|
||||
fr = gnc_kvp_bag_find_by_guid (src->kvp_data, "gemini",
|
||||
"book_guid", &bpriv->guid);
|
||||
|
||||
twin_guid = kvp_frame_get_guid (fr, "inst_guid");
|
||||
|
||||
col = qof_book_get_collection (target_book, src->e_type);
|
||||
twin = (QofInstance *) qof_collection_lookup_entity (col, twin_guid);
|
||||
|
||||
LEAVE (" found twin=%p", twin);
|
||||
return twin;
|
||||
}
|
||||
|
||||
/* Returns a displayable name to represent this object */
|
||||
gchar* qof_instance_get_display_name(const QofInstance* inst)
|
||||
{
|
||||
|
||||
@@ -225,33 +225,6 @@ void qof_instance_copy_version_check (gpointer to, gconstpointer from);
|
||||
guint32 qof_instance_get_idata (gconstpointer inst);
|
||||
void qof_instance_set_idata(gpointer inst, guint32 idata);
|
||||
|
||||
/** Pair things up. This routine inserts a kvp value into each instance
|
||||
* containing the guid of the other. In this way, if one has one of the
|
||||
* pair, one can always find the other by looking up it's guid. Typically,
|
||||
* you will want to use qof_instance_lookup_twin() to find the twin.
|
||||
* (The current implementation assumes the two instances belong to different
|
||||
* books, and will not add gemini kvp's unless the books differ. Note that
|
||||
* the gemini kvp includes the book guid as well, so that the right book can
|
||||
* be found.
|
||||
*/
|
||||
void qof_instance_gemini (QofInstance *to, const QofInstance *from);
|
||||
|
||||
/** The qof_instance_lookup_twin() routine will find the "twin" of this
|
||||
* instance 'src' in the given other 'book' (if the twin exists).
|
||||
*
|
||||
* When instances are gemini'ed or cloned, both of the pair are marked
|
||||
* with the guid of their copy, thus allowing the sibling-copy of
|
||||
* an instance to be found. Since the sibling may end up in a
|
||||
* different book, we need a way of finding it, given only that we
|
||||
* know the book, and that we know its twin.
|
||||
*
|
||||
* That's what this routine does. Given some book 'book', and an
|
||||
* instance 'src', it will find the sibling instance of 'src' that is
|
||||
* in 'book', and return it. If not found, it returns NULL. This
|
||||
* routine uses the 'gemini' kvp values to do its work.
|
||||
*/
|
||||
QofInstance * qof_instance_lookup_twin (const QofInstance *src, QofBook *book);
|
||||
|
||||
/**
|
||||
* Returns a displayable name for this object. The returned string must be freed by the caller.
|
||||
*/
|
||||
|
||||
@@ -357,44 +357,6 @@ test_instance_get_set_dirty( Fixture *fixture, gconstpointer pData )
|
||||
qof_collection_destroy( col );
|
||||
}
|
||||
|
||||
static void
|
||||
test_instance_gemini_and_lookup( void )
|
||||
{
|
||||
QofBook *to_book, *from_book;
|
||||
KvpFrame *to_book_frame, *from_book_frame;
|
||||
|
||||
/* setup books */
|
||||
to_book = qof_book_new();
|
||||
from_book = qof_book_new();
|
||||
g_assert( QOF_IS_BOOK( to_book ) );
|
||||
g_assert( QOF_IS_BOOK( from_book ) );
|
||||
g_assert( to_book != from_book );
|
||||
g_assert( to_book == qof_instance_get_book( QOF_INSTANCE( to_book ) ) );
|
||||
g_assert( from_book == qof_instance_get_book( QOF_INSTANCE( from_book ) ) );
|
||||
|
||||
g_test_message( "Test instances lookup has instance and book null protection" );
|
||||
g_assert( qof_instance_lookup_twin( NULL, from_book ) == NULL );
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( from_book ), NULL ) == NULL );
|
||||
|
||||
g_test_message( "Test instances lookup which are not geminis should return null" );
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( to_book ), from_book ) == NULL );
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( from_book ), to_book ) == NULL );
|
||||
|
||||
g_test_message( "Test instances with the same book are not paired" );
|
||||
qof_instance_gemini (&to_book->inst, (QofInstance *) &to_book->inst);
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( to_book ), to_book ) == NULL );
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( from_book ), from_book ) == NULL );
|
||||
|
||||
g_test_message( "Test instances with different books are paired" );
|
||||
qof_instance_gemini (&to_book->inst, (QofInstance *) &from_book->inst);
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( to_book ), from_book ) == &from_book->inst );
|
||||
g_assert( qof_instance_lookup_twin( QOF_INSTANCE( from_book ), to_book ) == &to_book->inst );
|
||||
|
||||
/* destroy books */
|
||||
qof_book_destroy( to_book );
|
||||
qof_book_destroy( from_book );
|
||||
}
|
||||
|
||||
/* mock display name function */
|
||||
static gchar*
|
||||
mock_get_display_name(const QofInstance* inst)
|
||||
@@ -1068,7 +1030,6 @@ test_suite_qofinstance ( void )
|
||||
GNC_TEST_ADD( suitename, "get set slots", Fixture, NULL, setup, test_instance_get_set_slots, teardown );
|
||||
GNC_TEST_ADD_FUNC( suitename, "version compare", test_instance_version_cmp );
|
||||
GNC_TEST_ADD( suitename, "get set dirty", Fixture, NULL, setup, test_instance_get_set_dirty, teardown );
|
||||
GNC_TEST_ADD_FUNC( suitename, "gemini creation and lookup", test_instance_gemini_and_lookup );
|
||||
GNC_TEST_ADD( suitename, "display name", Fixture, NULL, setup, test_instance_display_name, teardown );
|
||||
GNC_TEST_ADD( suitename, "begin edit", Fixture, NULL, setup, test_instance_begin_edit, teardown );
|
||||
GNC_TEST_ADD( suitename, "commit edit", Fixture, NULL, setup, test_instance_commit_edit, teardown );
|
||||
|
||||
Reference in New Issue
Block a user