Bug 205254 - Rounding error on investments
Summary: Rounding error on investments
Alias: None
Product: kmymoney
Classification: Unclassified
Component: general (show other bugs)
Version: git (master)
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
Depends on:
Reported: 2009-08-26 22:34 UTC by David Houlden
Modified: 2013-12-27 12:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description David Houlden 2009-08-26 22:34:26 UTC
Version:           1.0.0 (using KDE 4.2.4)
OS:                Linux

I just encountered the following on version 1.0.0.

My base currency is GBP and I was trying to enter a reinvest dividend 
transaction for some USD shares.

Total Dividend: $299.52
Amount Reinvested: $296.52
Dealing Charge: $3.00
Exchange rate: $1 = £0.6058

I entered the security name, number of shares, share price, Fees ($3.00) and a 
category of Dividend Payment in the Interest field. The total in the 
transaction editor form was shown as $299.52. So far so good.

When I clicked enter, the exchange rate editor popped up. I think this is 
where things start to go wrong. It asked me for the rate to convert $3.00 into 
GBP. Should that not be $299.52? I entered the exchange rate I wanted 
(0.6058) and it calculated the amount as £1.82. This gives an exchange rate 
of 1.82 / 3 = 0.6067. If I now look at the category for Dividend Payment I 
see a value of £181.71 which is $299.52 x 0.6067. I expected to see a value 
of £181.45 which is $299.52 x 0.6058.
Comment 1 David Houlden 2012-12-28 12:26:40 UTC
Updated to reflect that this is still happening on latest git version

This was sent to the developers mailing list on 19 Dec 2012 by Andreas about version 4.6.1

> Thomas Baumgart a écrit :
> >>
> >> When using Split transaction, the amount taken in account is only that
> >> from the first line.
> >> Other lines from the split are not taken.
> >> for example :
> >> Transport 1 438,18 INR
> >> Hotel 15 258,60 INR
> >> Total amount is 16 696,78 INR
> >> But in the window in which we enter the currency rate to be converted in
> >> default currency €
> >> the amount is only 1 438,18 INR
> >
> > Since you enter the exchange rate for the first split, and the foreign 
> > currency is the same for all splits, the exchange rate you enter for the 
> > first is used for all others automatically.
> >
> > Does this explain the scenario or am I missing something?
> >
Dear Thomas, all

The issue that Richard has mentioned above in 2006 persists in kmymoney 4.6.1
(on ubuntu 12.04). And while Thomas is correct that the exchange rate of the
first part of a split transaction is also used for the other parts of the split,
this leads toan inaccurate result (off by a few cents, possibly rounding error).
This could be avoided if the user can enter in the exchange rate dialog (just
prior to completing the transaction) the total converted amount.


Comment 2 Thomas Baumgart 2012-12-28 13:05:44 UTC
Modified target mail address to point to our new ML.
Comment 3 Thomas Baumgart 2013-12-27 12:09:46 UTC
Git commit 8901699c749384497fe6ee71309e868466c20e49 by Thomas Baumgart.
Committed on 27/12/2013 at 12:04.
Pushed by tbaumgart into branch 'master'.

Fix precision of price returned from price entry dialog

The returned price was truncated by the global price precision which
could cause all kinds of trouble when an amount was entered but the
price precision was not large enough to yield the same result in the
equation  result = amount / price * price;

Now the price is returned without precision loss in case it is based
on an amount (method is selected by the user in the dialog). In the
case the price is entered it is returned with the global price
precision in effect.
Related: bug 325953, bug 300965

M  +8    -9    kmymoney/dialogs/kcurrencycalculator.cpp
M  +12   -1    kmymoney/dialogs/kcurrencycalculator.h