GNOME Bugzilla – Bug 116353
Transaction Currency from stock registers?
Last modified: 2018-06-29 20:34:35 UTC
When you enter a transaction from a stock register, what should the common currency of the transaction be? It currently uses the Locale Currency, but this doesn't always work right. At least some things don't handle this properly, e.g.: ;;; WARNING (gnc:get-commodity-totalavg-prices: Sorry, currency exchange not yet implemented: $361.00 (buying 19 12415.PA ) =? EUR 0.00) So either there needs to be a way to set the 'default currency' for stock accounts, or this other bug needs to be fixed... (or both!)
*** Bug 125711 has been marked as a duplicate of this bug. ***
*** Bug 162288 has been marked as a duplicate of this bug. ***
Created attachment 58899 [details] [review] Set the transaction currency from the price DB If you enter a transaction for a commodity from the commodity's register, this patch attempts to set the currency for the transaction to the currency in which the commodity is traded by looking up a price for the commodity in the price DB. This solves the problem described here and (more fully) in 125711. Using the price DB for this seems a bit odd, but I couldn't find any other way to get a currency for the commodity and this, at least, avoids the problem if you have a price for the commodity.
Thanks. I'll look at the patch. Unfortunately it DOESN'T solve it for the case where you do not have a pricedb entry for the commodity (which would be the FIRST transaction you enter!). A better approach would be to look at the transfer account and set the txn currency to the first currency-based account you can find. This works without the pricedb entry. Keep in mind that you COULD have the same stock transacted in multiple currencies. So just using the pricedb isn't necessarily better. I think a better approach would be to refrain from setting the txn currency at the onset if the register is a non-currency, and when the txn is actually SAVED you see if you have a txn currency and if you do not you iterate over the splits until you find a currency-based account and set the txn currency then.
It's possible we could use the patch from bug #143720 to solve this problem.
*** Bug 306534 has been marked as a duplicate of this bug. ***
Created attachment 72361 [details] [review] Get currency from parent account This patch is another attempt to solve this problem. It works for the case where you have a currency based account with subaccounts for non-currency commodities. When entering a transaction in one of the subaccounts it gets the currency from the parent account. This is better than my previous patch since it doesn't depend on the price DB being present. I've been running with this patch for several months and haven't had any problems with it.
*** Bug 388104 has been marked as a duplicate of this bug. ***
*** Bug 456067 has been marked as a duplicate of this bug. ***
Any update to this bug recently? I just crash into this bug today (using GnuCash 2.2.1, sold mutual fund shares but the related bank account's deposit column is empty). It cost me 2 hours to track down to this bug (from https://lists.gnucash.org/pipermail/gnucash-user/2003-October/008945.html). Is it fixed in SVN? Or shall we document this into FAQ if it's really difficult to fix. I think it's quite easy for people to meet this problem: just sell funds or stocks and see it! Thanks!
Okay, I just applied something based on the patch in comment #7. The difference is that it actually walks up the tree instead of only looking at the parent. It also pops up a dialog if it fails, although I don't see how it could fail unless you have a top-level stock account. Note that this does not fix bug #106873, and the fix for that would make this fix unnecessary. But this one was easier to solve. Committed into trunk as r16718. Awaiting backport.
Sorry, re-opened until it gets backported.
Oh, actually this has been backported and is available in GnuCash 2.2.3, but missed the release notes.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=116353. Please update any external references or bookmarks.