I've been investigating the reasons behind order and item percentage discounts not working in POS...

I've focused on order-level (Sale Disc) to start, and it seem pretty clear why it doesn't work. The POS application adds the "percent" order adjustment to the cart, and when the grand total is calculated "calcOrderAdjustmentBd(GenericValue, BigDecimal)" (in OrderReadHelper.java) quite happily ignores the adjustment because the orderAdjustment.get("amount") returns null - quite right too since our adjustment is a "percent". IWO, calcOrderAdjustmentBd only takes notice of "amount" adjustments.

Compare this with the handling of something like an order level discount applied via Order Entry. For example, if you apply a 10% promotional discount to the order, ProductPromoWorker.performAction has code for handling the percentage discount.

The question is, can we mod OrderReadHelper.calcOrderAdjustmentBd with impunity to include handling of "percent" discounts?

First up, we need to change the order adjustment type in POS to "sourcePercentage" or we just fail with an exception (others have spotted this in the past). In my testing, I added the following block of code to calcOrderAdjustmentBd:

       else if (orderAdjustment.get("sourcePercentage") != null) {
// round amount to best precision (taxCalcScale) because db value of 0.825 is pulled as 0.8249999... BigDecimal percent = orderAdjustment.getBigDecimal("sourcePercentage").setScale(taxCalcScale, taxRounding); BigDecimal amount = orderSubTotal.multiply(percent).setScale(taxCalcScale, taxRounding);
           adjustment = adjustment.add(amount);
       }


Run POS, create an order, and then apply a percent discount to the order and POS updates to reflect the adjustment. Looks good so far, but....

Is this mod likely to break other apps that might have "sourcePercentage" adjustments?

The accounting needs to be tweaked. I checked out the transactions entered into the GL, and it records a SALES_ACCTG_TRANS for the non-discounted amount and a PAYMENT_ACCTG_TRANS for the discounted amount. (If you do an "amount" discount in POS, this is correctly recorded in the GL).

This needs someone with a deeper understanding of the core code (inc. Accounting) to fix properly.

Cheers, Iain


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date: 15/09/2006

Reply via email to