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

after the trading account was created breaks GnuCash.

Revisited. The original changeset looked for a top level trading account
and a namespace account in the transaction currency; if either of those
accounts had been created in a different currency it would duplicate
them.

This commit will accept any such account regardless of commodity. If
more than one exists it will prefer the one in the root currency if
there is one, otherwise it will select the first one found.
This commit is contained in:
John Ralls
2021-05-04 10:11:59 -07:00
parent 18c72baddf
commit 4f030aac6e
3 changed files with 129 additions and 71 deletions

View File

@@ -938,24 +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.
/** Find a direct child account matching name, GNCAccountType, and/or commodity.
*
* Note that commodity matching is by equivalence: If the
* mnemonic/symbol and namespace are the same, it matches.
* Name and commodity may be nullptr in which case the accounts in the
* list may have any value for those properties. 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 name The name of the account to look for or nullptr.
* @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.
* @param commodity The commodity in which the account should be denominated or nullptr.
* @return A GList of children matching the supplied parameters.
*/
Account *gnc_account_lookup_by_type_and_commodity (Account* root,
const char* name,
GNCAccountType acctype,
gnc_commodity* commodity);
GList *gnc_account_lookup_by_type_and_commodity (Account* root,
const char* name,
GNCAccountType acctype,
gnc_commodity* commodity);
/** @} */
/* ------------------ */