Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036675Openbravo ERP04. Warehouse managementpublic2017-08-21 11:332017-09-21 16:49
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q4 
aferraz
Core
Packaging and release
2017-05-25
main
https://code.openbravo.com/erp/devel/pi/rev/0bfbdaa123e3 [^]
No
0036675: [Costing Migration Process]: Transactions related with closing inventory lines do not have an entry in Transaction Cost tab
[Costing Migration Process]: Transactions related with closing inventory lines do not have an entry in Transaction Cost tab (M_TRANSACTION_COST)

The call to insertTrxCosts() function after cost is assigned to closing inventory lines' transactions is getting 0 in countTrx, obtained by calling

CostingUtilsData.countTrxCosts(conn)

It seems it is using different connection and the transactions are not available yet
Having a version previous to 3.0MP13 with products with stock, upgrade it to the latest version

As group admin role (for each client):
   Create current period and years (Fiscal Calendar)
   Open the current period (Open/Close Period Control)

As system admin role:
   Check two entries (Standard and Average) exist in Costing Algorithm window, create them if not
   Launch the Costing Migration Process
   If it finishes with error, remove the alert of products without cost
   Launch the process again

   Once it finishes, check the transactions related with closing inventory lines do have Transaction Cost defined in Transactions tab but not a related entry in Transaction Cost tab
   
No tags attached.
related to defect 0036659 closed markmm82 [Costing Migration Process]: Closing inventories are not leaving stock valuation to 0 
related to defect 0034130 closed aferraz Costing Migration Process takes too long with big amount of records in m_transaction table 
related to design defect 0035384 closed markmm82 Add logs on debug on the costing process and costing migration process to track the time invested on each part 
related to defect 0036534 closed collazoandy4 Error in Costing Background Process if starting date of first costing rule is lower than movement date of existing transactions 
depends on backport 00366923.0PR17Q3 closed markmm82 [Costing Migration Process]: Transactions related with closing inventory lines do not have an entry in Transaction Cost tab 
caused by defect 0035959 closed markmm82 Performance problem in Costing Migration Process with high volume of records in m_transaction table 
diff TestCosting_v1.diff (719,290) 2017-08-24 09:39
https://issues.openbravo.com/file_download.php?file_id=11006&type=bug
diff TestCosting_v2.diff (720,249) 2017-08-24 09:39
https://issues.openbravo.com/file_download.php?file_id=11007&type=bug
Issue History
2017-08-21 11:33ngarciaNew Issue
2017-08-21 11:33ngarciaAssigned To => Triage Finance
2017-08-21 11:33ngarciaModules => Core
2017-08-21 11:33ngarciaResolution time => 1505080800
2017-08-21 11:33ngarciaTriggers an Emergency Pack => No
2017-08-21 11:33ngarciaIssue Monitored: networkb
2017-08-21 11:40ngarciaRelationship addedrelated to 0036659
2017-08-21 12:02aferrazAssigned ToTriage Finance => markmm82
2017-08-21 16:32markmm82Statusnew => scheduled
2017-08-22 13:18aferrazRelationship addedcaused by 0035959
2017-08-22 13:20aferrazRegression level => Packaging and release
2017-08-22 13:20aferrazRegression date => 2017-05-25
2017-08-22 13:20aferrazRegression introduced in release => main
2017-08-22 13:20aferrazRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/0bfbdaa123e3 [^]
2017-08-22 13:20aferrazStatusscheduled => feedback
2017-08-22 13:20aferrazStatusfeedback => scheduled
2017-08-23 15:06aferrazRelationship addedrelated to 0034130
2017-08-24 09:39aferrazFile Added: TestCosting_v1.diff
2017-08-24 09:39aferrazFile Added: TestCosting_v2.diff
2017-08-24 10:52aferrazRelationship addedrelated to 0035384
2017-08-28 11:19aferrazRelationship addedrelated to 0036534
2017-08-30 10:13hgbotCheckin
2017-08-30 10:13hgbotNote Added: 0098721
2017-08-30 10:13hgbotStatusscheduled => resolved
2017-08-30 10:13hgbotResolutionopen => fixed
2017-08-30 10:13hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/5cd05d20d9cfdd4f380f7de4a2f9f4c24f554845 [^]
2017-08-30 10:13hgbotCheckin
2017-08-30 10:13hgbotNote Added: 0098722
2017-08-30 10:14aferrazReview Assigned To => aferraz
2017-08-30 10:14aferrazNote Added: 0098723
2017-08-30 10:14aferrazStatusresolved => closed
2017-08-30 10:14aferrazFixed in Version => 3.0PR17Q4
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099343
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099345

