book/acct-period related bugfixes

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6484 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2002-01-02 19:03:05 +00:00
parent 950f028a46
commit 7cdd1d7751
3 changed files with 24 additions and 14 deletions

View File

@ -145,7 +145,9 @@ xaccCloneAccountSimple(const Account *from, GNCBook *book)
xaccInitAccount (ret, book); xaccInitAccount (ret, book);
xaccAccountBeginEdit (ret); /* Do not Begin/CommitEdit() here; give the caller
* a chance to fix things up, and let them do it.
* Also let caller issue the generate_event (EVENT_CREATE) */
ret->type = from->type; ret->type = from->type;
ret->accountName = g_strdup(from->accountName); ret->accountName = g_strdup(from->accountName);
@ -158,10 +160,6 @@ xaccCloneAccountSimple(const Account *from, GNCBook *book)
ret->commodity_scu = from->commodity_scu; ret->commodity_scu = from->commodity_scu;
ret->core_dirty = TRUE; ret->core_dirty = TRUE;
gnc_engine_generate_event (&ret->guid, GNC_EVENT_CREATE);
xaccAccountCommitEdit (ret);
LEAVE (" "); LEAVE (" ");
return ret; return ret;
} }
@ -181,7 +179,9 @@ xaccCloneAccount (const Account *from, GNCBook *book)
now = time(0); now = time(0);
xaccInitAccount (ret, book); xaccInitAccount (ret, book);
xaccAccountBeginEdit (ret); /* Do not Begin/CommitEdit() here; give the caller
* a chance to fix things up, and let them do it.
* Also let caller issue the generate_event (EVENT_CREATE) */
ret->type = from->type; ret->type = from->type;
ret->accountName = g_strdup(from->accountName); ret->accountName = g_strdup(from->accountName);
@ -198,10 +198,6 @@ xaccCloneAccount (const Account *from, GNCBook *book)
gnc_kvp_gemini (ret->kvp_data, &from->guid, &from->book->guid, now); gnc_kvp_gemini (ret->kvp_data, &from->guid, &from->book->guid, now);
gnc_kvp_gemini (from->kvp_data, &ret->guid, &book->guid, now); gnc_kvp_gemini (from->kvp_data, &ret->guid, &book->guid, now);
gnc_engine_generate_event (&ret->guid, GNC_EVENT_CREATE);
xaccAccountCommitEdit (ret);
LEAVE (" "); LEAVE (" ");
return ret; return ret;
} }

View File

@ -699,7 +699,7 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
// xxxxxxxxxxxxxxxxxxxxxxx // xxxxxxxxxxxxxxxxxxxxxxx
/* hack alert -- this implementation is not exactly correct. /* hack alert -- this implementation is not exactly correct.
* If the entity tables are not identical, then the 'from' book * If the entity tables are not identical, then the 'from' book
* will have a different backend than the 'to' book. This means * may have a different backend than the 'to' book. This means
* that we should get the 'from' backend to destroy this account, * that we should get the 'from' backend to destroy this account,
* and the 'to' backend to save it. Right now, this is broken. * and the 'to' backend to save it. Right now, this is broken.
* *
@ -784,15 +784,21 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
to_acc = xaccCloneAccount (from_acc, to->book); to_acc = xaccCloneAccount (from_acc, to->book);
xaccAccountBeginEdit (to_acc); xaccAccountBeginEdit (to_acc);
to->accounts = g_list_append (to->accounts, to_acc); to->accounts = g_list_insert_sorted (to->accounts, to_acc,
group_sort_helper);
to_acc->parent = to;
to_acc->core_dirty = TRUE;
/* copy child accounts too. */ /* copy child accounts too. */
if (from_acc->children) if (from_acc->children)
{ {
to_acc->children = xaccMallocAccountGroup (to->book); to_acc->children = xaccMallocAccountGroup (to->book);
to_acc->children->parent = to_acc;
xaccGroupCopyGroup (to_acc->children, from_acc->children); xaccGroupCopyGroup (to_acc->children, from_acc->children);
} }
xaccAccountCommitEdit (to_acc); xaccAccountCommitEdit (to_acc);
gnc_engine_generate_event (&to_acc->guid, GNC_EVENT_CREATE);
/* make sure that we have a symmetric, uniform number of /* make sure that we have a symmetric, uniform number of
* begin-edits, so that subsequent GroupCommitEdit's * begin-edits, so that subsequent GroupCommitEdit's

View File

@ -104,10 +104,18 @@ gnc_book_insert_trans (GNCBook *book, Transaction *trans)
if (!trans || !book) return; if (!trans || !book) return;
/* if this is the same book, its a no-op. */ /* If this is the same book, its a no-op. */
if (trans->book == book) return; if (trans->book == book) return;
/* fiddle the transaction into place in the new book */ /* If the old and new book don't share backends, then clobber-copy;
* i.e. destroy it in one backend, create it in another. */
if (book->backend != trans->book->backend)
{
gnc_book_insert_trans_clobber (book, trans);
return;
}
/* Fiddle the transaction into place in the new book */
xaccTransBeginEdit (trans); xaccTransBeginEdit (trans);
xaccRemoveEntity (trans->book->entity_table, &trans->guid); xaccRemoveEntity (trans->book->entity_table, &trans->guid);