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 454827 - Reports: Incorrect share value of stocks in foreign currency
Reports: Incorrect share value of stocks in foreign currency
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: General
2.2.x
Other All
: Normal normal
: ---
Assigned To: Charles Day
Chris Lyttle
Depends on:
Blocks: backport
 
 
Reported: 2007-07-08 12:15 UTC by Nikita Zhuk
Modified: 2018-06-29 21:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GnuCash data file which shows the incorrect stock value in Investment Portfolio (1.59 KB, application/octet-stream)
2007-07-08 12:17 UTC, Nikita Zhuk
Details

Description Nikita Zhuk 2007-07-08 12:15:45 UTC
Please describe the problem:
I have one stock with USD value. When I create a Investment Portfolio report and use USD as report currency, the value is calculated correctly. However, when I change the report currency to EUR, the value is incorrect.

Steps to reproduce:
1. Buy 31.00 stocks with some starting price
2. Open the Price Editor, set the last price of the stock to 40.66 USD
3. In the Price Editor, set the last price of USD currency to 0.728600 EUR
4. Open the Investment Portfolio report

Actual results:
Investment portfolio displays 918.51 EUR as the value of stocks.

Expected results:
Investment portfolio displays 918.37 EUR as the value of stocks (31 * 40.66 * 0.7286 = 918.371156 ≈ 918.37)

Does this happen every time?
Yes

Other information:
I'm using GnuCash 2.0.5 installed via MacPorts 1.442 on Mac OS X 10.4.10 on Intel Mac.


Example datafile which shows this bug can be downloaded from http://zhuk.fi/gnucash/GnuCash-Datafile.gnucash
Comment 1 Nikita Zhuk 2007-07-08 12:17:34 UTC
Created attachment 91424 [details]
GnuCash data file which shows the incorrect stock value in Investment Portfolio

Attaching the data file to this bug report so you don't have to download it from my site.
Comment 2 Nikita Zhuk 2007-07-08 15:24:45 UTC
Actually this isn't limited to the Investment Portfolio report. The same total value is displayed in the Total (EUR) column of the Accounts tab. Changing the summary and component of this bug report.
Comment 3 Nikita Zhuk 2007-07-28 18:34:00 UTC
Got the same results in GnuCash 2.2.0 (installed from MacPorts).
Comment 4 Anton Zinoviev 2007-08-17 12:59:07 UTC
A similar thing happens to me with asset report. In these reports the price of the shares is shown according to the last price I have purchased a share, not the price in "Price Editor". Moreover the calculations for foreign shares are as if they are denominated in the local currency.

My local currency is BGN and if I have shares denominated in EUR (1 EUR = 1.95 BGN), their value is roughly halfed (because GnuCash calculates shares for 1000 EUR as if they are 1000 BGN).  If I change the price of the share in "Price Editor" this changes nothing in the report. However if I buy 0.00001 share for double price (i.e. in the transaction I am entering the price in BGN even though GnuCash thinks this is EUR), then the report becomes correct.

I must add that the calculations are wrong only in the reports. In the main screen everything in EUR is being transformed correctly to BGN according to the values in "Price Editor".
Comment 5 Charles Day 2008-07-26 21:45:06 UTC
Re comment 4: Anton, is the immediate parent account of the stock account denominated in EUR or in BGN? It should be EUR. (See bug 495137.)

So you need to have something like "Assets:Investments:EUR Investments" which is denominated in EUR, with a subaccount to hold the stock that is priced in EUR.
Comment 6 Charles Day 2008-07-26 22:24:06 UTC
Nikita: Make sure that when you buy a stock, the parent of the stock account is denominated in the currency that the stock is priced in. In your attached example, you are buying a stock in USD but the parent account is EUR. This means that the price of "10" entered on the buy transaction is 10 EUR, not 10 USD. See bug 495137.

However, this doesn't fix the bug that you reported. I can reproduce your bug with the latest code and I'm working on a patch. Confirming this bug.
Comment 7 Nikita Zhuk 2008-07-26 23:01:16 UTC
(In reply to comment #6)
> Nikita: Make sure that when you buy a stock, the parent of the stock account is
> denominated in the currency that the stock is priced in.

Thanks for this recommendation. I will add this additional node to my stock account tree.
Comment 8 Charles Day 2008-07-26 23:15:42 UTC
OK, good news: My fix works and I will commit the changes soon. (The server is down at the moment.) With the attached example I now see 918.37 in the Investment Portfolio report and in the account tab.
Comment 9 Charles Day 2008-07-27 05:43:42 UTC
Fix committed as r17409. Requesting backport for 2.2.
Comment 10 Andreas Köhler 2008-09-15 14:36:57 UTC
Applied to branches/2.2 as r17510 for inclusion in GnuCash 2.2.7.
Thanks a lot!
Comment 11 André Klapper 2009-08-22 12:25:43 UTC
Also see bug 592569 - might happen again.
Comment 12 Carsten Rinke 2013-04-24 08:23:03 UTC
I loaded the attached data file with GnuCash 2.5.0 on Ubuntu 12.04 and followed the steps in Comment 1.

The EUR amount is calculated to 918.37 -> as expected.
Comment 13 Mike Alexander 2014-01-20 04:53:27 UTC
The single transaction in the attached file is rather strange.  The transaction currency is EUR and it has two splits:

 Split 1   31 AT&T   310 EUR
 Split 2   0 USD    -310 EUR

I don't know how you created a transaction like this, but if you turned on trading accounts it wouldn't be balanced.  It also implies an infinite exchange rate between USD and EUR.

Nevertheless, the Advanced Portfolio report handles this more or less correctly, mainly because it only looks at split 1 and largely ignores split 2.

The bug that causes the value to be €918.51 when it should be €918.37 is a rounding bug in the C code that handles exchanges.  If it had to go through an intermediate currency to get to the target currency (in this case first convert AT&T to USD and then USD to EUR) it was rounding the intermediate result when it shouldn't have been.  Oddly the code that handled "latest" conversions worked, but the code that handled "nearest" didn't, so your example worked ok if you switched to "latest" prices.

I've fixed this and it will be in the next build.
Comment 14 John Ralls 2018-06-29 21:42:04 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=454827. Please update any external references or bookmarks.