mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
misc cleanup; lot-related bug fixes; add more traces
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6914 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
47eaa5c35d
commit
f47b53a310
@ -47,7 +47,7 @@
|
||||
#include "gncObject.h"
|
||||
#include "QueryObject.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
static short module = MOD_ACCOUNT;
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
@ -305,7 +305,8 @@ xaccFreeAccount (Account *acc)
|
||||
/* any split pointing at this account needs to be unmarked */
|
||||
for(lp = acc->splits; lp; lp = lp->next)
|
||||
{
|
||||
xaccSplitSetAccount((Split *) lp->data, NULL);
|
||||
Split *s = lp->data;
|
||||
s->acc = NULL;
|
||||
}
|
||||
|
||||
acc->editlevel = 0;
|
||||
@ -947,6 +948,7 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot)
|
||||
Account * old_acc = NULL;
|
||||
|
||||
if (!acc || !lot) return;
|
||||
ENTER ("(acc=%p, lot=%p)", acc, lot);
|
||||
|
||||
/* pull it out of the old account */
|
||||
if (lot->account && lot->account != acc)
|
||||
@ -958,8 +960,13 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot)
|
||||
}
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
lot->account = acc;
|
||||
acc->lots = g_list_prepend (acc->lots, lot);
|
||||
|
||||
/* Avoid inserting into list more than once */
|
||||
if (lot->account != acc)
|
||||
{
|
||||
acc->lots = g_list_prepend (acc->lots, lot);
|
||||
lot->account = acc;
|
||||
}
|
||||
|
||||
/* Move all slots over to the new account. At worst,
|
||||
* this is a no-op. */
|
||||
@ -976,6 +983,7 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot)
|
||||
}
|
||||
xaccAccountCommitEdit(acc);
|
||||
xaccAccountCommitEdit(old_acc);
|
||||
LEAVE ("(acc=%p, lot=%p)", acc, lot);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -988,6 +996,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)
|
||||
|
||||
if (!acc) return;
|
||||
if (!split) return;
|
||||
ENTER ("(acc=%p, split=%p)", acc, split);
|
||||
|
||||
/* check for book mix-up */
|
||||
g_return_if_fail (acc->book == split->book);
|
||||
@ -1015,7 +1024,11 @@ xaccAccountInsertSplit (Account *acc, Split *split)
|
||||
xaccSplitGetAccount(split) != acc)
|
||||
xaccAccountRemoveSplit (xaccSplitGetAccount(split), split);
|
||||
|
||||
xaccSplitSetAccount (split, acc);
|
||||
split->acc = acc;
|
||||
if (split->lot && (NULL == split->lot->account))
|
||||
{
|
||||
xaccAccountInsertLot (acc, split->lot);
|
||||
}
|
||||
|
||||
if (g_list_index(acc->splits, split) == -1)
|
||||
{
|
||||
@ -1035,6 +1048,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)
|
||||
|
||||
xaccTransCommitEdit(trans);
|
||||
xaccAccountCommitEdit(acc);
|
||||
LEAVE ("(acc=%p, split=%p)", acc, split);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -1045,6 +1059,7 @@ xaccAccountRemoveSplit (Account *acc, Split *split)
|
||||
{
|
||||
if (!acc) return;
|
||||
if (!split) return;
|
||||
ENTER ("(acc=%p, split=%p)", acc, split);
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
{
|
||||
@ -1065,7 +1080,7 @@ xaccAccountRemoveSplit (Account *acc, Split *split)
|
||||
acc->balance_dirty = TRUE;
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccSplitSetAccount(split, NULL);
|
||||
split->acc = NULL;
|
||||
if (split->lot)
|
||||
{
|
||||
gnc_lot_remove_split (split->lot, split);
|
||||
@ -1078,6 +1093,7 @@ xaccAccountRemoveSplit (Account *acc, Split *split)
|
||||
}
|
||||
}
|
||||
xaccAccountCommitEdit(acc);
|
||||
LEAVE ("(acc=%p, split=%p)", acc, split);
|
||||
}
|
||||
|
||||
|
||||
@ -1240,7 +1256,8 @@ static int revorder[NUM_ACCOUNT_TYPES] = {
|
||||
|
||||
|
||||
int
|
||||
xaccAccountOrder (Account **aa, Account **ab) {
|
||||
xaccAccountOrder (Account **aa, Account **ab)
|
||||
{
|
||||
char *da, *db;
|
||||
char *endptr = NULL;
|
||||
int ta, tb;
|
||||
@ -1317,7 +1334,8 @@ xaccAccountSetType (Account *acc, GNCAccountType tip)
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetName (Account *acc, const char *str) {
|
||||
xaccAccountSetName (Account *acc, const char *str)
|
||||
{
|
||||
char * tmp;
|
||||
|
||||
if ((!acc) || (!str)) return;
|
||||
@ -1336,7 +1354,8 @@ xaccAccountSetName (Account *acc, const char *str) {
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetCode (Account *acc, const char *str) {
|
||||
xaccAccountSetCode (Account *acc, const char *str)
|
||||
{
|
||||
char * tmp;
|
||||
if ((!acc) || (!str)) return;
|
||||
|
||||
@ -1354,7 +1373,8 @@ xaccAccountSetCode (Account *acc, const char *str) {
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetDescription (Account *acc, const char *str) {
|
||||
xaccAccountSetDescription (Account *acc, const char *str)
|
||||
{
|
||||
char * tmp;
|
||||
if ((!acc) || (!str)) return;
|
||||
|
||||
@ -1512,8 +1532,8 @@ DxaccAccountSetSecurity (Account *acc, gnc_commodity * security,
|
||||
}
|
||||
|
||||
void
|
||||
DxaccAccountSetCurrencySCU (Account * acc, int scu) {
|
||||
|
||||
DxaccAccountSetCurrencySCU (Account * acc, int scu)
|
||||
{
|
||||
if (!acc) return;
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
@ -1525,7 +1545,8 @@ DxaccAccountSetCurrencySCU (Account * acc, int scu) {
|
||||
}
|
||||
|
||||
int
|
||||
DxaccAccountGetCurrencySCU (Account * acc) {
|
||||
DxaccAccountGetCurrencySCU (Account * acc)
|
||||
{
|
||||
kvp_value *v;
|
||||
|
||||
if (!acc) return 0;
|
||||
@ -1720,7 +1741,8 @@ DxaccAccountGetSecurity (Account *acc, GNCBook *book)
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
xaccAccountGetBalance (Account *acc) {
|
||||
xaccAccountGetBalance (Account *acc)
|
||||
{
|
||||
if (!acc) return gnc_numeric_zero();
|
||||
return acc->balance;
|
||||
}
|
||||
@ -1989,8 +2011,10 @@ xaccAccountHasAncestor (Account *account, Account * ancestor)
|
||||
#define GNC_RETURN_ENUM_AS_STRING(x) case (x): return #x;
|
||||
|
||||
char *
|
||||
xaccAccountTypeEnumAsString(GNCAccountType type) {
|
||||
switch(type) {
|
||||
xaccAccountTypeEnumAsString(GNCAccountType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
GNC_RETURN_ENUM_AS_STRING(NO_TYPE);
|
||||
GNC_RETURN_ENUM_AS_STRING(BANK);
|
||||
GNC_RETURN_ENUM_AS_STRING(CASH);
|
||||
@ -2022,7 +2046,8 @@ xaccAccountTypeEnumAsString(GNCAccountType type) {
|
||||
if(safe_strcmp(#x, (str)) == 0) { *type = x; return(TRUE); }
|
||||
|
||||
gboolean
|
||||
xaccAccountStringToType(const char* str, GNCAccountType *type) {
|
||||
xaccAccountStringToType(const char* str, GNCAccountType *type)
|
||||
{
|
||||
|
||||
GNC_RETURN_ON_MATCH(NO_TYPE);
|
||||
GNC_RETURN_ON_MATCH(BANK);
|
||||
@ -2163,6 +2188,7 @@ xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
gboolean
|
||||
xaccAccountGetReconcileLastDate (Account *account, time_t *last_date)
|
||||
{
|
||||
@ -2209,6 +2235,7 @@ xaccAccountSetReconcileLastDate (Account *account, time_t last_date)
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
gboolean
|
||||
xaccAccountGetReconcileLastInterval (Account *account, int *months, int *days)
|
||||
{
|
||||
@ -2554,6 +2581,7 @@ xaccAccountGetQuoteTZ(Account *acc)
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccAccountSetReconcileChildrenStatus(Account *account, gboolean status)
|
||||
{
|
||||
@ -2767,5 +2795,4 @@ gboolean xaccAccountRegister (void)
|
||||
return gncObjectRegister (&account_object_def);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
/* ======================= END OF FILE =========================== */
|
||||
|
@ -881,7 +881,7 @@ xaccGroupMergeAccounts (AccountGroup *grp)
|
||||
|
||||
gnc_engine_generate_event (&xaccSplitGetAccount(split)->guid,
|
||||
GNC_EVENT_MODIFY);
|
||||
xaccSplitSetAccount(split, NULL);
|
||||
split->acc = NULL;
|
||||
xaccAccountInsertSplit (acc_a, split);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ gnc_book_insert_trans_clobber (GNCBook *book, Transaction *trans)
|
||||
else
|
||||
{
|
||||
/* force to null, so remove doesn't occur */
|
||||
xaccSplitSetAccount (s, NULL);
|
||||
s->acc = NULL;
|
||||
xaccAccountInsertSplit (twin, s);
|
||||
twin->balance_dirty = TRUE;
|
||||
twin->sort_dirty = TRUE;
|
||||
@ -141,7 +141,7 @@ gnc_book_insert_trans (GNCBook *book, Transaction *trans)
|
||||
else
|
||||
{
|
||||
/* force to null, so remove doesn't occur */
|
||||
xaccSplitSetAccount (s, NULL);
|
||||
s->acc = NULL;
|
||||
xaccAccountInsertSplit (twin, s);
|
||||
twin->balance_dirty = TRUE;
|
||||
twin->sort_dirty = TRUE;
|
||||
|
@ -104,7 +104,7 @@ static void
|
||||
xaccInitSplit(Split * split, GNCBook *book)
|
||||
{
|
||||
/* fill in some sane defaults */
|
||||
xaccSplitSetAccount(split, NULL);
|
||||
split->acc = NULL;
|
||||
split->parent = NULL;
|
||||
split->lot = NULL;
|
||||
|
||||
@ -210,7 +210,7 @@ xaccFreeSplit (Split *split)
|
||||
split->value = gnc_numeric_zero();
|
||||
split->parent = NULL;
|
||||
split->lot = NULL;
|
||||
xaccSplitSetAccount(split, NULL);
|
||||
split->acc = NULL;
|
||||
|
||||
split->date_reconciled.tv_sec = 0;
|
||||
split->date_reconciled.tv_nsec = 0;
|
||||
@ -384,14 +384,6 @@ xaccSplitGetAccount (Split *s)
|
||||
return s->acc;
|
||||
}
|
||||
|
||||
void
|
||||
xaccSplitSetAccount (Split *s, Account *act)
|
||||
{
|
||||
if (!s) return;
|
||||
s->acc = act;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@ -1869,7 +1861,7 @@ xaccTransRollbackEdit (Transaction *trans)
|
||||
Account *account = s->acc;
|
||||
|
||||
s->parent = trans;
|
||||
xaccSplitSetAccount(s, NULL);
|
||||
s->acc = NULL;
|
||||
xaccStoreEntity(s->book->entity_table, s, &s->guid, GNC_ID_SPLIT);
|
||||
xaccAccountInsertSplit (account, s);
|
||||
mark_split (s);
|
||||
|
@ -211,13 +211,6 @@ void xaccTransSetGUID (Transaction *trans, const GUID *guid);
|
||||
* call this on an existing split! */
|
||||
void xaccSplitSetGUID (Split *split, const GUID *guid);
|
||||
|
||||
/* Set the value of the splits account pointer. These are 'dangerous'
|
||||
* routines, because they fail to actually remove the split from
|
||||
* its old parent account, or insert it into its new parent account.
|
||||
* Using these incorrectly is guarenteed to scramble your data
|
||||
* or even lead to bizarre crashes and hangs! Achtung! */
|
||||
void xaccSplitSetAccount(Split *s, Account *act);
|
||||
|
||||
/* The xaccFreeSplit() method simply frees all memory associated
|
||||
* with the split. It does not verify that the split isn't
|
||||
* referenced in some account. If the split is referenced by an
|
||||
|
@ -65,6 +65,8 @@ static gncLogLevel loglevel[MOD_LAST + 1] =
|
||||
GNC_LOG_DEBUG, /* SX */
|
||||
GNC_LOG_WARNING, /* BOOK */
|
||||
GNC_LOG_TRACE, /* TEST */
|
||||
GNC_LOG_DEBUG, /* LOT */
|
||||
GNC_LOG_WARNING, /* ACCOUNT */
|
||||
};
|
||||
|
||||
static FILE *fout = NULL;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/********************************************************************\
|
||||
* gnc-engine-util.h -- GnuCash engine utility functions *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1998-2001 Linas Vepstas <linas@linas.org> *
|
||||
* Copyright (C) 1998-2002 Linas Vepstas <linas@linas.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -63,7 +63,9 @@ typedef enum
|
||||
MOD_SX = 16,
|
||||
MOD_BOOK = 17,
|
||||
MOD_TEST = 18,
|
||||
MOD_LAST = 18
|
||||
MOD_LOT = 19,
|
||||
MOD_ACCOUNT = 20,
|
||||
MOD_LAST = 20
|
||||
} gncModuleType;
|
||||
|
||||
typedef enum
|
||||
|
@ -44,13 +44,14 @@
|
||||
#include "TransactionP.h"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_ENGINE;
|
||||
static short module = MOD_LOT;
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
static void
|
||||
gnc_lot_init (GNCLot *lot, GNCBook *book)
|
||||
{
|
||||
ENTER ("(lot=%p, book=%p)", lot, book);
|
||||
lot->kvp_data = NULL;
|
||||
lot->account = NULL;
|
||||
lot->splits = NULL;
|
||||
@ -59,6 +60,7 @@ gnc_lot_init (GNCLot *lot, GNCBook *book)
|
||||
lot->book = book;
|
||||
xaccGUIDNew (&lot->guid, book);
|
||||
xaccStoreEntity (book->entity_table, lot, &lot->guid, GNC_ID_LOT);
|
||||
LEAVE ("(lot=%p, book=%p)", lot, book);
|
||||
}
|
||||
|
||||
GNCLot *
|
||||
@ -78,6 +80,7 @@ gnc_lot_destroy (GNCLot *lot)
|
||||
GList *node;
|
||||
if (!lot) return;
|
||||
|
||||
ENTER ("(lot=%p)", lot);
|
||||
gnc_engine_generate_event (&lot->guid, GNC_EVENT_DESTROY);
|
||||
|
||||
xaccRemoveEntity (lot->book->entity_table, &lot->guid);
|
||||
@ -203,6 +206,7 @@ gnc_lot_add_split (GNCLot *lot, Split *split)
|
||||
Account * acc;
|
||||
if (!lot || !split) return;
|
||||
|
||||
ENTER ("(lot=%p, split=%p)", lot, split);
|
||||
acc = xaccSplitGetAccount (split);
|
||||
if (NULL == lot->account)
|
||||
{
|
||||
@ -231,6 +235,7 @@ gnc_lot_remove_split (GNCLot *lot, Split *split)
|
||||
{
|
||||
if (!lot || !split) return;
|
||||
|
||||
ENTER ("(lot=%p, split=%p)", lot, split);
|
||||
lot->splits = g_list_remove (lot->splits, split);
|
||||
split->lot = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user