r15677 - gnucash/trunk/src/app-utils - Find the root based off the current account and not the book. It

David Hampton hampton at cvs.gnucash.org
Sat Mar 3 11:41:43 EST 2007


Author: hampton
Date: 2007-03-03 11:41:42 -0500 (Sat, 03 Mar 2007)
New Revision: 15677
Trac: http://svn.gnucash.org/trac/changeset/15677

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/app-utils/gnc-ui-util.h
Log:
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.




Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2007-03-02 13:19:26 UTC (rev 15676)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2007-03-03 16:41:42 UTC (rev 15677)
@@ -567,11 +567,10 @@
 }
 
 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 @@
   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 @@
     parent = root;
   g_assert(parent);
 
-  account = xaccMallocAccount (book);
+  account = xaccMallocAccount (gnc_account_get_book(root));
 
   xaccAccountBeginEdit (account);
 
@@ -673,7 +671,7 @@
   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)

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.h	2007-03-02 13:19:26 UTC (rev 15676)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.h	2007-03-03 16:41:42 UTC (rev 15677)
@@ -161,7 +161,7 @@
   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,



More information about the gnucash-changes mailing list