Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0055837Openbravo ERP09. Financial managementpublic2024-06-25 13:292024-07-19 14:40
sdossantos 
aferraz 
highmajorunable to reproduce
closedfixed 
5
PR22Q2 
PR24Q4 
Core
No
0055837: Incorrect accumulated values ​​in CostAdjustmentUtils.getStockOnTransactionDat
In this case the problem is in AverageAlgorithm.getLastCumulatedCosting(). Following the same case of 2 lines of a receipt generating a new average cost each. Each average cost will have different cumulative values. The problem is that when getLastCumulatedCosting is called, only the transaction process date is passed (or movement date if it is backdated, which I think is not entirely correct either but it does not impact this client)

 final Costing costing = AverageAlgorithm.getLastCumulatedCosting(date, trx.getProduct(), costDimensions, costorg);

This implies that the method will return the last average cost calculated for that timestamp, that is, that of the second transaction with the accumulated of the 2 transactions. If you are adjusting the first transaction, it will only take into account the amount adjusted in the first transaction, so it calculates a bad average cost.
1. Generate a purchase order and goods receipt with two lines of the same product and quantity. Price = 10, Qty = 1.
2. Calculate the cost so an average cost for each line is generated -> each transaction is calculated with cost = 10 and two average costs are calculated with cost = 10.
3. Generate the purchase invoice with different prices. Price = 50.
4. Execute the Price difference adjustment process. -> both transactions are updated with original cost = 10 and cost = 50 (this is correct), but average costs are updated with cost = 30 (first record) and cost = 36.67 (second record).
This is wrong, both average costs should be updated with cost = 50.
To fix it there are 2 options:
- add the transaction in the call to getLastCumulatedCosting and take it into account when searching for the latest or simplest,
- subtract 1 second from the timestamp that is passed so that it looks for a previous average cost
No tags attached.
related to defect 0055836 closed aferraz Processing order of cost adjustment lines 
Issue History
2024-06-25 13:29sdossantosNew Issue
2024-06-25 13:29sdossantosAssigned To => Triage Omni OMS
2024-06-25 13:29sdossantosModules => Core
2024-06-25 13:29sdossantosTriggers an Emergency Pack => No
2024-06-25 13:53frank_gonzalezNote Added: 0166308
2024-06-25 13:56PracticsIssue Monitored: Practics
2024-07-04 13:50hgbotNote Added: 0166683
2024-07-05 08:49aferrazAssigned ToTriage Omni OMS => igor_trebol
2024-07-05 08:49aferrazRelationship addedrelated to 0055836
2024-07-10 10:52aferrazDescription Updatedbug_revision_view_page.php?rev_id=28206#r28206
2024-07-10 10:52aferrazSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=28208#r28208
2024-07-12 10:04aferrazAssigned Toigor_trebol => aferraz
2024-07-18 15:03aferrazSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=28255#r28255
2024-07-19 14:40hgbotResolutionopen => fixed
2024-07-19 14:40hgbotStatusnew => closed
2024-07-19 14:40hgbotFixed in Version => PR24Q4
2024-07-19 14:40hgbotNote Added: 0167191
2024-07-19 14:40hgbotNote Added: 0167192

Notes
(0166308)
frank_gonzalez   
2024-06-25 13:53   
Jira: https://openbravo.atlassian.net/browse/RM-14959 [^]
(0166683)
hgbot   
2024-07-04 13:50   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/1292 [^]
(0167191)
hgbot   
2024-07-19 14:40   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 9e64cefb7b5ee64cfa3adc3a6373d18da55b11af
Author: Igor Trebol <i.trebol@orisha.com>
Date: 19-07-2024 12:40:22
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/9e64cefb7b5ee64cfa3adc3a6373d18da55b11af [^]

Fixes ISSUE-55837: Incorrect accumulated values ​​in CostAdjustmentUtils.getStockOnTransactionDate

---
A src-test/src/org/openbravo/test/costing/TestIssue55837.java
M src-test/src/org/openbravo/test/costing/TestCosting.java
M src-test/src/org/openbravo/test/costing/TestCostingBase.java
M src-test/src/org/openbravo/test/costing/TestCostingLandedCost.java
M src-test/src/org/openbravo/test/costing/TestCostingNoSourceAdjustments.java
M src-test/src/org/openbravo/test/costing/TestCostingSourceAdjustments.java
M src-test/src/org/openbravo/test/costing/utils/TestCostingUtils.java
M src/org/openbravo/costing/CostAdjustmentUtils.java
---
(0167192)
hgbot   
2024-07-19 14:40   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/1292 [^]