Find the root based off the current account and not the book. It

matters in this situation as the accounts haven't actually been added
to the book yet.  Fixes #414118.




git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15677 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2007-03-03 16:41:42 +00:00
parent b5cff8e9b5
commit 37e232fc10
2 changed files with 5 additions and 7 deletions

View File

@ -567,11 +567,10 @@ equity_base_name (GNCEquityType equity_type)
}
Account *
gnc_find_or_create_equity_account (QofBook *book,
gnc_find_or_create_equity_account (Account *root,
GNCEquityType equity_type,
gnc_commodity *currency)
{
Account *root;
Account *parent;
Account *account;
gboolean name_exists;
@ -582,11 +581,10 @@ gnc_find_or_create_equity_account (QofBook *book,
g_return_val_if_fail (equity_type >= 0, NULL);
g_return_val_if_fail (equity_type < NUM_EQUITY_TYPES, NULL);
g_return_val_if_fail (currency != NULL, NULL);
g_return_val_if_fail (book != NULL, NULL);
g_return_val_if_fail (root != NULL, NULL);
base_name = equity_base_name (equity_type);
root = gnc_book_get_root_account(book);
account = gnc_account_lookup_by_name(root, base_name);
if (account && xaccAccountGetType (account) != ACCT_TYPE_EQUITY)
account = NULL;
@ -638,7 +636,7 @@ gnc_find_or_create_equity_account (QofBook *book,
parent = root;
g_assert(parent);
account = xaccMallocAccount (book);
account = xaccMallocAccount (gnc_account_get_book(root));
xaccAccountBeginEdit (account);
@ -673,7 +671,7 @@ gnc_account_create_opening_balance (Account *account,
g_return_val_if_fail (account != NULL, FALSE);
equity_account =
gnc_find_or_create_equity_account (book,
gnc_find_or_create_equity_account (gnc_account_get_root(account),
EQUITY_OPENING_BALANCE,
xaccAccountGetCommodity (account));
if (!equity_account)

View File

@ -161,7 +161,7 @@ typedef enum
NUM_EQUITY_TYPES
} GNCEquityType;
Account * gnc_find_or_create_equity_account (QofBook *book,
Account * gnc_find_or_create_equity_account (Account *root,
GNCEquityType equity_type,
gnc_commodity *currency);
gboolean gnc_account_create_opening_balance (Account *account,