GNOME Bugzilla – Bug 335101
Purchasing stock problems when not dealing with default currency
Last modified: 2018-06-29 21:00:07 UTC
I have the following setup. Default currency : AUD (Australian Dollars) Asset:Investment:Broker:Citi:Cash Type Bank, Currency SEK (Swedish) Asset:Investment:Broker:Citi:Stock Type Stock, Commodity ERICB.ST (Ericsson B, Stockholm/Sweden) Expense:Investment:Citi:Commission Type Expense, Currency SEK (Swedish) Running GnuCash version 1.9.2 r13665 I am doing the following 1) Enter the Cash account 2) Do a withdrawal of 10000 (description Buying Stock) 3) Specify 300 to Commission 4) Specify the rest (default) to Stock But there is no popup dialog or anything to specify how many shares you bought. When you check the Stock account, you bought 0 shares This is something I consider very critical, since I am dealing with 4 different currencies, and stocks in 4 different countries.
I confirm I can reproduce this. The default currency is not important. Also, the commission account is not important. This can be reproduced with only two accounts, the cash account and the stock account. What _does_ seem to be important is that the first split entered be the cash account split. Then, the second split will not bring up the dialog.
BTW, 1.8.12 also has the same behavior.
I managed (by brute force) to narrow it down 1.8.4 Build 8978 - Exchange window is working 1.8.4 Build 8979 - Exchange window is NOT working Diff between 78 and 79'c changelog indicates that a change was made to not run the exchange-rate dialog during certain circumstances. Perhaps this change needs some review? < * src/register/ledger-core/split-register-control.c: if the exchange < rate cell is 0 but this is NOT the blank split, then don't run < the exchange-rate dialog unless specifically requested. full diff below $ diff r8979/ChangeLog r8978/ChangeLog 12,28d11 < Support "gain/loss" balancing splits on stocks: < * src/engine/Transaction.c: fix xaccSplitGetPrice() to return '0' < if 'amount' is zero but 'value' is non-zero < * src/register/ledger-core/split-register-model-save.c: if we've < already handled the debcred cell then DON'T handle the price cell < as it will override the debcred's value. < * src/register/ledger-core/split-register.c: if #shares == 0, < price == 0, and value (buy/sell) != 0 then allow this entry; < it's an income/expense balancing split. < * src/register/ledger-core/split-register-control.c: if the exchange < rate cell is 0 but this is NOT the blank split, then don't run < the exchange-rate dialog unless specifically requested. < * src/register/ledger-core/split-register-model.c: when trying to < find the conversion rate for a split, remember if we found < a matching split (even if the amount is 0). If all matching < splits are 0, then return 0, not 1.
Small workaround is to manually right click on the Stock purchase row, and select Edit Exchange-Rate. This will manually open up the Exchange-Rate popup dialog, and you can enter the number of stocks.
Created attachment 72007 [details] [review] Patch to fix this bug This is still happening in SVN 14771. I looked at it a little bit in gdb tonight and the cause seems to be that when you tab out of the split that needs the exchange rate and gnc_table_traverse_update calls gnc_split_register_traverse (via table->control->traverse) things have been updated so that gnc_split_register_get_current_split returns a null pointer. With a null split pointer the change to gnc_split_register_handle_exchange described above in build 8979 causes the exchange rate dialog to be skipped. The attached patch (which treats a null split pointer like a pointer to the blank split) fixes this problem. I don't think it will cause problems with the original change since it was looking for an income/expense balance split in which case the split pointer will be non-null.
*** Bug 340438 has been marked as a duplicate of this bug. ***
I have a similar problem in version 2.0.2 now. Basicly, if my default currecy is CNY, I bough some stock which I transfer money from HKD account. The amount does not show up in the HKD account. It keep asking me to edit the exchange rate after expanding the transaction. However, I click from the right menu, but exchange rate window never shows up. I think GNUCASH should really fix this bug in such an internationalized world, :) Thanks for all the effort.
After trying this on version 2.0.2, I installed version 2.0.3. The problem persists. I followed the example in the Tutorial & Concepts Guide - Multiple Currencies Chapter. There was no problem transferring AUD (default) to SEK, USD & HKD accounts. The conversion made via Price Editor worked flawlessly and the foreign/AUD accounts were debited/credited correctly. Problems happened when I entered stock purchases; putting brokers fee in the split (in the stock accounts) resulted in blank entries (in the debit/credit columns) in all respective currencies accounts. Putting the brokers fee as a separate entry (in respective currencies accounts) worked fine for SEK but the USD account only credited 1/10 of the actual stock price and still blank entry for the HKD account.
I have tested Mike's patch of 2006-09-01, and it solves this problem. It seems to be a good patch (as a one-liner it is not very complex either); I propose to apply it.
The explanation from comment#5 sounds convincing to me so that we can expect there are no unintended side-effects from this patch. Applied the patch in r15879, requesting back-port. Thanks a lot.
I've re-opened this bug so I remember that it still needs to be backported. I'll close it again after I backport.
Backported to 2.0 as r15963 Fix will be in 2.0.6
*** Bug 410604 has been marked as a duplicate of this bug. ***
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=335101. Please update any external references or bookmarks.