I'm experiencing a weird behavior with this module with the following setup/combination:

- 10% VAT rate
- Products price of 45, 4.50 and 450. (inclusive of vat)
- Percentage coupon of 50% discount.
- Coupon discount is taxed

When a 50% coupon applied to a subtotal of 45, 4.50 or 450 it doesn't equate properly. For 450 the 50% discount is 225.01 (should be 225). 45 the 50% discount is 22.49 (should be 22.50). 4.50 is 2.26 (should be 2.25).

Is there any rounding off problem somewhere? Its weird because I checked it with all other combination and it's working perfectly fine. This seem to be a deadly combination.

Can anybody reproduce?

Thanks.

Comments

halloffame’s picture

Tried the same setup with uc_discounts_alt module and computation comes ok.

wodenx’s picture

Status: Active » Needs review

Yes, this is a rounding error; for example, with 10% VAT and price of 450:

1, Price excl. VAT = (450/1.1)=409.090909
2, 50% discount = 409.090909/2 = 204.545454
3, uc_coupon then rounds this to 204.55 before sending it to the uc_vat price alterer
4, uc_vat altered line item = 204.55*1.1 = 225.005 which rounds to 225.01

the problem appears to be the rounding in step 3 - we might try removing line 494 of uc_coupon.module

    $coupon->amount = round($coupon->amount, variable_get('uc_currency_prec', 2));

but i have to trace through the ramifications of leaving the coupon discount amount unrounded at this point...

@longwave - do you happen to know whether removing this line would break anything?

wodenx’s picture

This is likely the same issue as #1056062: Wrong Tax Calculation.