Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0040275Openbravo ERP02. Master data managementpublic2019-02-26 16:532019-03-28 14:56
Leyre 
markmm82 
normalmajoralways
closedfixed 
5
 
3.0PR19Q2 
Sandrahuguet
Core
No
0040275: Error when calculating the discount field in the lines of a Sales Order
Error when calculating the discount field in the lines of a Sales Order
BACKEND:

1. Create a new discount:
    Discount/Promotion Type = Price Adjustment
    Discount % = 50
    Included Business Partners = Only those defined
        Business Partner = defined one

2. Modify the price list of a product, for example = 35.05

3. Modify the price list of another product, for example = 35.06

4. Create a new sales order, with the Partner defined previously

5. Add two lines to the sales order, with both products.

6. Verify in the lines, that, in the case of the product = 35.05, a discount of -0.03 is applied to the line.

PROBLEM:

PriceAdjustment.java class -> calculatePriceStd method

First calculated 35.05 / 2 = 17.525 -> precision 2 -> 17.53

Secondly calculate 17.53 / 2 = 35.06 and use this value to calculate the final discount: 35.05-35.06 = -0.01 -> -0.01 * 100 = -1 -> -1 / 35.05 = - 0.028 -> precision 2 -> -0.03
No tags attached.
Issue History
2019-02-26 16:53LeyreNew Issue
2019-02-26 16:53LeyreAssigned To => Triage Finance
2019-02-26 16:53LeyreModules => Core
2019-02-26 16:53LeyreResolution time => 1552950000
2019-02-26 16:53LeyreTriggers an Emergency Pack => No
2019-02-26 17:02PracticsIssue Monitored: Practics
2019-02-26 17:33SandrahuguetAssigned ToTriage Finance => markmm82
2019-02-27 03:00markmm82Statusnew => scheduled
2019-02-27 17:03LeyreSummaryError when calculating the field "amount"discount => Error when calculating the discount field in the lines of a Sales Order
2019-02-27 17:03LeyreDescription Updatedbug_revision_view_page.php?rev_id=18363#r18363
2019-02-27 17:03LeyreSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=18365#r18365
2019-02-27 17:03LeyreProposed Solution updated
2019-02-27 20:26markmm82Note Added: 0110112
2019-03-11 15:44hgbotCheckin
2019-03-11 15:44hgbotNote Added: 0110354
2019-03-11 15:44hgbotStatusscheduled => resolved
2019-03-11 15:44hgbotResolutionopen => fixed
2019-03-11 15:44hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1d09b6a639cf80ebec8b69195de78233951d047a [^]
2019-03-11 15:44SandrahuguetReview Assigned To => Sandrahuguet
2019-03-11 15:44SandrahuguetNote Added: 0110355
2019-03-11 15:44SandrahuguetStatusresolved => closed
2019-03-11 15:44SandrahuguetFixed in Version => 3.0PR19Q2
2019-03-28 14:56hudsonbotCheckin
2019-03-28 14:56hudsonbotNote Added: 0110860

Notes
(0110112)
markmm82   
2019-02-27 20:26   
Test Plan:
1. Create a new discount:
    Discount/Promotion Type = Price Adjustment
    Discount % = 50
    Included Business Partners = Only those defined
        Business Partner = defined one

2. Modify the price list of a product, for example = 35.05

3. Modify the price list of another product, for example = 35.06

4. Create a new sales order, with the Partner defined previously

5. Add two lines to the sales order, with both products.

6. Verify in the lines, that, in the case of the product = 35.05, a discount of 0 is applied to the line. Notice the same discount is applied in the other line.
(0110354)
hgbot   
2019-03-11 15:44   
Repository: erp/devel/pi
Changeset: 1d09b6a639cf80ebec8b69195de78233951d047a
Author: Mark Molina <mark.molina <at> doceleguas.com>
Date: Wed Feb 27 18:43:27 2019 -0300
URL: http://code.openbravo.com/erp/devel/pi/rev/1d09b6a639cf80ebec8b69195de78233951d047a [^]

Fixes issue 40275: Error when calculating the field "amount" discount

The discount was wrongly calculated because an incorrect rounding on its calculation.
When discounts are applied the ActualPrice is calculated from the standard price and rounded.
When the reverse process is made (calculate the Price Std from the Actual Price) could be
differences because the rounding previously done to the ActualPrice.
To avoid those differences first is divided by the price list and rounded and then multiplied
by 100 and rounded again when the discount is calculated.

---
M src/org/openbravo/erpCommon/ad_callouts/SL_Order_Amt.java
---
(0110355)
Sandrahuguet   
2019-03-11 15:44   
Code review + testing OK
(0110860)
hudsonbot   
2019-03-28 14:56   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/b2fbc1588df4 [^]
Maturity status: Test