Question: Rounding error in tax computation

Rounding error in tax computation

Given a tax of 9.75% Sale of 1.00 shows total of 1.10 (correct) Sale of 2.00 shows 2.19 (incorrect, computed tax is 0.195, should round up to 2.20) Sale of 3.00 shows 3.29 (correct) Sale

SS

Scott Smith

Asked

Given a tax of 9.75%

Sale of 1.00 shows total of 1.10 (correct)

Sale of 2.00 shows 2.19 (incorrect, computed tax is 0.195, should round up to 2.20)

Sale of 3.00 shows 3.29 (correct)

Sale of 4.00 shows 4.39 (correct)

Sale of 5.00 shows 5.49 (correct)

Sale of 6.00 shows 6.59 (correct, even though computed tax is 0.585, it rounds up to 0.59)

And so forth.

Our laws state that any tax computation >= 0.xx5 must round up to the next 0.xx value. That is, the PHP_ROUND_HALF_UP behavior.

How can I get SMA to observe this convention/requirement?

We actually do quite a few sales in the 2.00 range, so this error results in several manual corrections daily.

  • SS

    Scott Smith

    Answered

    9.75% tax rounds to a $0.xx5 amount at $2 and every $4 increment thereafter.

    I tested the app up through $50 and the rounding error is only evident at $2.

    My version of PHP (7.3) says 2 * 0.0975 = 0.195 and round(2 * 0.0975, 2) = 0.20

    There must be some other method being used that is rounding down instead of scientific.

    If this was only a display glitch, it would be less troubling. As it is resulting in bad data, however, it is a problem.

  • SS

    Scott Smith

    Answered

    Ah, I see we cross posted. Okay, I will wait for a fix. Thanks!

  • MS

    Mian Saleem

    Answered

    Thank you for the screenshot and the price and tax details. I will check this again before next update.

    Thanks again

  • Login to Reply