GNOME Bugzilla – Bug 341362
Price Editor: Price is displayed as fraction instead of decimal
Last modified: 2018-06-29 21:03:49 UTC
Please describe the problem: While working on an example of stock mergers for the Concept Guide I encountered the attached display. The stock price in fractions caught my attention. The price was entered via the "Stock split druid". I'm working off of today's svn build (13953), Fedora 5 (updated May 8), x86_64. I'll attach a screen shot of the issue and the data file. Steps to reproduce: 1. Create a Assets:investment:stock account 2. Purchase Stock 3. Invoke Split druid and enter stock price on Detail screen 4. Run Adv. Portfolio report - price should be displayed with fraction 5. Price Edit stock also shows in fraction. Actual results: Stock price displays a Int and fraction Expected results: price as $x.xx00 Does this happen every time? Yes Other information: See attachments
Created attachment 65211 [details] Screen shot of issue Next attachment will be data file
Created attachment 65212 [details] GnuCash example data file
appears related to bug:348364
As bug#348364 comment#1 says: We should just use the correct gnc_numeric -> string printing function.
I have the same problem, one of my stocks in my Investment Portfolio report has for some time displayed as a fraction i.e. "$0 + 43 / 500". Only this stock has the problem. The problem seems not so much as the report code but the price fetching code for the fraction is shown in the Price Editor and the report is showing the same thing. I will attach a screen print of the price editor panel. I have checked the yahooquote - it fetches the price correctly - /test$ yahooquote lmp.ax LMP.AX L&M PETROL FPO NZ 0.086 9/21/2007 ASX
Created attachment 95991 [details] price editor panel
Confirmed. I can still reproduce this with r1740. It only happens for certain split amounts. For example, with a current balance of 10 shares, do a stock split and enter 40 for "Shares" and 3.22 for "New Price".
Re: comment 7 -- Oops, that was r17402.
Fix committed as r17407. Requesting backport for 2.2.
Please note that this fix will not repair prices that have already been created via the stock split druid. However, future stock splits will create prices correctly. I assume there are very few fractional prices already in your data file. To fix them, edit each price via the Price Editor and replace the fraction. (For example, change "3 + 11 / 50" to "3.22".)
*** Bug 496593 has been marked as a duplicate of this bug. ***
I have made some additional changes to fix this bug without doing any rounding. Please backport r17407, r17421 and r17429 for this bug. (Note: part of the purpose of r17429 is to reverse r17407.)
My problem just disappeared seemingly of its own accord some months ago, so I can not test code changes. It has not reappeared since. Sorry to be of little help here. Thanks for looking into the problem. Gnucash is a great application. David
Re comment 10: The updated version of the fix addresses old quotes created by the stock split druid. So there is no need to go back and reenter them. Re comment 13: The updated version of the fix also addresses display of downloaded quotes, both old and new. Glad you are not experiencing the problem any more, but maybe it is because some rounding was added recently. Since we don't need to round prices any more, I'll take a look and get rid it if there turns out to be any.
Re comment 13: I don't think your fractional quote could have been downloaded, as the quote module cannot create quotes with a denominator of 500. Downloaded quotes are always decimal, so they would not display as fractions. Perhaps you are not seeing the fractional price on your reports any more because you have entered or downloaded a newer price. Or maybe you corrected the fractional price by hand and forgot about it?
RE comment 15: Certainly the stock prices in the report are new updated stock prices. However I still have some of the fractional prices recorded and visible in the prices editor for example "0 + 19 / 25" for 19 May 2008 for the LMP.AX stock. I don't have full record of the fraction prices because I fixed many of them up in the price editor so that the reports would display better. But the most recent one I can find is 19 May 2008. I am not sure when I upgraded to 2.2.5 so it could have 2.2.4 or 5.
Re comment 16: OK. I don't think there's anything else that needs to be done. This fix will prevent fractional display of any price that can be turned into a decimal number, regardless of source. For example, "0 + 19 / 25" is now automatically shown as 0.76. So you should be all set once this fix gets released (probably 2.2.7).
(In reply to comment #12) > Please backport r17407, r17421 and r17429 for this bug. (Note: part of the > purpose of r17429 is to reverse r17407.) r17421 applied to branches/2.2 as part of r17511. r17407 and r17429 applied to branches/2.2 as r17512 for inclusion in GnuCash 2.2.7. Thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=341362. Please update any external references or bookmarks.