Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036878Openbravo ERP04. Warehouse managementpublic2017-09-18 14:542018-01-08 18:22
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR18Q1 
dmiguelez
Core
No
0036878: [Valued Stock Report]: Wrong Actual Cost and Valuation if the costing rule is validated with warehouse dimension
[Valued Stock Report]: Wrong Actual Cost and Valuation if the costing rule is validated with warehouse dimension
As group admin role:
   Validate a new Costing Rule for F&B España, S.A. selecting Warehouse Dimension
   Create a new product for F&B España, S.A.
   Create a new Physical Inventory for F&B España, S.A.
   Add 1 unit of the previously created product in RN-0-0-0 storage bin with a cost of 5 and 1 unit in RS-0-0-0 with a cost of 8
   Process it
   Schedule the Costing Background Process to run immediately

   Launch the Valued Stock Report and check two lines are shown for the same product in Region Norte warehouse and two in Region Sur warehouse (one with each cost). Only one line should be shown with the actual cost that belongs to each warehouse

   Create a Goods receipt and add 1 unit of the previously created product

   Schedule the Costing Background Process to run immediately

   Launch the Valued Stock Report and check although one line is shown for each warehouse, the actual cost that belongs to Region Norte (5) is shown for Region Sur too
No tags attached.
Issue History
2017-09-18 14:54ngarciaNew Issue
2017-09-18 14:54ngarciaAssigned To => Triage Finance
2017-09-18 14:54ngarciaModules => Core
2017-09-18 14:54ngarciaResolution time => 1507500000
2017-09-18 14:54ngarciaTriggers an Emergency Pack => No
2017-09-18 14:55ngarciaIssue Monitored: networkb
2017-09-18 15:02eugeniIssue Monitored: eugeni
2017-09-19 17:35aferrazAssigned ToTriage Finance => markmm82
2017-09-19 19:15markmm82Statusnew => scheduled
2017-09-21 23:38markmm82Note Added: 0099446
2017-09-28 19:30markmm82Note Added: 0099670
2017-10-10 10:20dmiguelezNote Added: 0099845
2017-10-10 10:21dmiguelezNote Added: 0099846
2017-10-10 13:12hgbotCheckin
2017-10-10 13:12hgbotNote Added: 0099848
2017-10-10 13:12hgbotStatusscheduled => resolved
2017-10-10 13:12hgbotResolutionopen => fixed
2017-10-10 13:12hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/387066f2baf1e2a3cbd992a79a8ba5ca12483425 [^]
2017-10-10 13:12hgbotCheckin
2017-10-10 13:12hgbotNote Added: 0099849
2017-10-10 13:12hgbotCheckin
2017-10-10 13:12hgbotNote Added: 0099850
2017-10-10 13:13dmiguelezReview Assigned To => dmiguelez
2017-10-10 13:13dmiguelezNote Added: 0099851
2017-10-10 13:13dmiguelezStatusresolved => closed
2018-01-03 12:38hudsonbotCheckin
2018-01-03 12:38hudsonbotNote Added: 0101322
2018-01-03 12:38hudsonbotCheckin
2018-01-03 12:38hudsonbotNote Added: 0101323
2018-01-03 12:38hudsonbotCheckin
2018-01-03 12:38hudsonbotNote Added: 0101324
2018-01-08 18:22dmiguelezFixed in Version => 3.0PR18Q1

Notes
(0099446)
markmm82   
2017-09-21 23:38   
Test Plan:
As group admin role:
   Validate a new Costing Rule for F&B España, S.A. selecting Warehouse Dimension
   Create a new product for F&B España, S.A.
   Create a new Physical Inventory for F&B España, S.A.
   Add 1 unit of the previously created product in RN-0-0-0 storage bin with a cost of 5 and 1 unit in RS-0-0-0 with a cost of 8
   Process it
   Schedule the Costing Background Process to run immediately

   Launch the Valued Stock Report and check one line is show for the product in Region Norte warehouse and one in Region Sur warehouse (one with each cost 5 and 8).

   Create a Goods receipt and add 1 unit of the previously created product

   Schedule the Costing Background Process to run immediately

   Launch the Valued Stock Report and check one new line is shown for selected warehouse in receipt, for example Region Norte
(0099670)
markmm82   
2017-09-28 19:30   
Test Plan 1: Costing Rule selecting Warehouse Dimension
As group admin role:
   Validate a new Costing Rule for F&B España, S.A. selecting Warehouse Dimension
   Create a new product for F&B España, S.A. Product Category = Others.
   Create a new Physical Inventory for F&B España, S.A.
   Add 1 unit of the previously created product in RN-0-0-0 storage bin with a cost of 5 and 1 unit in RS-0-0-0 with a cost of 8
   Process it

   Schedule the Costing Background Process to run immediately
   Go to Product and move to Costing tab. Notice there are two costs calculated, one for each warehouse:
       For Norte: Cost = 5, Net Unit Price = 5, Total Movement quantity = 1, Total Stock Valuation = 5
       For Sur : Cost = 8, Net Unit Price = 8, Total Movement quantity = 1, Total Stock Valuation = 8

   Launch the Valued Stock Report, filter by F&B España, S.A. organization and Others product category.
    Check one line is show for the product in Region Norte warehouse and one in Region Sur warehouse.
    In Region Norte warehouse:
       Quantity = 1
       Unit Cost = 5
       Valuation = 5
       Actual Cost = 5
       Actual Valuation = 5
    In Region Sur warehouse:
       Quantity = 1
       Unit Cost = 8
       Valuation = 8
       Actual Cost = 8
       Actual Valuation = 8
    This is right according the last cost computation for the product.

   Create a Goods receipt and add 1 unit of the previously created product, for Region Norte warehouse.

   Schedule the Costing Background Process to run immediately.
   Go to Product and move to Costing tab. Notice there is a new cost for Region Norte warehouse:
       For Norte: Cost = 5, Net Unit Price = 5, Total Movement quantity = 2, Total Stock Valuation = 10

   Launch the Valued Stock Report and check line was updated for selected warehouse in receipt, for example Region Norte:
     In Region Norte warehouse:
       Quantity = 2
       Unit Cost = 5
       Valuation = 10
       Actual Cost = 5
       Actual Valuation = 10
     This is right according the last cost computation for the product.

     Notice the product still with the same values in Region Sur warehouse
       Quantity = 1
       Unit Cost = 8
       Valuation = 8
       Actual Cost = 8
       Actual Valuation = 8

     Launch the Valued Stock Report with the same filters but selecting Consolidated warehouse option.
     Notice this time information is grouped by product and all warehouses:
       Quantity = 3 (2 Units in Region Norte + 1 in Region Sur)
       Unit Cost = 6 (Cost in Norte is 10 + Cost in Sur is 8 = 18. 18 / Quantity = 18 /3 = 6)
       Valuation = 18 (Quantity * Unit Cost = 3 * 6 = 18)
       Actual Cost = 5 (Last cost in Costing Tab of Product)
       Actual Valuation = 15 (Quantity * Actual Cost = 3 * 5 = 15)


Test Plan 2: Costing Rule without select Warehouse Dimension
As group admin role:
   Validate a new Costing Rule for F&B España, S.A. selecting Warehouse Dimension
   Create a new product for F&B US, Inc Product Category = Others.
   Create a new Physical Inventory for F&B España, S.A.
   Add 1 unit of the previously created product in RN-0-0-0 storage bin with a cost of 5 and 1 unit in RS-0-0-0 with a cost of 8
   Process it

   Schedule the Costing Background Process to run immediately
   Go to Product and move to Costing tab. Notice there are two costs calculated, this time without specify warehouse:
       First cost : Cost = 5, Net Unit Price = 5, Total Movement quantity = 1, Total Stock Valuation = 5
       Second cost: Cost = 6.50, Net Unit Price = 8, Total Movement quantity = 2, Total Stock Valuation = 13

   Launch the Valued Stock Report, filter by F&B España, S.A. organization and Others product category.
    Check one line is shown for the product in Region Norte warehouse and one in Region Sur warehouse.
    In Region Norte warehouse:
       Quantity = 1
       Unit Cost = 5
       Valuation = 5
       Actual Cost = 6.5
       Actual Valuation = 6.5
    In Region Sur warehouse:
       Quantity = 1
       Unit Cost = 8
       Valuation = 8
       Actual Cost = 6.5
       Actual Valuation = 6.5
    This is right according the last cost computation for the product.

   Create a Goods receipt and add 1 unit of the previously created product, for Region Norte warehouse.

   Schedule the Costing Background Process to run immediately.
   Go to Product and move to Costing tab. Notice there is a new cost:
       Third cost: Cost = 6.5, Net Unit Price = 6.5, Total Movement quantity = 3, Total Stock Valuation = 19.5

   Launch the Valued Stock Report and check line was updated for selected warehouse in receipt, for example East Coast:
     In Region Norte warehouse:
       Quantity = 2
       Unit Cost = 5.75 ((First Cost of 5.0 + Second cost of 6.50 for Norte warehouse) / 2 = 11.50 / 2 = 5.75)
       Valuation = 11.50 (First Cost of 5.0 + Second cost of 6.50 for Norte warehouse = 11.50)
       Actual Cost = 6.50 (Last cost for product)
       Actual Valuation = 13 (Quantity * Actual Cost = 2 * 6.50 = 13.00)
     This is right according the last cost computation for the product.

     Notice the product still with the same values in Region Sur warehouse
       Quantity = 1
       Unit Cost = 8
       Valuation = 8
       Actual Cost = 6.50
       Actual Valuation = 6.50

     Launch the Valued Stock Report with the same filters but selecting Consolidated warehouse option.
     Notice this time information is grouped by product and all warehouses:
       Quantity = 3 (2 Units in Region Norte + 1 in Region Sur)
       Unit Cost = 6.50 (Last Cost)
       Valuation = 19.50 (Quantity * Unit Cost = 3 * 6.50 = 19.50)
       Actual Cost = 6.50 (Last cost in Costing Tab of Product)
       Actual Valuation = 19.50 (Quantity * Actual Cost = 3 * 6.5 = 19.50)
