> -----Original Message----- > From: suppressed > [mailto:suppressed On Behalf > Of Jeff Boes > Sent: Monday, July 23, 2007 5:00 PM > To: suppressed > Subject: [ic] Rounding and discounts > > > 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 <>< > suppressed Hi Jeffery, Basic mathematics rules 49.50 * 0.95 = 47.025 49.5 * 3 * 0.95 = 141.075 141.075 / 3 / 0.95 = 49.50 (here you forgot the 95%) Rounding will offset the total from the exact amounts. The divided rounded total would not give you the exact single item pricing. Dividing the rounded total: 141.07 / 3 / 0.95 = 49.49824... I believe the code is doing things the way it should Martin H. N.E.S.T. Solutions _______________________________________________ interchange-users mailing list suppressed http://www.icdevgroup.org/mailman/listinfo/interchange-users
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.