mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
further backend->book simplification
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6050 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9cc5dcce25
commit
8c2d2d4cf0
@ -107,10 +107,9 @@ xaccInitAccount (Account * acc, GNCBook *book)
|
||||
acc->do_free = FALSE;
|
||||
|
||||
acc->book = book;
|
||||
acc->entity_table = gnc_book_get_entity_table (book);
|
||||
|
||||
xaccGUIDNew(&acc->guid, book);
|
||||
xaccStoreEntity(acc->entity_table, acc, &acc->guid, GNC_ID_ACCOUNT);
|
||||
xaccStoreEntity(book->entity_table, acc, &acc->guid, GNC_ID_ACCOUNT);
|
||||
LEAVE ("account=%p\n", acc);
|
||||
}
|
||||
|
||||
@ -302,11 +301,11 @@ xaccFreeAccount (Account *acc)
|
||||
Transaction *t;
|
||||
GList *lp;
|
||||
|
||||
if (NULL == acc) return;
|
||||
if (!acc || !acc->book) return;
|
||||
|
||||
gnc_engine_generate_event (&acc->guid, GNC_EVENT_DESTROY);
|
||||
|
||||
xaccRemoveEntity (acc->entity_table, &acc->guid);
|
||||
xaccRemoveEntity (acc->book->entity_table, &acc->guid);
|
||||
|
||||
if (acc->children)
|
||||
{
|
||||
@ -826,11 +825,11 @@ xaccAccountSetGUID (Account *account, const GUID *guid)
|
||||
|
||||
PINFO("acct=%p", account);
|
||||
xaccAccountBeginEdit (account);
|
||||
xaccRemoveEntity (account->entity_table, &account->guid);
|
||||
xaccRemoveEntity (account->book->entity_table, &account->guid);
|
||||
|
||||
account->guid = *guid;
|
||||
|
||||
xaccStoreEntity (account->entity_table, account,
|
||||
xaccStoreEntity (account->book->entity_table, account,
|
||||
&account->guid, GNC_ID_ACCOUNT);
|
||||
account->core_dirty = TRUE;
|
||||
xaccAccountCommitEdit (account);
|
||||
@ -855,15 +854,6 @@ xaccAccountLookupDirect (GUID guid, GNCBook *book)
|
||||
&guid, GNC_ID_ACCOUNT);
|
||||
}
|
||||
|
||||
Account *
|
||||
xaccAccountLookupEntityTable (const GUID *guid,
|
||||
GNCEntityTable *entity_table)
|
||||
{
|
||||
if (!guid) return NULL;
|
||||
g_return_val_if_fail (entity_table, NULL);
|
||||
return xaccLookupEntity (entity_table, guid, GNC_ID_ACCOUNT);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@ -962,7 +952,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)
|
||||
if (!split) return;
|
||||
|
||||
/* check for book mix-up */
|
||||
g_return_if_fail (acc->entity_table == split->entity_table);
|
||||
g_return_if_fail (acc->book == split->book);
|
||||
|
||||
trans = xaccSplitGetParent (split);
|
||||
|
||||
|
@ -58,15 +58,7 @@ struct account_s
|
||||
/* public data, describes account */
|
||||
GUID guid; /* globally unique account id */
|
||||
|
||||
/* XXX FIXME ... this pointer shadows a more 'technically correct
|
||||
* pointer', the one in book. The correct way to find the entity
|
||||
* table should be to find the accounts parent group, then find
|
||||
* the parent book, then find the entity table. So this shadow
|
||||
* copy here is redundant... does it provide a performance boost
|
||||
* by being here ??? Do we ahve another reason ??? */
|
||||
GNCEntityTable *entity_table; /* Entity table this account is
|
||||
* stored in. */
|
||||
GNCBook *book;
|
||||
GNCBook *book; /* the entity_table in which this account is stored */
|
||||
|
||||
/* The accountName is an arbitrary string assigned by the user.
|
||||
* It is intended to a short, 5 to 30 character long string that
|
||||
@ -149,13 +141,6 @@ struct account_s
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
|
||||
/* The xaccAccountLookupEntityTable() routine is like xaccAccountLookup
|
||||
* but accepts and entity table instead of a book.
|
||||
*/
|
||||
Account * xaccAccountLookupEntityTable (const GUID *guid,
|
||||
GNCEntityTable *entity_table);
|
||||
|
||||
/* The xaccAccountRemoveSplit() routine will remove the indicated split
|
||||
* from the indicated account. Note that this will leave the split
|
||||
* "dangling", i.e. unassigned to any account, and therefore will put
|
||||
|
@ -90,46 +90,11 @@ xaccPriceDBGetBackend (GNCPriceDB *prdb)
|
||||
return prdb->book->backend;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* Fetch the backend *
|
||||
\********************************************************************/
|
||||
|
||||
/* XXX hack alert -- practically, it would be easier if we found the
|
||||
* book, and then asked the book about the backend.
|
||||
*/
|
||||
|
||||
Backend *
|
||||
xaccTransactionGetBackend (Transaction *trans)
|
||||
{
|
||||
GList *snode, *node;
|
||||
Split *s=NULL;
|
||||
|
||||
if (!trans) return NULL;
|
||||
|
||||
/* find an account */
|
||||
snode = xaccTransGetSplitList(trans);
|
||||
for (node = snode; node; node=node->next)
|
||||
{
|
||||
s = node->data;
|
||||
if (xaccSplitGetAccount(s)) break;
|
||||
s = NULL;
|
||||
}
|
||||
|
||||
/* if transaction is being deleted, it won't have any splits
|
||||
* so lets take a look at the 'original' transaction */
|
||||
if (!s)
|
||||
{
|
||||
snode = xaccTransGetSplitList(trans->orig);
|
||||
for (node = snode; node; node=node->next)
|
||||
{
|
||||
s = node->data;
|
||||
if (xaccSplitGetAccount(s)) break;
|
||||
s = NULL;
|
||||
}
|
||||
}
|
||||
if (!s) return NULL;
|
||||
|
||||
return xaccAccountGetBackend (xaccSplitGetAccount(s));
|
||||
if (!trans || !trans->book) return NULL;
|
||||
return trans->book->backend;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -660,11 +660,6 @@ xaccAccountInsertSubAccount (Account *adult, Account *child)
|
||||
{
|
||||
if (!adult) return;
|
||||
|
||||
/* We want the parent to have an entity table. It doesn't have to
|
||||
* be the same entity table as the child, the xaccGroupInsertAccount
|
||||
* routine will take care of that. */
|
||||
g_return_if_fail (adult->entity_table);
|
||||
|
||||
/* if a container for the children doesn't yet exist, add it */
|
||||
if (adult->children == NULL)
|
||||
{
|
||||
@ -718,9 +713,10 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
{
|
||||
xaccGroupRemoveAccount (acc->parent, acc);
|
||||
|
||||
/* switch over entity tables if needed */
|
||||
if (grp->book->entity_table != acc->entity_table)
|
||||
/* switch over betwen books, if needed */
|
||||
if (grp->book != acc->book)
|
||||
{
|
||||
// xxxxxxxxxxxxxxxxxxxxxxx
|
||||
/* hack alert -- this implementation is not exactly correct.
|
||||
* If the entity tables are not identical, then the 'from' book
|
||||
* will have a different backend than the 'to' book. This means
|
||||
@ -730,7 +726,7 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
PWARN ("reparenting accounts accross books is not correctly supported\n");
|
||||
|
||||
gnc_engine_generate_event (&acc->guid, GNC_EVENT_DESTROY);
|
||||
xaccRemoveEntity (acc->entity_table, &acc->guid);
|
||||
xaccRemoveEntity (acc->book->entity_table, &acc->guid);
|
||||
|
||||
xaccStoreEntity (grp->book->entity_table, acc, &acc->guid, GNC_ID_ACCOUNT);
|
||||
gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE);
|
||||
|
@ -8,7 +8,7 @@
|
||||
* CAUTION: this is currently a non-functioning, experimental implementation
|
||||
* of the design described in src/doc/book.txt
|
||||
|
||||
Open questions: hwo do we deal with the backends ???
|
||||
Open questions: how do we deal with the backends ???
|
||||
*
|
||||
* HISTORY:
|
||||
* created by Linas Vepstas November 2001
|
||||
@ -27,7 +27,11 @@ Open questions: hwo do we deal with the backends ???
|
||||
* to partition an existing book into two parts. It returns
|
||||
* a newly created book, containing a copy of all of the accounts,
|
||||
* and it moves all of the transactions returned by the query to
|
||||
* the copied accounts. I
|
||||
* the copied accounts.
|
||||
|
||||
The intent is that the 'typical' query will be a date that splits
|
||||
the book into a 'before and after'; but in fact, any general query
|
||||
will do.
|
||||
|
||||
Note that this routine is 'special' in that it works hard to make sure
|
||||
that the partitioned accounts, transactions and splits are really
|
||||
@ -45,13 +49,31 @@ GNCBook * gnc_book_partition (GNCBook *, Query *);
|
||||
|
||||
#include "gnc-book-p.h"
|
||||
#include "GroupP.h"
|
||||
#include "TransactionP.h"
|
||||
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
static void
|
||||
reparent (Transaction *trans, GNCBook *book)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
{
|
||||
Account *twin;
|
||||
Split *s = node->data;
|
||||
|
||||
twin = xaccAccountLookupTwin (s->acc, book);
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
GNCBook *
|
||||
gnc_book_partition (GNCBook *existing_book, Query *query)
|
||||
{
|
||||
GList * split_list;
|
||||
GList *split_list, *snode;
|
||||
GNCBook *partition_book;
|
||||
AccountGroup *part_topgrp;
|
||||
|
||||
@ -65,6 +87,15 @@ gnc_book_partition (GNCBook *existing_book, Query *query)
|
||||
/* next, run the query */
|
||||
split_list = xaccQueryGetSplitsUniqueTrans (query);
|
||||
|
||||
/* and start moving transactions over */
|
||||
for (snode = split_list; snode; snode=snode->next)
|
||||
{
|
||||
GList *tnode;
|
||||
Split *s = snode->data;
|
||||
Transaction *trans = s->parent;
|
||||
|
||||
}
|
||||
|
||||
return partition_book;
|
||||
}
|
||||
|
||||
|
@ -1082,12 +1082,10 @@ guid_list_to_account_list (Query * q, GList *guids)
|
||||
GUID *guid = node->data;
|
||||
Account *account;
|
||||
|
||||
if (!guid)
|
||||
continue;
|
||||
if (!guid) continue;
|
||||
|
||||
account = xaccAccountLookupEntityTable (guid, q->acct_group->book->entity_table);
|
||||
if (!account)
|
||||
continue;
|
||||
account = xaccAccountLookup (guid, q->acct_group->book);
|
||||
if (!account) continue;
|
||||
|
||||
accounts = g_list_prepend (accounts, account);
|
||||
}
|
||||
@ -2488,12 +2486,12 @@ xaccGUIDMatchPredicate(Split * s, PredicateData * pd)
|
||||
return 0;
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_ACCOUNT))
|
||||
return (xaccSplitGetAccount (s) ==
|
||||
xaccAccountLookupEntityTable (guid, s->entity_table));
|
||||
xaccAccountLookup (guid, s->book));
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_TRANS))
|
||||
return (xaccSplitGetParent (s) ==
|
||||
xaccTransLookupEntityTable (guid, s->entity_table));
|
||||
xaccTransLookup (guid, s->book));
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_SPLIT))
|
||||
return s == xaccSplitLookupEntityTable (guid, s->entity_table);
|
||||
return s == xaccSplitLookup (guid, s->book);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ check_open (Transaction *trans)
|
||||
\********************************************************************/
|
||||
|
||||
static void
|
||||
xaccInitSplit(Split * split, GNCEntityTable *entity_table)
|
||||
xaccInitSplit(Split * split, GNCBook *book)
|
||||
{
|
||||
/* fill in some sane defaults */
|
||||
xaccSplitSetAccount(split, NULL);
|
||||
@ -116,33 +116,25 @@ xaccInitSplit(Split * split, GNCEntityTable *entity_table)
|
||||
split->kvp_data = kvp_frame_new();
|
||||
split->idata = 0;
|
||||
|
||||
split->entity_table = entity_table;
|
||||
split->book = book;
|
||||
|
||||
xaccGUIDNewEntityTable (&split->guid, split->entity_table);
|
||||
xaccStoreEntity(split->entity_table, split, &split->guid, GNC_ID_SPLIT);
|
||||
xaccGUIDNew (&split->guid, book);
|
||||
xaccStoreEntity(book->entity_table, split, &split->guid, GNC_ID_SPLIT);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
static Split *
|
||||
xaccMallocSplitEntityTable (GNCEntityTable *entity_table)
|
||||
{
|
||||
Split *split;
|
||||
|
||||
g_return_val_if_fail (entity_table, NULL);
|
||||
|
||||
split = g_new (Split, 1);
|
||||
xaccInitSplit (split, entity_table);
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
Split *
|
||||
xaccMallocSplit(GNCBook *book)
|
||||
{
|
||||
Split *split;
|
||||
g_return_val_if_fail (book, NULL);
|
||||
return xaccMallocSplitEntityTable (gnc_book_get_entity_table (book));
|
||||
|
||||
split = g_new (Split, 1);
|
||||
xaccInitSplit (split, book);
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -161,7 +153,7 @@ xaccCloneSplit (Split *s)
|
||||
/* copy(!) the guid and entity table. The cloned split is *not* unique,
|
||||
* is a sick twisted clone that holds 'undo' information. */
|
||||
split->guid = s->guid;
|
||||
split->entity_table = s->entity_table;
|
||||
split->book = s->book;
|
||||
|
||||
xaccSplitSetAccountGUID(split, s->acc_guid);
|
||||
split->parent = s->parent;
|
||||
@ -398,16 +390,6 @@ xaccSplitSetSlots_nc(Split *s, kvp_frame *frm)
|
||||
* Account funcs
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
xaccSplitSetAccount_Internal(Split *s, Account *act)
|
||||
{
|
||||
if(!act)
|
||||
{
|
||||
return;
|
||||
}
|
||||
s->acc = act;
|
||||
}
|
||||
|
||||
Account*
|
||||
xaccSplitGetAccount(Split *s)
|
||||
{
|
||||
@ -415,10 +397,7 @@ xaccSplitGetAccount(Split *s)
|
||||
|
||||
if (!s->acc)
|
||||
{
|
||||
Account *account;
|
||||
|
||||
account = xaccAccountLookupEntityTable (&s->acc_guid, s->entity_table);
|
||||
xaccSplitSetAccount_Internal (s, account);
|
||||
s->acc = xaccAccountLookup (&s->acc_guid, s->book);
|
||||
}
|
||||
|
||||
return s->acc;
|
||||
@ -483,22 +462,14 @@ xaccSplitSetGUID (Split *split, const GUID *guid)
|
||||
{
|
||||
if (!split || !guid) return;
|
||||
check_open (split->parent);
|
||||
xaccRemoveEntity(split->entity_table, &split->guid);
|
||||
xaccRemoveEntity(split->book->entity_table, &split->guid);
|
||||
split->guid = *guid;
|
||||
xaccStoreEntity(split->entity_table, split, &split->guid, GNC_ID_SPLIT);
|
||||
xaccStoreEntity(split->book->entity_table, split, &split->guid, GNC_ID_SPLIT);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
Split *
|
||||
xaccSplitLookupEntityTable (const GUID *guid, GNCEntityTable *entity_table)
|
||||
{
|
||||
if (!guid) return NULL;
|
||||
g_return_val_if_fail (entity_table, NULL);
|
||||
return xaccLookupEntity(entity_table, guid, GNC_ID_SPLIT);
|
||||
}
|
||||
|
||||
Split *
|
||||
xaccSplitLookup (const GUID *guid, GNCBook *book)
|
||||
{
|
||||
@ -785,10 +756,10 @@ xaccInitTransaction (Transaction * trans, GNCBook *book)
|
||||
trans->kvp_data = kvp_frame_new();
|
||||
trans->idata = 0;
|
||||
|
||||
trans->entity_table = gnc_book_get_entity_table (book);
|
||||
trans->book = book;
|
||||
|
||||
xaccGUIDNew (&trans->guid, book);
|
||||
xaccStoreEntity (trans->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
xaccStoreEntity (book->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -845,10 +816,10 @@ xaccCloneTransaction (Transaction *t)
|
||||
trans->common_currency = t->common_currency;
|
||||
|
||||
/* copy(!) the guid and entity table. The cloned transaction is
|
||||
* *not* unique, is a sick twisted clone that holds 'undo'
|
||||
* *not* unique, it is a sick twisted clone that holds 'undo'
|
||||
* information. */
|
||||
trans->guid = t->guid;
|
||||
trans->entity_table = t->entity_table;
|
||||
trans->book = t->book;
|
||||
|
||||
return trans;
|
||||
}
|
||||
@ -1110,23 +1081,15 @@ void
|
||||
xaccTransSetGUID (Transaction *trans, const GUID *guid)
|
||||
{
|
||||
if (!trans || !guid) return;
|
||||
xaccRemoveEntity(trans->entity_table, &trans->guid);
|
||||
xaccRemoveEntity(trans->book->entity_table, &trans->guid);
|
||||
trans->guid = *guid;
|
||||
xaccStoreEntity(trans->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
xaccStoreEntity(trans->book->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
Transaction *
|
||||
xaccTransLookupEntityTable (const GUID *guid,
|
||||
GNCEntityTable *entity_table)
|
||||
{
|
||||
g_return_val_if_fail (entity_table, NULL);
|
||||
return xaccLookupEntity (entity_table, guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
Transaction *
|
||||
xaccTransLookup (const GUID *guid, GNCBook *book)
|
||||
{
|
||||
@ -1585,7 +1548,7 @@ xaccTransCommitEdit (Transaction *trans)
|
||||
if ((1 == force_double_entry) &&
|
||||
(NULL == g_list_nth(trans->splits, 1)) &&
|
||||
(!gnc_numeric_zero_p(split->amount))) {
|
||||
Split * s = xaccMallocSplitEntityTable(trans->entity_table);
|
||||
Split * s = xaccMallocSplit(trans->book);
|
||||
xaccTransAppendSplit (trans, s);
|
||||
xaccAccountInsertSplit (xaccSplitGetAccount(s), s);
|
||||
xaccSplitSetMemo (s, split->memo);
|
||||
@ -1650,7 +1613,7 @@ xaccTransCommitEdit (Transaction *trans)
|
||||
PINFO ("delete trans at addr=%p", trans);
|
||||
/* Make a log in the journal before destruction. */
|
||||
xaccTransWriteLog (trans, 'D');
|
||||
xaccRemoveEntity(trans->entity_table, &trans->guid);
|
||||
xaccRemoveEntity(trans->book->entity_table, &trans->guid);
|
||||
xaccFreeTransaction (trans);
|
||||
return;
|
||||
}
|
||||
@ -1695,7 +1658,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
|
||||
/* If the transaction had been deleted before the rollback,
|
||||
* the guid would have been unlisted. Restore that */
|
||||
xaccStoreEntity(trans->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
xaccStoreEntity(trans->book->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
|
||||
trans->common_currency = orig->common_currency;
|
||||
|
||||
@ -1819,7 +1782,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
mark_split (s);
|
||||
xaccAccountRemoveSplit (xaccSplitGetAccount(s), s);
|
||||
xaccAccountRecomputeBalance (xaccSplitGetAccount(s));
|
||||
xaccRemoveEntity(s->entity_table, &s->guid);
|
||||
xaccRemoveEntity(s->book->entity_table, &s->guid);
|
||||
xaccFreeSplit (s);
|
||||
|
||||
trans->editlevel--;
|
||||
@ -1837,7 +1800,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
Account *account = xaccSplitGetAccount(s);
|
||||
|
||||
xaccSplitSetAccount(s, NULL);
|
||||
xaccStoreEntity(s->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
||||
xaccStoreEntity(s->book->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
||||
xaccAccountInsertSplit (account, s);
|
||||
xaccAccountRecomputeBalance (account);
|
||||
mark_split (s);
|
||||
@ -1935,7 +1898,7 @@ xaccTransDestroy (Transaction *trans)
|
||||
|
||||
xaccAccountRemoveSplit (xaccSplitGetAccount(split), split);
|
||||
xaccAccountRecomputeBalance (xaccSplitGetAccount(split));
|
||||
xaccRemoveEntity(split->entity_table, &split->guid);
|
||||
xaccRemoveEntity(split->book->entity_table, &split->guid);
|
||||
xaccFreeSplit (split);
|
||||
|
||||
node->data = NULL;
|
||||
@ -1944,7 +1907,7 @@ xaccTransDestroy (Transaction *trans)
|
||||
g_list_free (trans->splits);
|
||||
trans->splits = NULL;
|
||||
|
||||
xaccRemoveEntity(trans->entity_table, &trans->guid);
|
||||
xaccRemoveEntity(trans->book->entity_table, &trans->guid);
|
||||
|
||||
/* the actual free is done with the commit call, else its rolled back */
|
||||
/* xaccFreeTransaction (trans); don't do this here ... */
|
||||
@ -1978,7 +1941,7 @@ xaccSplitDestroy (Split *split)
|
||||
check_open (trans);
|
||||
|
||||
mark_split (split);
|
||||
xaccRemoveEntity (split->entity_table, &split->guid);
|
||||
xaccRemoveEntity (split->book->entity_table, &split->guid);
|
||||
|
||||
if (trans)
|
||||
{
|
||||
@ -2007,7 +1970,7 @@ xaccTransAppendSplit (Transaction *trans, Split *split)
|
||||
Transaction *oldtrans;
|
||||
|
||||
if (!trans || !split) return;
|
||||
g_return_if_fail (trans->entity_table == split->entity_table);
|
||||
g_return_if_fail (trans->book == split->book);
|
||||
check_open (trans);
|
||||
|
||||
/* first, make sure that the split isn't already inserted
|
||||
@ -2058,21 +2021,21 @@ xaccTransAppendSplit (Transaction *trans, Split *split)
|
||||
#define DATE_CMP(aaa,bbb,field) { \
|
||||
/* if dates differ, return */ \
|
||||
if ( (aaa->field.tv_sec) < \
|
||||
(bbb->field.tv_sec)) { \
|
||||
(bbb->field.tv_sec)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ( (aaa->field.tv_sec) > \
|
||||
(bbb->field.tv_sec)) { \
|
||||
(bbb->field.tv_sec)) { \
|
||||
return +1; \
|
||||
} \
|
||||
\
|
||||
/* else, seconds match. check nanoseconds */ \
|
||||
if ( (aaa->field.tv_nsec) < \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
if ( (aaa->field.tv_nsec) < \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ( (aaa->field.tv_nsec) > \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
if ( (aaa->field.tv_nsec) > \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
return +1; \
|
||||
} \
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ struct split_s
|
||||
{
|
||||
GUID guid; /* globally unique id */
|
||||
|
||||
GNCEntityTable *entity_table; /* The table where this split is stored. */
|
||||
GNCBook *book; /* The enitity table where this split is stored. */
|
||||
|
||||
GUID acc_guid; /* the guid of the associated account */
|
||||
Account *acc; /* back-pointer to debited/credited account */
|
||||
@ -137,8 +137,7 @@ struct transaction_s
|
||||
*/
|
||||
GUID guid;
|
||||
|
||||
/* entity_table is the table where the transaction is stored by guid */
|
||||
GNCEntityTable *entity_table;
|
||||
GNCBook *book; /* The entity_table where the transaction is stored */
|
||||
|
||||
Timespec date_entered; /* date register entry was made */
|
||||
Timespec date_posted; /* date transaction was posted at bank */
|
||||
@ -201,13 +200,6 @@ struct transaction_s
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
/* Lookup the transaction/split with the guid, using the given table. */
|
||||
Transaction * xaccTransLookupEntityTable (const GUID *guid,
|
||||
GNCEntityTable *entity_table);
|
||||
|
||||
Split * xaccSplitLookupEntityTable (const GUID *guid,
|
||||
GNCEntityTable *entity_table);
|
||||
|
||||
/* Set the transaction's GUID. This should only be done when reading
|
||||
* a transaction from a datafile, or some other external source. Never
|
||||
* call this on an existing transaction! */
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "AccountP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "gnc-associate-account.h"
|
||||
#include "gnc-book-p.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
@ -92,9 +94,7 @@ back_associate_expense_accounts(Account *stock_account,
|
||||
g_return_if_fail(kvp_value_get_type(val) == KVP_TYPE_GUID);
|
||||
existing_acc_guid = kvp_value_get_guid(val);
|
||||
|
||||
g_return_if_fail(xaccGUIDTypeEntityTable (existing_acc_guid,
|
||||
stock_account->entity_table) ==
|
||||
GNC_ID_NONE);
|
||||
g_return_if_fail(GNC_ID_NONE == xaccGUIDType (existing_acc_guid, stock_account->book));
|
||||
|
||||
kvp_frame_set_slot_nc(acc_frame, "associated-stock-account",
|
||||
stock_acc_guid_kvpval);
|
||||
@ -129,8 +129,8 @@ back_associate_income_accounts(Account *stock_account,
|
||||
g_return_if_fail(kvp_value_get_type(val) == KVP_TYPE_GUID);
|
||||
existing_acc_guid = kvp_value_get_guid(val);
|
||||
|
||||
g_return_if_fail(xaccGUIDTypeEntityTable(existing_acc_guid,
|
||||
stock_account->entity_table) ==
|
||||
g_return_if_fail(xaccGUIDType(existing_acc_guid,
|
||||
stock_account->book) ==
|
||||
GNC_ID_NONE);
|
||||
|
||||
kvp_frame_set_slot_nc(acc_frame, "associated-stock-account",
|
||||
@ -172,7 +172,7 @@ make_kvpd_on_list(GList *account_list)
|
||||
}
|
||||
|
||||
static GList *
|
||||
de_kvp_account_list(kvp_value *kvpd_list, GNCEntityTable *entity_table)
|
||||
de_kvp_account_list(kvp_value *kvpd_list, GNCBook *book)
|
||||
{
|
||||
GList *guid_account_list = kvp_value_get_glist(kvpd_list);
|
||||
if (guid_account_list)
|
||||
@ -181,8 +181,7 @@ de_kvp_account_list(kvp_value *kvpd_list, GNCEntityTable *entity_table)
|
||||
for(; guid_account_list; guid_account_list=g_list_next(guid_account_list))
|
||||
{
|
||||
g_list_prepend(expense_acc_list,
|
||||
xaccAccountLookupEntityTable(guid_account_list->data,
|
||||
entity_table));
|
||||
xaccAccountLookup(guid_account_list->data, book));
|
||||
}
|
||||
|
||||
expense_acc_list = g_list_reverse(expense_acc_list);
|
||||
@ -312,8 +311,7 @@ gnc_tracking_find_expense_accounts(Account *stock_account,
|
||||
kvpd_on_account_list = kvp_frame_get_slot(account_frame,
|
||||
expense_to_key[category]);
|
||||
|
||||
return de_kvp_account_list(kvpd_on_account_list,
|
||||
stock_account->entity_table);
|
||||
return de_kvp_account_list(kvpd_on_account_list, stock_account->book);
|
||||
}
|
||||
|
||||
/*********************************************************************\
|
||||
@ -347,8 +345,7 @@ gnc_tracking_find_income_accounts(Account *stock_account,
|
||||
kvpd_on_account_list = kvp_frame_get_slot(income_acc_frame,
|
||||
income_to_key[category]);
|
||||
|
||||
return de_kvp_account_list(kvpd_on_account_list,
|
||||
stock_account->entity_table);
|
||||
return de_kvp_account_list(kvpd_on_account_list, stock_account->book);
|
||||
}
|
||||
|
||||
/*********************************************************************\
|
||||
@ -452,8 +449,7 @@ gnc_tracking_dissociate_account(Account *inc_or_expense_account)
|
||||
|
||||
stock_account_guid = kvp_value_get_guid(stock_account_kvpval);
|
||||
if(!safe_strcmp
|
||||
(xaccGUIDTypeEntityTable(stock_account_guid,
|
||||
inc_or_expense_account->entity_table),
|
||||
(xaccGUIDType(stock_account_guid, inc_or_expense_account->book),
|
||||
GNC_ID_NULL))
|
||||
return;
|
||||
|
||||
@ -463,8 +459,8 @@ gnc_tracking_dissociate_account(Account *inc_or_expense_account)
|
||||
|
||||
|
||||
inc_or_expense_account_guid = xaccAccountGetGUID(inc_or_expense_account);
|
||||
stock_account = xaccAccountLookupEntityTable
|
||||
(stock_account_guid, inc_or_expense_account->entity_table);
|
||||
stock_account = xaccAccountLookup
|
||||
(stock_account_guid, inc_or_expense_account->book);
|
||||
|
||||
stock_account_kvpframe = xaccAccountGetSlots(stock_account);
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "GNCId.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-pricedb.h"
|
||||
@ -41,7 +41,7 @@ struct gnc_price_s
|
||||
GNCPriceDB *db;
|
||||
gnc_commodity *commodity;
|
||||
gnc_commodity *currency;
|
||||
Timespec time;
|
||||
Timespec tmspec;
|
||||
char *source;
|
||||
char *type;
|
||||
gnc_numeric value;
|
||||
|
@ -292,7 +292,7 @@ void
|
||||
gnc_price_set_time(GNCPrice *p, Timespec t)
|
||||
{
|
||||
if(!p) return;
|
||||
if(!timespec_equal(&(p->time), &t))
|
||||
if(!timespec_equal(&(p->tmspec), &t))
|
||||
{
|
||||
/* Changing the datestamp requires the hash table
|
||||
* position to be modified. The easiest way of doing
|
||||
@ -300,7 +300,7 @@ gnc_price_set_time(GNCPrice *p, Timespec t)
|
||||
gnc_price_ref (p);
|
||||
remove_price (p->db, p, FALSE);
|
||||
gnc_price_begin_edit (p);
|
||||
p->time = t;
|
||||
p->tmspec = t;
|
||||
if(p->db) p->db->dirty = TRUE;
|
||||
gnc_price_commit_edit (p);
|
||||
add_price (p->db, p);
|
||||
@ -403,7 +403,7 @@ gnc_price_get_time(GNCPrice *p)
|
||||
result.tv_nsec = 0;
|
||||
return result;
|
||||
}
|
||||
return p->time;
|
||||
return p->tmspec;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
Loading…
Reference in New Issue
Block a user