(0099845)
dmiguelez   
2017-10-10 10:20   
Test with no costs calculated:

As group admin role:
   Validate a new Costing Rule for F&B España, S.A. selecting Warehouse Dimension
   Create a new product for F&B España, S.A.
   Create a new Physical Inventory for F&B España, S.A.
   Add 1 unit of the previously created product in RN-0-0-0 storage bin with a cost of 5 and 1 unit in RS-0-0-0 with a cost of 8
   Process it
   Launch the Valued Stock Report and check the actual average cost and the actual validation columns are null
(0099846)
dmiguelez   
2017-10-10 10:21   
Test with aggregated data.

Repeat test plans 1 and 2 but, after scheduling the Costing Background, schedule the Genearte Aggregated Data Process too.
The test plan should give the same results
(0099848)
hgbot   
2017-10-10 13:12   
Repository: erp/devel/pi
Changeset: 387066f2baf1e2a3cbd992a79a8ba5ca12483425
Author: Mark <markmm82 <at> gmail.com>
Date: Thu Sep 28 13:08:49 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/387066f2baf1e2a3cbd992a79a8ba5ca12483425 [^]

Fixes issue 36878: [Valued Stock Report]: Wrong Actual Cost and Valuation
if the costing rule is validated with warehouse dimension.

Incorrect computation was made because costs related to transactions were not
grouped by warehouse and more than one cost could be showed with the cost of the
current line related to it. To fix this issue were took into account that if the
costing rule has the warehouse dimension activated, costs will be related to them
and calculated taking into account the transaction's warehouse. If the costing rule
hasn't the Warehouse dimension activated, then cost doesn't has the warehouse column
filled. Both cases are taken into account to a correct computation of costs.

Also was fixed when Consolidated warehouse option is choosed.

---
M src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql
---
(0099849)
hgbot   
2017-10-10 13:12   
Repository: erp/devel/pi
Changeset: fea0b4bc0f16ead4b0c4ae3a83b2843620b1d6d8
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Mon Oct 09 18:28:14 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/fea0b4bc0f16ead4b0c4ae3a83b2843620b1d6d8 [^]

Related to Issue 36878. Code Review fixes:

* Removed query to retrieve last M_Costing in Consolidated with cost query
  for the group of Transactions without Cost calculated. This must be null
* Take into account Warehouse Dimension in both queries that look for costs
   - In not consolidated, if the Warehouse Dimension is checked, the Warehouse
     of the Costing record must be the same one as the Transaction
   - In the consolidated, the Organization of the Warehouse of the Costing record
     must belong to the Organization of the filter of the Report. In this case,
     the average of the Costing records must be returned as the last costing record

---
M src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java
M src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql
---
(0099850)
hgbot   
2017-10-10 13:12   
Repository: erp/devel/pi
Changeset: 6f27674da85d3c939307f32ffb45efda8bc749f5
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Tue Oct 10 10:04:55 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/6f27674da85d3c939307f32ffb45efda8bc749f5 [^]

Related to Issue 36878. Code Review Fixes

* In ReportValuedStock.java, when looking for the last costing rule
  filter by validated costing rules
* In queries, check that the warehouses are equal only when the warehouse
  dimension is Y
* Use left join with the M_Costing subqueri instead of a join

---
M src/org/openbravo/erpCommon/ad_reports/ReportValuationStock.java
M src/org/openbravo/erpCommon/ad_reports/ReportValuationStock_data.xsql
---
(0099851)
dmiguelez   
2017-10-10 13:13   
Code Review + Testing Ok
(0101322)
hudsonbot   
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
(0101323)
hudsonbot   
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
(0101324)
hudsonbot   
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