From: R P. <arc...@mt...> - 2008-01-17 15:35:30
|
On Tuesday 01 January 2008, Luke wrote: > Hello > > I have an invoice which appears to be calculating the discount > incorrectly. > > The line item cost is $2.95 (sellprice--the list price is $2.99, and I > lowered this on the invoice to compensate for another seeming error). > > Setting the discount to 10, with a quantity of 12, yealds a cost of > $31.80, while my calculater seems to think that it should equal $31.86. > > SL 2.8.10; PGSQL 8.2. > > Am I missing something obvious here? > > Luke Hello Luke Yup you are missing something... This is because the total amount depends on where, in the process, the discount is applied (combined with the resulting rounding) For example... if you calculate (and round if needed) the line total.... and then calculate the discount on that line total...as you are doing... (item price * quantity) * discount 2.95*12 = 35.40 (round to 35.40) 35.40 * 0.90 = $31.86 whereas SQL-ledger is applying the discount to the single item....rounding that to the nearest cent if needed..... and then generating a line total. (This method makes sense since you would usually discount the actual item price not the total) $2.95 * 0.90 =$2.655 (round to $2.65) 2.65 * 12 = $31.80 Rounding can be a pain but unfortunately it's part of the hassle when you have math that doesn't come out to exact cents. Cheers, Roy Pennington |