New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revist Bug798093 #996
Revist Bug798093 #996
Conversation
This reverts commit ed486a5.
The changes to the TransScrubOrphansFast function and reports/standard/test/test-bdget.scm seem unrelated and I didn't include them in my testing. Both find_root_currency and xaccScrubUtilityGetOrMakeAccount seem to leak a GList sometimes. It seems like it would be better in xaccScrubUtilityGetOrMakeAccount if checkName is false and there are two or more accounts that match type and commodity, then prefer one that matches the name too, if any. That way if the file has two trading accounts for the same commodity it will continue to use the one with the new name rather than (perhaps) switching back to the old one. The transaction that can't be balanced still can't be balanced. I'll add something to the bug report about this. |
If it found one it would try to create an orphan account with no currency which will crash later.
This latest round picks up your suggestion from the bug about preferring the trading account whose name matches the commodity mnemonic where there's more than one trading account for a commodity. More significantly it addresses the balancing problem you have with transactions that have more than one trading account split because of an old name change by deleting all trading account splits at the beginning of |
find_root_currency calls gnc_account_get_children which returns a copy of the account list. It is this copy that I think is being leaked. Or it could just access the child list directly and not make a copy of it. |
Ah, you're right, |
I tested your changes up to e7b94d7 (which I think is current) and everything seems to work much better. It seems to use the existing trading account, if any, in all cases. It also cleans up a transaction with multiple trading accounts when it is rebalanced. Thanks for cleaning this up. I clearly didn't think about renaming commodities when I wrote that code. |
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.
@mtalexander Thanks for the reviews and catching the leaks. |
Reverts ed486a5 as that was based on seriously misunderstanding what was going on.
0f8d9f6 changes the way trading accounts are found from looking at their names and ignoring account types to looking for account-types and commodities and ignoring names in order to fix Bug 798093 with the added (supposed) advantage of allowing the top level trading account to have any name.
Sadly I overlooked a key issue in that commit: The top-level trading account and any placeholders were created with the transaction currency of the transaction that caused them to be created. The new logic wouldn't find the existing ones if the current transaction has a different currency, so it would make a new hierarchy.
This PR changes in two ways: When looking for the top-level trading account and namespace placeholder account it will accept any account currency, and if it needs to create one or both it will get the book's root account currency (if the book is old and doesn't have one it will use the currency of the first top-level income account). If, thanks to 0f8d96 there's more than one top-level trading account or namespace placeholder it will prefer one in the root account-currency but if that doesn't exist it will use the first one found.