Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036692Openbravo ERP04. Warehouse managementpublic2017-08-21 11:332017-08-30 10:12
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q33.0PR17Q3 
aferraz
Core
Packaging and release
2017-05-25
main
https://code.openbravo.com/erp/devel/pi/rev/0bfbdaa123e3 [^]
No
0036692: [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.
blocks defect 0036675 closed markmm82 [Costing Migration Process]: Transactions related with closing inventory lines do not have an entry in Transaction Cost tab 
Issue History
2017-08-22 13:20aferrazTypedefect => backport
2017-08-22 13:20aferrazTarget Version => 3.0PR17Q3
2017-08-30 10:10hgbotCheckin
2017-08-30 10:10hgbotNote Added: 0098718
2017-08-30 10:10hgbotStatusscheduled => resolved
2017-08-30 10:10hgbotResolutionopen => fixed
2017-08-30 10:10hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/87bb93f75b522109909d9e12331638ee84be20f6 [^]
2017-08-30 10:12aferrazReview Assigned To => aferraz
2017-08-30 10:12aferrazNote Added: 0098719
2017-08-30 10:12aferrazStatusresolved => closed
2017-08-30 10:12aferrazFixed in Version => 3.0PR17Q3

Notes
(0098718)
hgbot   
2017-08-30 10:10   
Repository: erp/backports/3.0PR17Q3
Changeset: 87bb93f75b522109909d9e12331638ee84be20f6
Author: Mark <markmm82 <at> gmail.com>
Date: Wed Aug 23 14:16:09 2017 -0400
URL: http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/87bb93f75b522109909d9e12331638ee84be20f6 [^]

Fixes issue 36692: 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
---
(0098719)
aferraz   
2017-08-30 10:12   
Code review + Testing OK