Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0036969
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] 03. Procurement managementmajoralways2017-09-28 12:332018-01-03 12:38
ReporterngarciaView Statuspublic 
Assigned Tomarkmm82 
PriorityurgentResolutionfixedFixed in Version3.0PR18Q1
StatusclosedFix in branchFixed in SCM revision5f2720a854cc
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Toaferraz
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0036969: Purchase order lines created from Requisitions are created with 0 price if price list includes taxes and a discount is defined

DescriptionPurchase order lines created from Requisitions are created with 0 price if price list includes taxes and a discount is defined
Steps To ReproduceAs group admin role:
   Create a new record in Discounts and Promotions window:
      Discount/Promotion Type: Price Adjustment
      Included Product: Only those defined
      Discount %: 50
      Add Cerveza Ale 0,5L product in Products tab

   Change Tarifa Bebidas Alegres to Price includes tax = Y
   Create a new Requisition
      Business Partner. Bebidas Alegres, S.L.
   Add the previously created product and complete it
   Go to Manage Requisitions window and Create Purchase Order
   Go to Purchase Order and check the Gross Unit Price, Line Net Amount and Line Gross Amount are 0
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0038085 closedmarkmm82 Prices in Invoice lines of discounts copied by Copy Lines process are updated to 0 when completing if a price adjustment exists 

-  Notes
(0099716)
hgbot (developer)
2017-10-03 13:43

Repository: erp/devel/pi
Changeset: 5f2720a854ccbb7a34411ddfb013207705781de0
Author: Mark <markmm82 <at> gmail.com>
Date: Mon Oct 02 17:19:19 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/5f2720a854ccbb7a34411ddfb013207705781de0 [^]

Fixes issue 36969: Purchase order created from Requisitions created with 0 price

Purchase order lines created from Requisitions are created with 0 price if price
list includes taxes and a discount is defined.

When M_REQUISITION_CREATEPO process is executed it creates the order and its lines.
Then it call the C_ORDER_POST1, to process the created order and it calls the
M_PROMOTION_CALCULATE to recalculate prices and quantities if discounts, and in
this case it uses the grosspricestd of lines to recalculates the gross_unit_price
and line_gross_amount if price list includes taxes:

if (v_taxIncluded = 'Y') then
update c_orderline set
    gross_unit_price = grosspricestd,
    line_gross_amount = round(grosspricestd * qtyordered, v_stdPrecision)
where c_orderline_id = Cur_Order.id;

The process was failling because order lines were created without a GROSSPRICESTD
column defined, and it was taking 0 instead of the right price. Due that, when the
values of the lines were recalculated to apply discounts it reset all values to ZERO
and order ends with incorrect totals.

To avoid that, the GROSSPRICESTD is defined when the lines are created.

---
M src-db/database/model/functions/M_REQUISITION_CREATEPO.xml
---
(0099717)
aferraz (developer)
2017-10-03 13:43

Code review + Testing OK
(0099718)
aferraz (developer)
2017-10-03 13:45

Test Plan 1: Create PO from requisition, Price List including taxes and applying a discount
As group admin role:
   Create a new record in Discounts and Promotions window:
      Discount/Promotion Type: Price Adjustment
      Included Product: Only those defined
      Discount %: 50
      Add Cerveza Ale 0,5L product in Products tab

   Change Tarifa Bebidas Alegres to Price includes tax = Y
   Verify Cerveza Ale 0,5L has a Unit Price = List Price = 1.36

   Create a new Requisition
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Add a line to it:
      Need by date: Next week
      Product: Cerveza Ale 0,5L
      Quantity: 10 Units
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Complete the requisition.
   Go to Manage Requisitions window and Create Purchase Order from created requisition. take note of the document no. of generated purchase order.
   Go to Purchase Order header and check the following values:
      Total Gross Amount: 6.80
      Total Net Amount: 5.62
   Go to Lines and see the created line has the following values:
      Product: Cerveza Ale 0,5L
      Ordered Quantity: 10
      Net Unit Price: 0.56
      Gross Unit Price: 0.68
      Line Net Amount: 5.62
      Line Gross Amount: 6.80
      Tax: Adquisiciones IVA 21%

      As Price Includes Taxes, Gross Unit Price (GUP)
      GUP = Price List Unit Price - discount
      GUP = 1.36 - (1.36 * 0.5)
      GUP = 0.68

      Net Unit Price Computation (NUP)
      NUP + NUP * TAX = GUP
      NUP + NUP * 0.21 = 0.68
      NUP (1 + 0.21) = 0.68
      NUP = 0.68 / 1.21
      NUP = 0.56198
      NUP = 0.56 (Rounded)

      Line Net Amount = Net Unit Price * Qty = 0.56198 * 10 = 5.6198 = 5.62 rounded
      Line Gross Amount = Gross Unit Price * Qty = 0.68 * 10 = 6.80

