gnucash maint: Bug 798204 - Creation of Imbalance Accounts

John Ralls jralls at code.gnucash.org
Sat Jun 12 18:22:46 EDT 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/9eeff5dd (commit)
	from  https://github.com/Gnucash/gnucash/commit/68ec80e6 (commit)



commit 9eeff5dd7eb5d76a7d619409e6eacff0c9e0402d
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jun 12 15:21:50 2021 -0700

    Bug 798204 - Creation of Imbalance Accounts
    
    Search recursively when getting account by name.

diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c
index d54541114..78e9652be 100644
--- a/libgnucash/engine/Scrub.c
+++ b/libgnucash/engine/Scrub.c
@@ -463,7 +463,7 @@ find_root_currency(void)
               if (xaccAccountGetType (child) == ACCT_TYPE_INCOME)
                    root_currency = xaccAccountGetCommodity (child);
          }
-         g_free (children);
+         g_list_free (children);
     }
     return root_currency;
 }
@@ -1453,6 +1453,19 @@ xaccScrubUtilityGetOrMakeAccount (Account *root, gnc_commodity * currency,
 
     g_return_val_if_fail (root, NULL);
 
+    /* If we're looking for a name, search the whole hierarchy for the name */
+
+    if (checkname)
+    {
+        if (!accname)
+            return NULL;
+        acc = gnc_account_lookup_by_name (root, accname);
+        return acc ? acc :  construct_account (root, currency, accname,
+                                               acctype, placeholder);
+    }
+    /* Otherwise search just the current level. This is used to build
+     * a hierarchy directly under the root account for trading accounts.
+     */
     acc_list =
         gnc_account_lookup_by_type_and_commodity (root,
                                                   checkname ? accname : NULL,



Summary of changes:
 libgnucash/engine/Scrub.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list