Percentage discounts (code snippet included)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Percentage discounts (code snippet included)

Iain Fogg
All,

I think it's been well known that percentage discounts applied in the
POS application don't work.

I hunted the problem down and it's pretty simple. The routine that
calculates adjustments ignores anything except fixed amount adjustments.
I added a snippet of code to calculate the percentage adjustment and it
seems to work fine now.

Will try to post a JIRA and patch ASAP.

Posting this message just in case someone else was interested in the
same bug.

In case your desparate, add the following snippet to
calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
testing for "amount" adjustments):

        else if (itemAdjustment.get("sourcePercentage") != null) {
            adjustment =
                adjustment.add(setScaleByType(
                   
"SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
                   
quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
        }

My testing seemed to indicate that all is well, but since I'm not
terribly familiar with all the applications, I won't guarantee it is a
benign addition.

Cheers, Iain


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date: 7/10/2006

Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

Jacques Le Roux
Administrator
Iain,

Thanks for your feedback. I'm currently writing a message about VAT and gross pricing, trying to summarise the situation...

Jacques

From: "Iain Fogg" <[hidden email]>

> All,
>
> I think it's been well known that percentage discounts applied in the
> POS application don't work.
>
> I hunted the problem down and it's pretty simple. The routine that
> calculates adjustments ignores anything except fixed amount adjustments.
> I added a snippet of code to calculate the percentage adjustment and it
> seems to work fine now.
>
> Will try to post a JIRA and patch ASAP.
>
> Posting this message just in case someone else was interested in the
> same bug.
>
> In case your desparate, add the following snippet to
> calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
> testing for "amount" adjustments):
>
>         else if (itemAdjustment.get("sourcePercentage") != null) {
>             adjustment =
>                 adjustment.add(setScaleByType(
>                    
> "SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
>                    
> quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
>         }
>
> My testing seemed to indicate that all is well, but since I'm not
> terribly familiar with all the applications, I won't guarantee it is a
> benign addition.
>
> Cheers, Iain
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date: 7/10/2006
Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

Jacques Le Roux
Administrator
Ooops, Iain,

My answer below ("> Thanks for your feedback. I'm currently writing a message ...) was a response
to your message with subject "Re: Itemising tax on POS receipts" CCed to dev ML (strange I don't see it in the ML but I received the
original)...

About this one : are you using last svn ? Because following your first post (16/09/2006 "POS, percent discounts, and accounting") I
did some work and my tests were successful.
Please see http://svn.apache.org/viewvc?view=rev&rev=453515

Thanks

Jacques

> Iain,
>
> Thanks for your feedback. I'm currently writing a message about VAT and gross pricing, trying to summarise the situation...
>
> Jacques
>
> From: "Iain Fogg" <[hidden email]>
> > All,
> >
> > I think it's been well known that percentage discounts applied in the
> > POS application don't work.
> >
> > I hunted the problem down and it's pretty simple. The routine that
> > calculates adjustments ignores anything except fixed amount adjustments.
> > I added a snippet of code to calculate the percentage adjustment and it
> > seems to work fine now.
> >
> > Will try to post a JIRA and patch ASAP.
> >
> > Posting this message just in case someone else was interested in the
> > same bug.
> >
> > In case your desparate, add the following snippet to
> > calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
> > testing for "amount" adjustments):
> >
> >         else if (itemAdjustment.get("sourcePercentage") != null) {
> >             adjustment =
> >                 adjustment.add(setScaleByType(
> >
> > "SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
> >
> > quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
> >         }
> >
> > My testing seemed to indicate that all is well, but since I'm not
> > terribly familiar with all the applications, I won't guarantee it is a
> > benign addition.
> >
> > Cheers, Iain
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date: 7/10/2006

Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

David E Jones-2
In reply to this post by Iain Fogg

Iain,

Have you tried this out and checked other areas? My guess is that  
this would mess a few things up... The sourcePercentage is meant for  
information only and should already be accounted for an adjustment  
amount, which shouldn't be recalculated because this is not meant to  
represent all of the information that goes into that.

-David


On Oct 10, 2006, at 3:42 PM, Iain Fogg wrote:

> All,
>
> I think it's been well known that percentage discounts applied in  
> the POS application don't work.
>
> I hunted the problem down and it's pretty simple. The routine that  
> calculates adjustments ignores anything except fixed amount  
> adjustments. I added a snippet of code to calculate the percentage  
> adjustment and it seems to work fine now.
>
> Will try to post a JIRA and patch ASAP.
>
> Posting this message just in case someone else was interested in  
> the same bug.
>
> In case your desparate, add the following snippet to  
> calcItemAdjustmentBd in OrderReadHelper.java (after the if clause  
> testing for "amount" adjustments):
>
>        else if (itemAdjustment.get("sourcePercentage") != null) {
>            adjustment =
>                adjustment.add(setScaleByType(
>                    "SALES_TAX".equals(itemAdjustment.get
> ("orderAdjustmentTypeId")),
>                    quantity.multiply(unitPrice).multiply
> (itemAdjustment.getBigDecimal("sourcePercentage"))));
>        }
>
> My testing seemed to indicate that all is well, but since I'm not  
> terribly familiar with all the applications, I won't guarantee it  
> is a benign addition.
>
> Cheers, Iain
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date:  
> 7/10/2006
>

Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

Iain Fogg
David,

As mentioned I haven't tested extensively. The POS application creates
the discount adjustment, setting the "sourcePercentage" attribute of the
adjustment if the user specifies "%". From there, it seems to be
studiously ignored by everything, which is consistent with your remark
about "sourcePercentage" being informational. IWO, I can't find anything
anywhere that is trying to convert the "sourcePercentage" adjustment
into an "amount" adjustment, or anything similar. Would a better
strategy be to calculate the value of the percent discount at the source
(ie, when the POS creates the adustment)?

Cheers, Iain

David E Jones wrote:

>
> Iain,
>
> Have you tried this out and checked other areas? My guess is that this
> would mess a few things up... The sourcePercentage is meant for
> information only and should already be accounted for an adjustment
> amount, which shouldn't be recalculated because this is not meant to
> represent all of the information that goes into that.
>
> -David
>
>
> On Oct 10, 2006, at 3:42 PM, Iain Fogg wrote:
>
>> All,
>>
>> I think it's been well known that percentage discounts applied in the
>> POS application don't work.
>>
>> I hunted the problem down and it's pretty simple. The routine that
>> calculates adjustments ignores anything except fixed amount
>> adjustments. I added a snippet of code to calculate the percentage
>> adjustment and it seems to work fine now.
>>
>> Will try to post a JIRA and patch ASAP.
>>
>> Posting this message just in case someone else was interested in the
>> same bug.
>>
>> In case your desparate, add the following snippet to
>> calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
>> testing for "amount" adjustments):
>>
>>        else if (itemAdjustment.get("sourcePercentage") != null) {
>>            adjustment =
>>                adjustment.add(setScaleByType(
>>                    
>> "SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
>>                    
>> quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
>>
>>        }
>>
>> My testing seemed to indicate that all is well, but since I'm not
>> terribly familiar with all the applications, I won't guarantee it is
>> a benign addition.
>>
>> Cheers, Iain
>>
>>
>> --No virus found in this outgoing message.
>> Checked by AVG Free Edition.
>> Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date:
>> 7/10/2006
>>
>
>
>
> --No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.408 / Virus Database: 268.13.1/470 - Release Date:
> 10/10/2006
>
>



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.1/470 - Release Date: 10/10/2006

Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

Iain Fogg
In reply to this post by Jacques Le Roux
Jacques,

Thanks for the heads-up. I'm using an svn a couple of weeks old. I'll
update and re-test...

Cheers, Iain

Jacques Le Roux wrote:

> Ooops, Iain,
>
> My answer below ("> Thanks for your feedback. I'm currently writing a message ...) was a response
> to your message with subject "Re: Itemising tax on POS receipts" CCed to dev ML (strange I don't see it in the ML but I received the
> original)...
>
> About this one : are you using last svn ? Because following your first post (16/09/2006 "POS, percent discounts, and accounting") I
> did some work and my tests were successful.
> Please see http://svn.apache.org/viewvc?view=rev&rev=453515
>
> Thanks
>
> Jacques
>
>  
>> Iain,
>>
>> Thanks for your feedback. I'm currently writing a message about VAT and gross pricing, trying to summarise the situation...
>>
>> Jacques
>>
>> From: "Iain Fogg" <[hidden email]>
>>    
>>> All,
>>>
>>> I think it's been well known that percentage discounts applied in the
>>> POS application don't work.
>>>
>>> I hunted the problem down and it's pretty simple. The routine that
>>> calculates adjustments ignores anything except fixed amount adjustments.
>>> I added a snippet of code to calculate the percentage adjustment and it
>>> seems to work fine now.
>>>
>>> Will try to post a JIRA and patch ASAP.
>>>
>>> Posting this message just in case someone else was interested in the
>>> same bug.
>>>
>>> In case your desparate, add the following snippet to
>>> calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
>>> testing for "amount" adjustments):
>>>
>>>         else if (itemAdjustment.get("sourcePercentage") != null) {
>>>             adjustment =
>>>                 adjustment.add(setScaleByType(
>>>
>>> "SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
>>>
>>> quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
>>>         }
>>>
>>> My testing seemed to indicate that all is well, but since I'm not
>>> terribly familiar with all the applications, I won't guarantee it is a
>>> benign addition.
>>>
>>> Cheers, Iain
>>>
>>>
>>> --
>>> No virus found in this outgoing message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date: 7/10/2006
>>>      
>
>
>
>  



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.1/470 - Release Date: 10/10/2006

Reply | Threaded
Open this post in threaded view
|

Re: Percentage discounts (code snippet included)

Iain Fogg
In reply to this post by Jacques Le Roux
Jacques,

Just been reviewing my local patches and something has me a bit
concerned. In the snippet I emailed, the code uses "sourcePercentage",
but I think the original svn of POS actually uses "percentage". I think
the "sourcePercentage" came from me messing about with the code to see
if I could get the percent change stuff to work a while ago. This might
also explain why David was so concerned about using sourcePercentage...

If I have in fact screwed up, the change is the same, but replace
"sourcePercentage" with "percentage" in OrderReadHelper.java.
Presumably, when I get a clean update from SVN my local hacks will be
replaced with the correct reference to "percentage" in the POS code that
adds the adjustment :-)

I'll try to get in a check this later today as well.

Cheers, Iain

Jacques Le Roux wrote:

> Ooops, Iain,
>
> My answer below ("> Thanks for your feedback. I'm currently writing a message ...) was a response
> to your message with subject "Re: Itemising tax on POS receipts" CCed to dev ML (strange I don't see it in the ML but I received the
> original)...
>
> About this one : are you using last svn ? Because following your first post (16/09/2006 "POS, percent discounts, and accounting") I
> did some work and my tests were successful.
> Please see http://svn.apache.org/viewvc?view=rev&rev=453515
>
> Thanks
>
> Jacques
>
>  
>> Iain,
>>
>> Thanks for your feedback. I'm currently writing a message about VAT and gross pricing, trying to summarise the situation...
>>
>> Jacques
>>
>> From: "Iain Fogg" <[hidden email]>
>>    
>>> All,
>>>
>>> I think it's been well known that percentage discounts applied in the
>>> POS application don't work.
>>>
>>> I hunted the problem down and it's pretty simple. The routine that
>>> calculates adjustments ignores anything except fixed amount adjustments.
>>> I added a snippet of code to calculate the percentage adjustment and it
>>> seems to work fine now.
>>>
>>> Will try to post a JIRA and patch ASAP.
>>>
>>> Posting this message just in case someone else was interested in the
>>> same bug.
>>>
>>> In case your desparate, add the following snippet to
>>> calcItemAdjustmentBd in OrderReadHelper.java (after the if clause
>>> testing for "amount" adjustments):
>>>
>>>         else if (itemAdjustment.get("sourcePercentage") != null) {
>>>             adjustment =
>>>                 adjustment.add(setScaleByType(
>>>
>>> "SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
>>>
>>> quantity.multiply(unitPrice).multiply(itemAdjustment.getBigDecimal("sourcePercentage"))));
>>>         }
>>>
>>> My testing seemed to indicate that all is well, but since I'm not
>>> terribly familiar with all the applications, I won't guarantee it is a
>>> benign addition.
>>>
>>> Cheers, Iain
>>>
>>>
>>> --
>>> No virus found in this outgoing message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.407 / Virus Database: 268.13.1/466 - Release Date: 7/10/2006
>>>      
>
>
>
>  



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.1/470 - Release Date: 10/10/2006