GnuCash
Contact   Instructions
Bug 798219 - apply/OK truncates exchange rates from 4 to 2 decimal places; enter doesn't
Summary: apply/OK truncates exchange rates from 4 to 2 decimal places; enter doesn't
Status: ASSIGNED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Currency and Commodity (show other bugs)
Version: 4.6
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
: 798223 798240 798246 798247 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-06-28 03:15 EDT by Phil Diacono
Modified: 2021-07-16 23:27 EDT (History)
9 users (show)

See Also:


Attachments
see pdf properties->subject for description of each image (331.48 KB, application/pdf)
2021-06-28 03:15 EDT, Phil Diacono
no flags Details
Fix entering prices (2.03 KB, patch)
2021-06-29 10:52 EDT, Bob
no flags Details

Description Phil Diacono 2021-06-28 03:15:12 EDT
Created attachment 374092 [details]
see pdf properties->subject for description of each image

You may recall me from such bugs as "Bug 797982 - exchange rates' decimal places (edit)" that I logged last October and the amazing gnucash team responded brilliantly quickly to fix. I am still totally impressed.

I've just pulled and built 4.6 from github and went to add an exchange rate in the price database. I wanted the AUD/USD rate to be 1.3173, so did my usual click "Add", Security: USD, Currency: AUD, Date 28/06/21; Type: Last; Price: 1.3173; OK.

However, unlike all my earlier exchange rates, this is displaying as 1.32. If I edit, same result. I exited and re-entered gnucash, shows 1.32 in Price Database, but Price Editor shows 1.3200; changing to 1.3173 again displays as 1.32.

I retried adding a new entry with the same date (asked if I wanted to replace: yes) and editing gave same result.

HOWEVER, I had been clicking "apply" and "OK" to accept the new exchange rate. When I instead hit "enter" on the keyboard, the 1.3173 was finally accepted. Weird, huh?

Subsequent accept/OK changes get truncated to 2 decimal places; "enter" changes get 4 decimal places.

Do you think you could take a squiz? Thanks.

---

config details:

$ gnucash --version
GnuCash 4.6 development version
Build ID: git 4.6+(2021-06-26)

DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
VERSION="20.04.2 LTS (Focal Fossa)"

$ dpkg -l '*sqlite*' | grep ^.i
ii  libdbd-sqlite3:amd64    0.9.0-8ubuntu1       amd64        SQLite3 database driver for libdbi
ii  libmono-sqlite4.0-cil   6.8.0.105+dfsg-2     all          Mono Sqlite library (for CLI 4.0)
ii  libqt5sql5-sqlite:amd64 5.12.8+dfsg-0ubuntu1 amd64        Qt 5 SQLite 3 database driver
ii  libsqlite3-0:amd64      3.31.1-4ubuntu0.2    amd64        SQLite 3 shared library
ii  libsqlite3-dev:amd64    3.31.1-4ubuntu0.2    amd64        SQLite 3 development files
Comment 1 Phil Diacono 2021-06-28 03:21:14 EDT
GnuCash Preferences -> Number, Date, Time -> 
Force Prices to display as decimals: Tick
Automatic decimal point: unticked
Decimal places: 2
Comment 2 John Ralls 2021-06-28 12:45:35 EDT
Confirmed. Bob, reverting 8f063159 fixes this. Prices shouldn't be rounded except for display and then to 1/100 * the currency's SCU; in this case 4 digits, not 2.
Comment 3 Bob 2021-06-29 10:52:30 EDT
Created attachment 374098 [details]
Fix entering prices

Sorry about this, did not occur to me the prices have more decimal places.

I think this change fixes it by setting the fraction of the amount edit to 0 so will not round.

The reason for the difference in behavior was that by pressing the enter key, the amount edit was being validated, (which set internal flag indicating so), before I had made the changes to print_info. Then the 'OK' button call back was triggered which eventually does the copy of values to the price database and it here that the value is checked again and as it has already passed the earlier value is retrieved and used.

I also noticed that the price editor was being populated with the rounded value of the price, the same on version 4.5, so have changed that to display the actual price which also fixes the observation above.

If OK will push this.
Comment 4 Bob 2021-06-29 10:57:17 EDT
Forgot to mention, I think made the same mistake on the price value in the stock split assistant so can make a similar change there.
Comment 5 Geert Janssens 2021-07-02 03:20:39 EDT
*** Bug 798223 has been marked as a duplicate of this bug. ***
Comment 6 Bob 2021-07-08 10:36:38 EDT
I have pushed a fix for this and will be in the next nightly and version 4.7

Will leave this open so it can easily be found for duplicates till next release.

Sorry for the error.
Comment 7 Phil Diacono 2021-07-08 22:33:58 EDT
I cherry-picked Bob's commit 8d6675442 "Bug 798219 - Price dialog prices truncated" on top of 4.6, rebuilt gnucash and can confirm this fixes the bug. Many thanks, Bob and team, yet another sterling (or even AUD/USD) effort. It is much appreciated.
Comment 8 John Ralls 2021-07-13 15:05:45 EDT
*** Bug 798240 has been marked as a duplicate of this bug. ***
Comment 9 John Ralls 2021-07-16 12:48:08 EDT
*** Bug 798246 has been marked as a duplicate of this bug. ***
Comment 10 John Ralls 2021-07-16 23:27:25 EDT
*** Bug 798247 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.