Rounding Error with Taxes

Thomas Baumgart thb at net-bembel.de
Mon Aug 7 14:41:08 UTC 2017


Hi Gee,

On Montag, 7. August 2017 13:01:52 CEST Gee Backhouse wrote:

> Hello,
> 
> Firstly, thank you for a great product which I use and love.
> 
> And now, my problem.
> 
> I am having to consider tax (VAT) for the first time in Kmymoney and have
> found a rounding error. I followed the excellent instructions in your pdf
> manual and they work like a dream until there's a number that it is unable
> to resolve.
> 
> *Example*: I am entering the gross amount of 17.07 and the associated tax
> amount is 20%.
> On a calculator 17.07 gives 14.225 + 2.845
> In Kmymoney 17.07 gives 14.22 + 2.84 (automatically as shown in the
> attached). So, Kmymoney appears to round each value down and leave me with
> a discrepancy - which I am also unable to override manually.

Rounding is a tricky business. There are many ways out there, how rounding can 
be performed. See https://www.mathsisfun.com/numbers/rounding-methods.html for 
a good overview.

What are the values that you expect to show up? Is it 14.23 and 2.84 or 14.22 
and 2.85? The method we currently use on the net amount is documented as 
follows:

    RoundRound                 /**<
                                * Use RoundHalfDown for 0.1 .. 0.4 and
                                * RoundHalfUp for 0.6 .. 0.9. Use RoundHalfUp
                                * for 0.5 in case the resulting numerator
                                * is odd, RoundHalfDown in case the resulting
                                * numerator is even.
                                * e.g. 0.5 -> 0.0 and 1.5 -> 2.0
                                */


I am using the feature myself extensively and never had these problems. OK, my 
VAT percentage is 19% so that seems to give odd numbers to not run into this 
scenario.

> Can you help?

We will try. I have no immediate solution (other as to turn off the automatic 
VAT assignment for now and enter values manually). I think I have localized 
the source of the problem and can then fix it in source. This comes to my next 
question:

Which version of KMyMoney are you using?

> Many thanks. Yours hopefully,

-- 

Regards

Thomas Baumgart

https://www.telegram.org/       Telegram, the better WhatsApp
-------------------------------------------------------------
On Windoze it helps to reboot, on UNIX it helps to be root!
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 846 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20170807/f16354f6/attachment.sig>


More information about the KMyMoney-devel mailing list