Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0007323Openbravo ERP07. Sales managementpublic2009-02-02 18:192009-03-25 10:28
rafaroda 
rafaroda 
highminoralways
closedno change required 
20Ubuntu 7.10
2.35 
 
Core
No
0007323: Discount is not correctly calculated when Price Adjustments are applied
Discount field inside in the lines of Sales or Purchase Orders is not correctly calculated when Price Adjustments are applied.
1) Create a price adjustment in 'Master Data Management || Pricing || Price Adjustments || Adjustments' with values:
* Starting date = 01-01-2000
* Discount % = 50
* Min Quantity = 499
* Business Partner = All Selected
* Product = All Selected
2) Move to Business Partner tab and select one business partner
3) Move to Product tab and select one product
4) Create a new Sales or Purchase Order for the business partner of the price adjustment
5) Create one line for the product of the price adjustment.

Notice that the Discount field is correctly calculated as:
* Unit Price = UP
* List Price = LP
* Discount = D = 100*(1-(UP/LP))

6) Save this line
7) Change quantity to 500. Unit Price should have half amount

But notice that the Discount remains the same.

8) Change Unit Price to the same value that the List Price.

Discount should be 0 but is calculated as -100.
Review https://dev.openbravo.com/websvn/openbravo/trunk/src/org/openbravo/erpCommon/ad_callouts/SL_Order_Product.java [^] specially the lines where it says:

BigDecimal discount = new BigDecimal(0.0);
    if (priceList.compareTo(discount) != 0) {
      discount = (((priceList.subtract(priceStd)).divide(priceList, 12, BigDecimal.ROUND_HALF_EVEN))
          .multiply(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_UP);
    }

Should the discount be calculated using the unit price instead of the price std?
No tags attached.
related to defect 00070982.40 closed rafaroda Unit price set to zero when you change quantity in lines created with Copy Lines button 
Issue History
2009-02-02 18:19rafarodaNew Issue
2009-02-02 18:19rafarodaAssigned To => galderromo
2009-02-02 18:19rafarodasf_bug_id0 => 2557615
2009-02-02 18:19rafarodaRegression testing => No
2009-02-02 19:01galderromoIssue Monitored: galderromo
2009-02-03 21:34galderromoNote Added: 0013111
2009-02-03 21:35galderromoAssigned Togalderromo => rafaroda
2009-02-10 10:51psarobeStatusnew => feedback
2009-02-19 14:16rafarodaSeveritymajor => minor
2009-02-20 09:16pjuvaraIssue Monitored: psarobe
2009-02-20 09:16pjuvaraNote Added: 0013789
2009-02-23 13:07rafarodaRelationship addedrelated to 0007098
2009-03-25 10:28rafarodaStatusfeedback => closed
2009-03-25 10:28rafarodaNote Added: 0014932
2009-03-25 10:28rafarodaResolutionopen => no change required

Notes
(0013111)
galderromo   
2009-02-03 21:34   
In my opinion this is not a bug.
It is different a price adjustment from a discount.
Think you are the person who introduce the information on the application. And you have your customer on the phone. The customer wants 525 units of your product, and you comunicate there is a 50% off adjustment. The customer, does not agree with the adjustment because is a very special customer, and this adjustment applies to every customer. Is asking you for an extra personal discount, so you decide to give a extra 10% (you include it on discount field). So Unitprice, supposing price list is 100 Euros will be 100 - 50 - 5 = 45 Euros. This is why I think the behaviour is ok. Therefore is not a bug.
(0013789)
pjuvara   
2009-02-20 09:16   
Reminder sent to: psarobe, rafaroda

Rafa, Pablo,

can you please review this defect and decide whether it is a defect or not?
Please consider Galder's comment and his explanation of why this is not a defect.

Thanks,

Paolo
(0014932)
rafaroda   
2009-03-25 10:28   
This is not a bug but the correct behavior of price adjustments:
* Discount is calculated as (List Price - Standard Price)/List Price: CORRECT
* When changing Unit Price, Standard Price is re-calculated: CORRECT

For a better understanding of price adjustments have a look at documentation issue 0008275

For an improvement of price adjustments have a look at feature request 0008161