Bug 334564 - small deposits entered in foreign currency are wrongly converted to base currency
Summary: small deposits entered in foreign currency are wrongly converted to base curr...
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.6.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-09 18:22 UTC by Michael Berger
Modified: 2014-10-18 17:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.7.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Berger 2014-05-09 18:22:19 UTC
Prices are set as follows:
1 IDR = 0,00006212 €
1€ = 16097,87508 IDR

This is what I entered and what the Exchange Rate Editor presented me with:

deposit IDR 1 returns € 16097,87
deposit IDR 10 returns € 160978,75
deposit IDR 100 returns € 0,01
deposit IDR 1000 returns € 0,06
deposit IDR 10000 returns € 0,62
deposit IDR 100000 returns € 6,21
deposit IDR 1000000 returns € 62,12
deposit IDR 10000000 returns € 621,20
deposit IDR 100000000 returns € 6212,00 
Accordingly all respective reports (all currencies converted to base currency) showed unexpected results
Comment 1 Christian David 2014-05-11 10:48:36 UTC
"Prices are set as follows:
1 IDR = 0,00006212 €
1€ = 16097,87508 IDR

deposit IDR 1 returns € 16097,87"

this looks like the prices are set
1 € = 0,00006212 IDR and
1 IDR = 16097,87508 €
which is the the other way round than you wrote.
Comment 2 Michael Berger 2014-05-11 11:56:46 UTC
Hi Christian,
thanks for your comments. But no, the prices were definitely not set as 
you said they might. Prices are set as I had reported:

1€ = 16097,87508 IDR
1IDR = 0,00006212 €

If prices were set reversely each of my several reports with all 
currencies set to the base currency would show garbage - but they don't.
Only if I enter deposits of less than 100 IDR garbage is produced. When 
I delete those small deposits all records show again as they should.
And secondly, if prices were set reversely, why is the conversion 
starting to produce correct results when adding deposits in the 
magnitude of 100 IDR and higher? (though the precision is still behind)

I hope I did not misunderstand your comments!? If so, sorry!

Michael


On 05/11/2014 12:48 PM, Christian David wrote:
> https://bugs.kde.org/show_bug.cgi?id=334564
>
> Christian David <christian-david@web.de> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |christian-david@web.de
>
> --- Comment #1 from Christian David <christian-david@web.de> ---
> "Prices are set as follows:
> 1 IDR = 0,00006212 €
> 1€ = 16097,87508 IDR
>
> deposit IDR 1 returns € 16097,87"
>
> this looks like the prices are set
> 1 € = 0,00006212 IDR and
> 1 IDR = 16097,87508 €
> which is the the other way round than you wrote.
>
Comment 3 Alvaro Soliverez 2014-05-11 12:55:08 UTC
How many digits do you have in the price precision setting? That's in KMyMoney Settings > General > Global
Comment 4 Christian David 2014-05-11 13:38:48 UTC
Then this may help to find the bug. As you said and as we can see, the calculations for 100 IDR and above are correct (100 IDR = 0,006212 € ≈ 0,01 €) .

But below, somehow the exchange rate is reversed:
1 IDR = 0,00006212 € ⇒  1 IDR = 16097,87508 IDR

Here is to note that using the correct exchange rate would lead to 0 € ( 10 IDR = 0,0006212 € ≈ 0,00 €).
Comment 5 Michael Berger 2014-05-11 14:26:15 UTC
Hi Alvaro,
the precision is set to 8 digits

On 05/11/2014 02:55 PM, Alvaro Soliverez wrote:
> https://bugs.kde.org/show_bug.cgi?id=334564
>
> --- Comment #3 from Alvaro Soliverez <asoliverez@kde.org> ---
> How many digits do you have in the price precision setting? That's in KMyMoney
> Settings > General > Global
>
Comment 6 Michael Berger 2014-05-11 15:36:11 UTC
Hi Alvaro, Christian,
I entered deposits in amounts from 1 IDR to 1000000 IDR and this time 
observed the results in the Exchange Rate/Price Editor.
The resulting figures are - in the mathematical sense - anything else 
than equicontinuous.

Should I furnish you the resulting table?

Michael

