[ic] Rounding and discounts
Jeff Boes
jeff at endpoint.com
Mon Jul 23 16:59:34 EDT 2007
I have run across a situation that highlights what I think is a problem
in the way discounts are applied.
E.g., if I have a 5% discount for an item that costs $49.50, and the
cart contains three items, then the total is
($49.50 * 3) * 0.95 = $141.075, which rounds to $141.07
That's because the IC code applies the discount to the cart by
multiplying the discount by the total cost for each item in the cart
(Vend::Interpolate::apply_discount).
However, this brings up an oddity: if I ask, "what is the discounted
price of each item?", the calculation of
$141.07 / 3 = $47.025, which rounds to $47.02
In other words, you get a different answer if you apply the discount to
each item's per-item price, round, and then multiply by the quantity,
than if you calculate the undiscounted item subtotal, then discount,
then round.
Have others encountered this problem before? Should discounts and
rounding be applied in a different way to avoid this?
--
Jeffery Boes <><
jeff at endpoint.com
More information about the interchange-users
mailing list