Test Plan 2: Create PO from requisition, Price List NOT including taxes and applying a discount
As group admin role:
   Create a new record in Discounts and Promotions window:
      Discount/Promotion Type: Price Adjustment
      Included Product: Only those defined
      Discount %: 50
      Add Cerveza Ale 0,5L product in Products tab

   Change Tarifa Bebidas Alegres to Price includes tax = N
   Verify Cerveza Ale 0,5L has a Unit Price = List Price = 1.36

   Create a new Requisition
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Add a line to it:
      Need by date: Next week
      Product: Cerveza Ale 0,5L
      Quantity: 10 Units
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Complete the requisition.
   Go to Manage Requisitions window and Create Purchase Order from created requisition. take note of the document no. of generated purchase order.
   Go to Purchase Order header and check the following values:
      Total Gross Amount: 8.23
      Total Net Amount: 6.80
   Go to Lines and see the created line has the following values:
      Product: Cerveza Ale 0,5L
      Ordered Quantity: 10
      Net Unit Price: 0.68
      Line Net Amount: 6.80
      Net List Price: 1.36
      Tax: Adquisiciones IVA 21%

      As Price NOT Includes Taxes, Net Unit Price Computation (NUP)
      NUP = Price List Unit Price - discount
      NUP = 1.36 - (1.36 * 0.5)
      NUP = 0.68

      Line Net Amount = Net Unit Price * Qty = 0.68 * 10 = 6.80
      
      Header Total Gross Amount = Line Net Amount + Tax = 6.80 + (6.80 * 0.21) = 8.228 = 8.23 rounded.


Test Plan 3: Create PO from requisition, Price List NOT including taxes
As group admin role:
   Remove any discount if exists for Cerveza Ale.

   Change Tarifa Bebidas Alegres to Price includes tax = N
   Verify Cerveza Ale 0,5L has a Unit Price = List Price = 1.36

   Create a new Requisition
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Add a line to it:
      Need by date: Next week
      Product: Cerveza Ale 0,5L
      Quantity: 10 Units
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Complete the requisition.
   Go to Manage Requisitions window and Create Purchase Order from created requisition. take note of the document no. of generated purchase order.
   Go to Purchase Order header and check the following values:
      Total Gross Amount: 16.46
      Total Net Amount: 13.60
   Go to Lines and see the created line has the following values:
      Product: Cerveza Ale 0,5L
      Ordered Quantity: 10
      Net Unit Price: 1.36
      Line Net Amount: 13.60
      Net List Price: 1.36
      Tax: Adquisiciones IVA 21%
 
      Header Total Gross Amount = Line Net Amount + Tax = 13.60 + (13.60 * 0.21) = 16.456 = 16.46 rounded.


Test Plan 4: Create PO from requisition, Price List including taxes
As group admin role:
   Remove any discount if exists for Cerveza Ale.

   Change Tarifa Bebidas Alegres to Price includes tax = Y
   Verify Cerveza Ale 0,5L has a Unit Price = List Price = 1.36

   Create a new Requisition
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Add a line to it:
      Need by date: Next week
      Product: Cerveza Ale 0,5L
      Quantity: 10 Units
      Business Partner: Bebidas Alegres, S.L.
      Price List: Tarifa Bebidas Alegres
   Complete the requisition.
   Go to Manage Requisitions window and Create Purchase Order from created requisition. take note of the document no. of generated purchase order.
   Go to Purchase Order header and check the following values:
      Total Gross Amount: 13.60
      Total Net Amount: 11.24
   Go to Lines and see the created line has the following values:
      Product: Cerveza Ale 0,5L
      Ordered Quantity: 10
      Net Unit Price: 1.12
      Gross Unit Price: 1.36
      Line Net Amount: 11.24
      Line Gross Amount: 13.60
      Tax: Adquisiciones IVA 21%

      As Price Includes Taxes, Gross Unit Price (GUP)
      GUP = 1.36

      Net Unit Price Computation (NUP)
      NUP + NUP * TAX = GUP
      NUP + NUP * 0.21 = 1.36
      NUP (1 + 0.21) = 1.36
      NUP = 1.36 / 1.21
      NUP = 1.1239
      NUP = 1.12 (Rounded)

      Line Net Amount = Net Unit Price * Qty = 1.1239 * 10 = 11.239 = 11.24 rounded
      Line Gross Amount = Gross Unit Price * Qty = 1.36 * 10 = 13.60


For all test cases 1 to 4 you can compare doing manual Purchase orders and you will get the same results.
(0101308)
hudsonbot (developer)
2018-01-03 12:38

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/c81e0d3cbab5 [^]
Maturity status: Test

- Issue History
Date Modified Username Field Change
2017-09-28 12:33 ngarcia New Issue
2017-09-28 12:33 ngarcia Assigned To => Triage Finance
2017-09-28 12:33 ngarcia Modules => Core
2017-09-28 12:33 ngarcia Triggers an Emergency Pack => No
2017-09-28 12:33 ngarcia Issue Monitored: networkb
2017-09-28 16:39 aferraz Assigned To Triage Finance => markmm82
2017-09-28 23:50 markmm82 Status new => scheduled
2017-10-03 13:43 hgbot Checkin
2017-10-03 13:43 hgbot Note Added: 0099716
2017-10-03 13:43 hgbot Status scheduled => resolved
2017-10-03 13:43 hgbot Resolution open => fixed
2017-10-03 13:43 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/5f2720a854ccbb7a34411ddfb013207705781de0 [^]
2017-10-03 13:43 aferraz Review Assigned To => aferraz
2017-10-03 13:43 aferraz Note Added: 0099717
2017-10-03 13:43 aferraz Status resolved => closed
2017-10-03 13:43 aferraz Fixed in Version => 3.0PR18Q1
2017-10-03 13:45 aferraz Note Added: 0099718
2018-01-03 12:38 hudsonbot Checkin
2018-01-03 12:38 hudsonbot Note Added: 0101308
2018-03-08 15:55 ngarcia Relationship added related to 0038085


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker