(0099716)
|
hgbot
|
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
---
|
|
|
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. |
|