On 05/11/2014 04:26 PM, Michael Berger wrote:
> https://bugs.kde.org/show_bug.cgi?id=334564
>
> --- Comment #5 from Michael Berger <idest@online.de> ---
> Hi Alvaro,
> the precision is set to 8 digits
>
> On 05/11/2014 02:55 PM, Alvaro Soliverez wrote:
>> https://bugs.kde.org/show_bug.cgi?id=334564
>>
>> --- Comment #3 from Alvaro Soliverez <asoliverez@kde.org> ---
>> How many digits do you have in the price precision setting? That's in KMyMoney
>> Settings > General > Global
>>
Comment 7 Alvaro Soliverez 2014-05-11 16:08:26 UTC
Please, that will provide us an additional data point to figure out what the problem is.
Comment 8 Michael Berger 2014-05-12 08:54:53 UTC
Alvaro,
here comes the list.
Prices are set:
1 IDR = 0,00006212 €
1 € = 16087,1992 IDR

deposit                  change            Exchange rates as shown in 
Price Editor
_IDR                         to amount               IDR = €           
     € = IDR_
*1                      16097,87           16097,87 0,00006212 *
2                            32195,75                16097,875          
0,00006212
3                            48293,62 16097,87333         0,00006212
5                            80489,37                16097,874          
0,00006212
10                          160978,75              16097,875          
0,00006212
50                          804893,75              16097,875          
0,00006212
80                          1287830,00            16097,875      0,00006212
85                          0,01 0,00011764           8500,00
86                          0,01 0,00011627           8600,00
88                          0,01 0,00011363           8800,00
90                          0,01 0,00011111           9000,00
100                        0,01 0,00010000           10000,00
110                        0,01 0,00009090           11000,00
125                        0,01 0,00008000           12500,00
150                        0,01 0,00006666           15000,00
200                        0,01 0,00005000           20000,00
500                        0,03 0,00006000           16666,66...
1000                      0,06 0,00006000           16999,66...
2000                      0,12 0,00006000           16666,66...
5000                      0,31 0,00006200           16129,0322...
10000                    0,62 0,00006200           16129,0322...
*16087*             1,00                    0,00006216 16087,00*
20000                    1,24 0,00006200           16129,0322...
50000                    3,11 0,00006220           16077,1704...
100000                  6,21 0,00006210           16103,0595...
500000                  31,06                        0,00006212        
16097,875...
1000000                62,12                        0,00006212        
16097,875...

* I entered 16087,1992 but the decimal points were truncated

Hope that helps!
Michael

On 05/11/2014 06:08 PM, Alvaro Soliverez wrote:
> https://bugs.kde.org/show_bug.cgi?id=334564
>
> --- Comment #7 from Alvaro Soliverez <asoliverez@kde.org> ---
> Please, that will provide us an additional data point to figure out what the
> problem is.
>
Comment 9 Cristian Oneț 2014-10-18 17:48:21 UTC
Git commit 7f61ffb728b58bbb905bba87e184e221a7d9858a by Cristian Oneț.
Committed on 18/10/2014 at 17:41.
Pushed by conet into branch 'master'.

Fix the currency conversion dialog for really big/small conversion rates.

If the to value was equal to zero when the dialog was constructed a bad
(inverse) conversion rate was applied. This code was there since version
1.5 (on CVS) of this file. I don't understand why it was added that way
but now it's fixed.

Also fixe the prices dialog to display the prices using the configured
price precision.

Now in case that the value after conversion becomes zero the transaction
can't be entered.

M  +1    -2    kmymoney/dialogs/kcurrencycalculator.cpp
M  +1    -6    kmymoney/dialogs/kmymoneypricedlg.cpp
M  +0    -1    kmymoney/dialogs/kmymoneypricedlg.h

http://commits.kde.org/kmymoney/7f61ffb728b58bbb905bba87e184e221a7d9858a
Comment 10 Cristian Oneț 2014-10-18 17:48:57 UTC
Git commit f773f22f2685f7ae6e5bbafd461873cdcc08e349 by Cristian Oneț.
Committed on 18/10/2014 at 17:41.
Pushed by conet into branch '4.7'.

Fix the currency conversion dialog for really big/small conversion rates.

If the to value was equal to zero when the dialog was constructed a bad
(inverse) conversion rate was applied. This code was there since version
1.5 (on CVS) of this file. I don't understand why it was added that way
but now it's fixed.

Also fixe the prices dialog to display the prices using the configured
price precision.

Now in case that the value after conversion becomes zero the transaction
can't be entered.
(cherry picked from commit 7f61ffb728b58bbb905bba87e184e221a7d9858a)

M  +1    -2    kmymoney/dialogs/kcurrencycalculator.cpp
M  +1    -6    kmymoney/dialogs/kmymoneypricedlg.cpp
M  +0    -1    kmymoney/dialogs/kmymoneypricedlg.h

http://commits.kde.org/kmymoney/f773f22f2685f7ae6e5bbafd461873cdcc08e349