Bug 798093 - Changing the symbol/abbreviation of a security after...

the trading account was created breaks GnuCash.

Introduces a new function, gnc_account_lookup_by_type_and_commodity
that does that, though it also looks at name for the one special case
of finding/creating the Namespace placeholder account. Adds a parameter
checkname to xaccScrubUtilityGetOrMakeAccount to flag whether to look
for the name.

Namespaces aside this makes it possible for the user to rename trading
accounts or securities independent of each other.
This commit is contained in:
John Ralls
2021-01-26 16:16:25 -08:00
parent bcbebe62b1
commit 0f8d9f6d7c
3 changed files with 56 additions and 8 deletions

View File

@@ -938,6 +938,24 @@ Account *gnc_account_lookup_by_code (const Account *parent,
*/
Account *gnc_account_lookup_by_opening_balance (Account *account, gnc_commodity *commodity);
/** Find a direct child account matching name, GNCAccountType, and commodity.
*
* Note that commodity matching is by equivalence: If the
* mnemonic/symbol and namespace are the same, it matches.
*
* @param root The account among whose children one expects to find
* the account.
* @param name The name of the account to look for. If nullptr the
* returned account will match only on acctype and commodity.
* @param acctype The GNCAccountType to match.
* @param commodity The commodity in which the account should be denominated.
* @return The book's trading account for the given commodity if
* trading accounts are enabled and one exists; NULL otherwise.
*/
Account *gnc_account_lookup_by_type_and_commodity (Account* root,
const char* name,
GNCAccountType acctype,
gnc_commodity* commodity);
/** @} */
/* ------------------ */