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 649362 - Transfer Funds Window Exchange Rate and Decimal Points Rounding in Bill/Invoices
Transfer Funds Window Exchange Rate and Decimal Points Rounding in Bill/Invoices
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Business
2.4.x
Other All
: Normal normal
: ---
Assigned To: Derek Atkins
Christian Stimming
: 631474 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-05-04 10:54 UTC by Aris
Modified: 2018-06-29 22:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Compute the exchange rate for amount=10000000 instead of amount=1 (1.02 KB, patch)
2011-11-21 06:22 UTC, Mukund Sivaraman
rejected Details | Review

Description Aris 2011-05-04 10:54:39 UTC
Tested in MacOS 10.5.8, GnuCash 2.4.5, with Trading Accounting on (Even though this last information is not important) and EURO as main reporting currency

When creating a bill of a vendor with currency payment information different than main reporting currency and expense account used in the bill is in the major currency, there is an issue with respect to the Transfer Funds window and Exchange Rate rounding.

Example:

Bill of vendor X paid in USD (payment information currency USD)

Expense account of bill in EURO

A/P in USD

Quantity of Bill 1
 
Unit Price Amount 300 USD

When posting the bill a warning message pops up saying that there is a transfer between different currencies and informs of request for exchange rate.  Pressing ok, pops up the Transfer Funds window.

Exchange Rate set to 1.3861 indicating 1 EUR = 1.3861 USD and 1 USD = 0.721449 EUR correctly.

To Amount is automatically set incorrectly to 1.39 (equals exchange rate always rounded to second digit) instead of indicating amount (ie 216.4346). If changed to amount 238.07806 then exchange rate also changes to same amount rounded. If changed to 1.3861 and Exchange Rate is reselected both round to 1.39.

No matter what I choose (ie Exchange Rate : 1.3861 or To Amount:1.39) and press ok, the final transaction is rounded based on the exchange rate of 1.39 instead of 1.3861.

Final result

Expense Account: 215.83 EUR instead of 216.4346 (or 216.43 rounded).
Similarly the account  Trading:CURRENCY:EUR is 215.83 EUR

The result is the same whether Trading is on or off. 
On the other hand, if I do a transfer between accounts of different currencies the Exchange Rate is set correctly without any rounding and the To Amount is correctly indicated as 216.4346 in the Transfer Funds window, while the final Balance in the Expense Account is 216.43.
Comment 1 Aris 2011-05-04 19:43:30 UTC
Just to add a bit on that:

firstly when I said 238.07806 what I really meant was 216.4346.

secondly, it seems like for invoices the accuracy of the exchange rates is enforced by the CURRENCY used (i.e. fraction of USD and/or EUR is set to 1/100 and cannot be changed by the securities editor).

unlike the invoices, however, transferring between accounts with different currencies seems to allow accuracy of exchange rates different than the Security options of fraction traded (i.e. 1/100).

not sure if that is the case, but seems as a probable cause. A similar bug was reported for currency exchange rates in Bug 641863. However, it is a slightly different issue there and does not involve bills/invoices and seems to be related to simple transfers between account of different currencies.
Comment 2 Geert Janssens 2011-10-07 09:32:35 UTC
Thank you for your report. I can confirm this still happens in the latest stable (at present 2.4.7) and unstable (currently r21377) versions of GnuCash.

Also the problem isn't OS X specific. I can reproduce it on linux as well.
Comment 3 Geert Janssens 2011-11-18 09:06:57 UTC
*** Bug 631474 has been marked as a duplicate of this bug. ***
Comment 4 Mukund Sivaraman 2011-11-21 06:22:18 UTC
Created attachment 201785 [details] [review]
Compute the exchange rate for amount=10000000 instead of amount=1

To the reporter and whoever else is bitten by this bug:

I have also hit upon this problem. See this thread:
http://lists.gnucash.org/pipermail/gnucash-user/2011-November/042020.html

The cause of this bug is explained in that message. I am able to work around the bug by using this patch, which converts 10000000 into the target currency instead of just 1. The exchange rate is then computed more precisely.

Note that the patch is not elegant and is a hack, but it makes the software work correctly instead of what happens with the current behavior.

There is also a bug when you process payments. It auto-fills the amount in the customer's currency, instead of whatever payment that you received in your local currency (which you should actually fill in). That amount is assumed as the payment amount given in the local currency and converted back to the customer's currency using the transfer dialog which changes it to a radically different amount. This bug is also described in that thread. Anyway, this is just a UI quirk and can be worked around by filling in the correct amount in the local currency that was received.
Comment 5 Christian Stimming 2011-11-21 07:36:57 UTC
Comment on attachment 201785 [details] [review]
Compute the exchange rate for amount=10000000 instead of amount=1

I think it's a perfectly reasonable workaround to fix this particular rounding issue.
Comment 6 Geert Janssens 2011-12-11 17:55:25 UTC
Comment on attachment 201785 [details] [review]
Compute the exchange rate for amount=10000000 instead of amount=1

Thank you for your patch. I have chosen to fix the problem more profoundly though.

I have been looking into this a bit deeper and found the exchange rate actions during posting very confusing.

Take the original poster's example:

The bill and post to account are in USD, which means all entries are entered in USD as well.
The expense account is in EUR

When posting, an exchange rate is asked from EUR to USD, which is technically backwards, and stores it internally like that. But it calculates from USD to EUR when actually posting. It does so by actually dividing by the exchange rate from EUR to USD instead of multiplying with an exchange rate from USD to EUR.

This gives a very counter-intuitive experience.

I have applied a patch in r21713 that fixes both the rounding issue and this confusing backward conversion question. While these are strictly speaking different issues, they were difficult to fix in independent patches.
Comment 7 John Ralls 2017-09-24 22:45:26 UTC
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
Comment 8 John Ralls 2018-06-29 22:57:41 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=649362. Please update any external references or bookmarks.