Notes
(0098721)
hgbot   
2017-08-30 10:13   
Repository: erp/devel/pi
Changeset: 5cd05d20d9cfdd4f380f7de4a2f9f4c24f554845
Author: Mark <markmm82 <at> gmail.com>
Date: Wed Aug 23 14:16:09 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/5cd05d20d9cfdd4f380f7de4a2f9f4c24f554845 [^]

Fixes issue 36675: Transaction Cost not created for closing inventory lines

After cost was assigned to closing inventory lines transactions,
when calling to insertTrxCosts() from calculateCosts() method (second call),
CostingUtilsData.countTrxCosts(conn) was getting 0 in countTrx.
It was caused because closing inventory lines cost calculation
was done by OBDal connection, and methods invoked in CostingUtilsData are done
using different connection provided by SQLC, and the transactions are not available
at this moment. See: http://wiki.openbravo.com/wiki/Data_Access_Layer#Transaction_and_Session [^]

To find the best solution for this issue and don't affect the performance (see issue 35959),
different solutions were tested to always use DAL and make process use the same connection.

1.- Doing a single insert-select query with limits is not supported in DAL. We tried it in two different ways (see attached TestCosting_v1.diff):
- Use setMaxResults(). It only works for selects but not for inserts/updates.
- Use setMaxResults() in select query and append it to insert query using getQueryString(). It appends the select without any limit.

2.- Another option could be to refactor insertTrxCosts() method to do a multiple insert query:
We can create the select query with limits using setMaxResults(), iterate it using an scroll
and create and save in each iteration a new TransactionCost. Flush won't be done in every iteration.
When flush is done, it raises every insert in multiple single-row inserts instead of only one multiple-row insert.
Single-row inserts performs worst than multiple-row insert, at least with not many rows (see attached TestCosting_v2.diff).

3.- Finally, we have refactor the process to avoid insertTrxCosts() method:
Our solution makes an insertion in M_Transaction_Cost table each
time we make the updation of related transaction cost in M_Transaction table.
We will do single-row inserts in two methods: updateTrxLegacyCosts() and calculateCosts(),
and multiple-row insert in one method: updateWithZeroCostRemainingTrx().
Thus, we split the number of TransactionCost records to be created in three different steps.

---
M src/org/openbravo/costing/CostingMigrationProcess.java
M src/org/openbravo/costing/CostingUtils_data.xsql
---
(0098722)
hgbot   
2017-08-30 10:13   
Repository: erp/devel/pi
Changeset: 1dc42ad30d5ce73021c9af6830d07bad3f5681ba
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Mon Aug 28 14:45:28 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1dc42ad30d5ce73021c9af6830d07bad3f5681ba [^]

Related to issue 36675: Fix some logs

---
M src/org/openbravo/costing/CostingMigrationProcess.java
---
(0098723)
aferraz   
2017-08-30 10:14   
Code review + Testing OK
(0099343)
hudsonbot   
2017-09-21 16:49   
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/9750b78d3e5c [^]
Maturity status: Test
(0099345)
hudsonbot   
2017-09-21 16:49   
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/9750b78d3e5c [^]
Maturity status: Test