GNOME Bugzilla – Bug 333572
[Patch] Currency exchange rates are not downloaded correctly
Last modified: 2018-06-29 20:59:04 UTC
Please describe the problem: If you use "Get Quotes" to download prices, currency exchange rates are not downloaded. In Gnucash 1.8 the flag that caused prices to be downloaded was set in the the account that contained the commodity in question. In 1.9 it has been moved to a more logical place in the dialog used to edit the commodity itself. However there is no way to edit a currency as a commodity so there is no way to set this flag. However, there is a kluge in xaccAccountSetCommodity that says to download exchange rates for any currency that is used in any account. Unfortunately this kluge isn't quite right. It sets the flag to get quotes, but neglects to set a quote source. Even with the quote source set, things don't work right since the quote source for currency quotes has "currency" as the name, but the the code fetching the quotes is looking for CURRENCY. With these two bugs fixed GC 1.9 downloads exchange rates ok, but if you save a file in 1.9 it loses the flags that cause 1.8 to download exchange rates. The code in gnc_account_dom_tree_create that saves this flag won't save it for a currency even if the account is a currency account. There is one last bug I found in this code. If you use --add-price-quotes to download quotes without a GUI, GC 1.9 downloads an exchange rate to convert the default currency to itself. It always gets 1 (fortunately) but it shouldn't be doing this. This happens because gnc:url->loaded-session which is used to load the file in this case gets a new session to load the file, but does not make it the default session. This means that we have two definitions of the default currency, one in the session used to load the file and the other in the default session created implicitly. These two never match so it always downloads the exchange rate for converting the default currency into itself. Steps to reproduce: 1. Create a file with accounts in more than one currency 2. Use "Get Quotes" to download quotes 3. Observe that you don't get currency exchange rates Actual results: I don't get any exchange rates Expected results: Exchange rates for converting all currencies used in the file into the default currency should be downloaded Does this happen every time? Yes Other information: I have a patch that fixes these problems which I will attach to this bug report. With these changes gnucash 1.9 downloads exchange rates properly and doesn't clobber the flag that tells version 1.8 to do so.
Sorry about the line wrapping. I don't know what caused that.
Created attachment 60741 [details] [review] Patch to fix these problems
Thanks for providing the patch.
Confirming I have the same problem, and installing this patch resolved the issue for me.
Applied as r13723. Thanks for the cleanup work on currencies.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=333572. Please update any external references or bookmarks.