After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 335101 - Purchasing stock problems when not dealing with default currency
Purchasing stock problems when not dealing with default currency
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Register
git-master
Other Linux
: Normal major
: ---
Assigned To: David Hampton
Chris Shoemaker
: 340438 410604 (view as bug list)
Depends on:
Blocks: 166610 347575
 
 
Reported: 2006-03-19 11:06 UTC by Bengt Thuree
Modified: 2018-06-29 21:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix this bug (601 bytes, patch)
2006-09-01 05:16 UTC, Mike Alexander
none Details | Review

Description Bengt Thuree 2006-03-19 11:06:44 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.
Comment 1 Chris Shoemaker 2006-03-20 04:41:00 UTC
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.
Comment 2 Chris Shoemaker 2006-03-20 04:52:27 UTC
BTW, 1.8.12 also has the same behavior.
Comment 3 Bengt Thuree 2006-03-25 13:51:36 UTC
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.
Comment 4 Bengt Thuree 2006-03-30 01:17:14 UTC
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.
Comment 5 Mike Alexander 2006-09-01 05:16:52 UTC
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.
Comment 6 Mike Alexander 2006-09-01 05:19:00 UTC
*** Bug 340438 has been marked as a duplicate of this bug. ***
Comment 7 Yajun Wang 2006-11-03 09:22:06 UTC
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.
Comment 8 Abdul 2006-12-22 16:03:46 UTC
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.
Comment 9 Peter Selinger 2007-03-24 02:46:09 UTC
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.
Comment 10 Christian Stimming 2007-04-14 09:25:55 UTC
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.
Comment 11 Derek Atkins 2007-04-17 14:15:30 UTC
I've re-opened this bug so I remember that it still needs to be backported.  I'll close it again after I backport.
Comment 12 Derek Atkins 2007-04-21 19:23:42 UTC
Backported to 2.0 as r15963
Fix will be in 2.0.6
Comment 13 Christian Stimming 2010-01-04 13:07:39 UTC
*** Bug 410604 has been marked as a duplicate of this bug. ***
Comment 14 John Ralls 2018-06-29 21:00:07 UTC
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.