Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033975Openbravo ERP02. Master data managementpublic2016-09-13 13:222016-09-29 00:02
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR16Q4 
aferraz
Core
No
0033975: Wrong Net Unit Price and pricestd in order and invoice lines when applying a discount of a percentage with decimals
Wrong Net Unit Price and pricestd in order and invoice lines when applying a discount of a percentage with decimals
As group admin role:
   Set the Price Precision of the Currency to 2
   Create a new product
   Add a price of 34.27 to it
   Create a Price Adjustment for that product (Discount and Promotions):
      Discount %: 64.3
      Discount Amount: 0.00
   Create a Sales Order
   Add the previously created product and check the Net Unit Price is updated to 12.34
   Book it and check the Net Unit Price is updated to 12.24
   The correct value should be 12.23
   Repeat the process for sales invoices and also in purchase flow
The problem seems to be in calculatePriceActual and calculatePriceStd functions of PriceAdjustment class as the discount percentage is rounded to the price precision after dividing it by 100. Example:

64.3 / 100 = 0.643 -> 0.64

.divide(BigDecimal.valueOf(100), precision, BigDecimal.ROUND_HALF_UP)
No tags attached.
related to defect 0032544 closed shivum039 Retail Modules automatic discounts are applied in backoffice purchase flow 
related to defect 0034103 closed markmm82 Openbravo ERP Incorrect prices are calculated in Purchase Orders/Invoices when exists discounts or promotions related to products. 
Issue History
2016-09-13 13:22ngarciaNew Issue
2016-09-13 13:22ngarciaAssigned To => Triage Finance
2016-09-13 13:22ngarciaModules => Core
2016-09-13 13:22ngarciaResolution time => 1475532000
2016-09-13 13:22ngarciaTriggers an Emergency Pack => No
2016-09-13 13:22ngarciaIssue Monitored: networkb
2016-09-15 11:16aferrazAssigned ToTriage Finance => markmm82
2016-09-20 17:27markmm82Statusnew => scheduled
2016-09-26 13:17aferrazRelationship addedrelated to 0032544
2016-09-27 17:22markmm82Note Added: 0090306
2016-09-27 17:37markmm82Relationship addedrelated to 0034103
2016-09-28 09:53hgbotCheckin
2016-09-28 09:53hgbotNote Added: 0090330
2016-09-28 09:53hgbotStatusscheduled => resolved
2016-09-28 09:53hgbotResolutionopen => fixed
2016-09-28 09:53hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e94a1240a35856cbe1cafacda5447ed54fef70fc [^]
2016-09-28 10:02aferrazReview Assigned To => aferraz
2016-09-28 10:02aferrazNote Added: 0090333
2016-09-28 10:02aferrazStatusresolved => closed
2016-09-28 10:02aferrazFixed in Version => 3.0PR16Q4
2016-09-29 00:02hudsonbotCheckin
2016-09-29 00:02hudsonbotNote Added: 0090361

Notes
(0090306)
markmm82   
2016-09-27 17:22   
Test Plan 1:
As group admin role:
   Set the Price Precision of the Currency EUR to 2 if necessary
   Create a new product
      Search key/ Name: Test
   Add two prices of 34.27 to it. For instance for Tarifa Bebidas Alegres and Tarifa de Ventas price lists versions.
   Create a Price Adjustment for that product. Go to Discount and Promotions and add a new record:
      Discount %: 64.3
      Discount Amount: 0.00
      Included Products: Only those defined
   Add the new product in tab Products
   Create a Sales Order header for Alimentos y Supermercados, S.A bp.
   Create a line to the sales order:
     Add the previously created product (Test) and check the Net Unit Price is updated to 12.23.
   Set tax to Ventas exentas, to not apply taxes.
   Remove discounts from Basic Discounts if exists.
   Book it and check the following information is updated in Sales order header and line:
     Sales Order Line:
        Net Unit Price is updated to 12.23
     Sales Order Header:
    Total Gross Amount: 12.23
    Total Net Amount: 12.23
     It is correct, there are not taxes or discounts except applied to the price with the Price adjustment previously created to the product.

Test Plan 2:
As group admin role:
   Set the Price Precision of the Currency EUR to 2 if necessary
   Create a new product
      Search key/ Name: Test-II
   Add two prices of 34.27 to it. For instance for Tarifa Bebidas Alegres and Tarifa de Ventas price lists versions.
   Create a Price Adjustment for that product. Go to Discount and Promotions and add a new record:
      Discount %: 64.3
      Discount Amount: 0.00
      Included Products: Only those defined
   Add the new product in tab Products
   Create a Sales Invoice header for Alimentos y Supermercados, S.A bp.
   Create a line to the invoice:
     Add the previously created product (Test-II) and check the Net Unit Price is updated to 12.23.
   Set tax to Ventas exentas, to not apply taxes.
   Remove discounts from Basic Discounts if exists.
   Complete it and check the following information is updated in header and line:
     Sales Invoice Line:
        Net Unit Price is updated to 12.23
     Sales Invoice Header:
    Total Gross Amount: 12.23
    Total Net Amount: 12.23
     It is correct, there are not taxes or discounts except applied to the price with the Price adjustment previously created for the product.
(0090330)
hgbot   
2016-09-28 09:53   
Repository: erp/devel/pi
Changeset: e94a1240a35856cbe1cafacda5447ed54fef70fc
Author: Mark <markmm82 <at> gmail.com>
Date: Fri Sep 23 15:37:24 2016 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/e94a1240a35856cbe1cafacda5447ed54fef70fc [^]

Fixes issue 33975: Fixed Prices in sales order and invoice lines if discounts

Modified the calculatePriceActual and calculatePriceStd methods of PriceAdjustment class to rounds correctly the price precision when discount percentage is applied.

---
M src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java
---
(0090333)
aferraz   
2016-09-28 10:02   
Code review + Testing OK
(0090361)
hudsonbot   
2016-09-29 00:02   
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/2cd54ee6264a [^]
Maturity status: Test