Login  Register

Re: POS, percent discounts, and accounting

Posted by Jacques Le Roux on Sep 19, 2006; 7:13pm
URL: http://ofbiz.116.s1.nabble.com/POS-percent-discounts-and-accounting-tp172514p172515.html

Thanks Iain for this interesting work,

I have no time yet to work on this but hope to do some in a near future.

In the meantime I put this information in the related Jira : http://issues.apache.org/jira/browse/OFBIZ-289

Jacques

----- Original Message -----
From: "Iain Fogg" <[hidden email]>
To: <[hidden email]>
Sent: Saturday, September 16, 2006 6:15 PM
Subject: POS, percent discounts, and accounting


> 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