Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036889Openbravo ERP04. Warehouse managementpublic2017-09-19 13:112018-01-03 12:38
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR18Q1 
aferraz
Core
No
0036889: [Valued Stock Report]: Wrong stock shown if Generate Aggregated Data Background process is launched with two costing rules
[Valued Stock Report]: Wrong stock shown if Generate Aggregated Data Background process is launched with two costing rules for same organization

Having the following costing rules for the same org:
   1. Starting Date: 31-12-2013 23:00:00
      Ending Date: 01-07-2014 04:28:21
   1. Starting Date: 01-07-2014 04:28:21
      Ending Date: null

The ResetValuedStockAggregated.getCostingRules is returning both of them for Jan-14 period (2014-01-01 - 2014-01-31)
As group admin role:
   Create a new Costing Rule for F&B España S.A. and validate it
   Create some warehouse transactions on it
   Close all the periods
   Go to Process Request window and run Generate Aggregated Data Background process
   Launch the Valued Stock Report and check the stock shown there is wrong
No tags attached.
Issue History
2017-09-19 13:11ngarciaNew Issue
2017-09-19 13:11ngarciaAssigned To => Triage Finance
2017-09-19 13:11ngarciaModules => Core
2017-09-19 13:11ngarciaResolution time => 1507586400
2017-09-19 13:11ngarciaTriggers an Emergency Pack => No
2017-09-19 13:11ngarciaIssue Monitored: networkb
2017-09-26 17:24aferrazAssigned ToTriage Finance => markmm82
2017-09-28 19:33markmm82Statusnew => scheduled
2017-10-02 20:51markmm82Note Added: 0099705
2017-10-03 09:21hgbotCheckin
2017-10-03 09:21hgbotNote Added: 0099712
2017-10-03 09:21hgbotStatusscheduled => resolved
2017-10-03 09:21hgbotResolutionopen => fixed
2017-10-03 09:21hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/a6c2534085d419446ff4caf0db8a0cf3db2945c9 [^]
2017-10-03 09:22aferrazReview Assigned To => aferraz
2017-10-03 09:22aferrazNote Added: 0099713
2017-10-03 09:22aferrazStatusresolved => closed
2017-10-03 09:22aferrazFixed in Version => 3.0PR18Q1
2018-01-03 12:38hudsonbotCheckin
2018-01-03 12:38hudsonbotNote Added: 0101307

Notes
(0099705)
markmm82   
2017-10-02 20:51   
Test Plan:
0. Go to Costing Rules windows.
   Notice there is an existing costing rule for F&B España, S.A organization, with starting date = 13-07-2012 14:06:26 and ending date = NULL.
1. Create a new Costing Rule:
   Organization = F&B España, S.A,
   Costing Algorithm = Average Algorithm
2. Validate previously created costing rule.
   Notice after save the new costing rule
   Starting Date = Today
   Ending date = NULL.

   Notice that previously costing rule updated this ending date to starting date of the new costing rule.

3. Create a new Goods receipt:
   Organization = F&B España, S.A,
   Business Partner = Bebidas Alegres, S.L.
   Warehouse = Región Norte
   Movemente Date = 02-10-2017
4. Add a line to it:
   Open product selector and choose product Vino Blanco 0,75L
   Storage bin = RN-0-0-0
   Movement Quantity = 10
5. Process Receipt.
6. Close all the periods.
7. Go to Process Request window and run Generate Aggregated Data Background process for Spain organization.
   If you debug the code for ResetValuedStockAggregated.java, in insertValuesIntoValuedStockAggregated() method:
   
   List<CostingRule> costingRulesList = getCostingRules(legalEntity, period.getStartingDate(),
          period.getEndingDate());
   Notice for Jul-12 period only is returned the costing rule existing before create the new costing rule (explained in step 0)
   Same for the rest of periods, only one and just the correct costing rule is returned for each one.
8. Launch the Valued Stock Report. Filter by:
   Organization = F&B España, S.A,
   Date = 02-10-2017 (Same of transaction)
   Product Category = Alcoholic
9. Check the stock shown there is right for Vino Blanco 0,75L.
   For instance if the stock of product was 42800, it will be updated to 42810 for the receipt of 10 units in step 4. Probably is needed to run the Costing Background process to see it.
(0099712)
hgbot   
2017-10-03 09:21   
Repository: erp/devel/pi
Changeset: a6c2534085d419446ff4caf0db8a0cf3db2945c9
Author: Mark <markmm82 <at> gmail.com>
Date: Sun Oct 01 19:56:56 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/a6c2534085d419446ff4caf0db8a0cf3db2945c9 [^]

Fixes issue 36889: Wrong stock shown if Generate Aggregated Data Background
process is launched with two costing rules for same organization

Wrong stock shown if Generate Aggregated Data Background process is launched with
two costing rules for same organization.

Problem was that conditions in getCostingRules() method had conditions that retrieved
more than one costing rule for the same period because an incorrect condition when
validated if starting and ending dates are null.

To fix the problem was restructured the query to combine the three conditions in just two
conditions that includes the third one (period is completely included inside the costing
rule range) and avoid return more than one costing rule for period is processed.

Also, was replaced cr.organization.id in (:org) for cr.organization.id = :org) as :org
parameter will be only one organization and not a list of organizations.

---
M src/org/openbravo/materialmgmt/ResetValuedStockAggregated.java
---
(0099713)
aferraz   
2017-10-03 09:22   
Code review + Testing OK
(0101307)
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