Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0058052Openbravo ERP04. Warehouse managementpublic2025-02-21 14:482025-03-25 10:15
malsasua 
Sandrahuguet 
highmajoralways
closedfixed 
5
 
PR25Q2 
approved
AtulOpenbravo
OBPS
Core
121225
No
0058052: Wrong cost amount with backdated transactions
With"backdated transactions" feature enabled, the query that calculates the accumulated stock does not take this feature into account and does not sort by "transaction date" first. This results in incorrect accumulated stock on days when backdated transactions are processed.
. backdated transactions enabled
. trx1 - trxProcessDate 20/05/2024 07:00:00 - movementdate 19/05/2024 - qty +3
. trx3 - trxProcessDate 20/05/2024 07:30:00 - movementdate 19/05/2024 - qty +4
. trx2 - trxProcessDate 20/05/2024 07:15:00 - movementdate 20/05/2024 - qty -3

the trx2 is processed after trx1 - reducing the stock
the trx3 is processed after trx2, but with date 19/05/2025 , butg in this moment, the acumulated stock should not take the trx2

More detail in
https://docs.google.com/document/d/1j17OLSgMQs3lzpXTvlwoCSrC_zD2joCa8wOmfAkxjZc/edit?usp=sharing [^]
No tags attached.
related to defect 0058297 new Triage Omni WMS Modules MovementDate should be truncate 
Issue History
2025-02-21 14:48malsasuaNew Issue
2025-02-21 14:48malsasuaAssigned To => Triage Omni WMS
2025-02-21 14:48malsasuaOBNetwork customer => OBPS
2025-02-21 14:48malsasuaModules => Core
2025-02-21 14:48malsasuaSupport ticket => 121225
2025-02-21 14:48malsasuaTriggers an Emergency Pack => No
2025-02-21 16:44PracticsIssue Monitored: Practics
2025-02-27 10:23mtaalReview Assigned To => mtaal
2025-02-27 10:23mtaalNote Added: 0176203
2025-02-27 10:23mtaalStatusnew => closed
2025-03-13 12:22egoitzNote Added: 0176787
2025-03-13 12:22egoitzStatusclosed => new
2025-03-19 19:20aferrazAssigned ToTriage Omni WMS => Sandrahuguet
2025-03-20 14:04SandrahuguetRelationship addedrelated to 0058297
2025-03-20 14:11hgbotMerge Request Status => open
2025-03-20 14:11hgbotNote Added: 0177029
2025-03-20 14:44SandrahuguetNote Added: 0177030
2025-03-21 12:30SandrahuguetNote Edited: 0177030bug_revision_view_page.php?bugnote_id=0177030#r29393
2025-03-21 12:31SandrahuguetNote Edited: 0177030bug_revision_view_page.php?bugnote_id=0177030#r29394
2025-03-24 12:41AtulOpenbravoStatusnew => scheduled
2025-03-24 12:41AtulOpenbravoReview Assigned Tomtaal => AtulOpenbravo
2025-03-25 09:45AtulOpenbravoNote Edited: 0177030bug_revision_view_page.php?bugnote_id=0177030#r29397
2025-03-25 09:45AtulOpenbravoNote Edited: 0177030bug_revision_view_page.php?bugnote_id=0177030#r29398
2025-03-25 09:46hgbotMerge Request Statusopen => approved
2025-03-25 10:15hgbotResolutionopen => fixed
2025-03-25 10:15hgbotStatusscheduled => closed
2025-03-25 10:15hgbotFixed in Version => PR25Q2
2025-03-25 10:15hgbotNote Added: 0177204
2025-03-25 10:15hgbotNote Added: 0177205

Notes
(0176203)
mtaal   
2025-02-27 10:23   
We discussed internally and backdated transactions are not supported with the accumulated stock. This was stated from the start of the development.

To support backdating the accumulated stock has to be removed and recomputed from the backdated date.
(0176787)
egoitz   
2025-03-13 12:22   
Ticket reopened after internall discussion
(0177029)
hgbot   
2025-03-20 14:11   
Merge Request created: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/openbravo/-/merge_requests/1601 [^]
(0177030)
Sandrahuguet   
2025-03-20 14:44   
(edited on: 2025-03-25 09:45)
Test Plan:
In F&B Client
-Go to Costing Rule and activate backdated transactions (Fix backdated transactions button) Use Today's date as the input value in the popup.
-Go to product tab and create a new product add a price in be soft drinker price list and in general sales price list. Set price as 10.
- Add a costing record with date as today cost = 10.
-Create a physical inventory for this product qty 100 and date today
-Create a goods shipment for 10 units date as today and product created in previous step
-Create a goods receipt date as today and product with 50 units created in previous step
-Create a goods receipt date as tomorrow and product with 75 units created in previous step
-Create a goods shipment date as tomorrow and product with 15 units created in previous step (in the database update the movementdate in m_transaction with any hour,min,sec) for example: 2025-03-25 16:43:22
-Create a goods receipt date as tomorrow and product with 25 units created in previous step
-Create a goods receipt date as day after tomorrow and product with 35 units created in previous step
-Launch the costing background


Use the product id in the below query

select t.movementtype, t.movementqty, t.trxprocessdate, t.movementdate, tcost.cost
  , sum(t.movementqty) over (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) as realstock
  , sum(t.movementqty) over (order by trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) as realstock2
  , sum(tcost.cost) OVER (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) as realcumcost
  , ROUND(CASE WHEN sum(t.movementqty) OVER (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) = 0 THEN 0 ELSE sum(tcost.cost) OVER (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc)/sum(t.movementqty) OVER (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) END, 6) AS realavg
  , ' ' as blank
  , c.datefrom, c.dateto, c.ismanual, c.qty, c.price, c.cost, c.cumstock, c.cumcost, c.originalcost
  , sum(t.movementqty) OVER (order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc) - c.cumstock as stockdiff
  , t.m_transaction_id
from m_transaction t
  left join m_costing c on t.m_transaction_id = c.m_transaction_id
  left join (select sum(tc.cost)*sign(tct.movementqty) as cost, tc.m_transaction_id
             from m_transaction_cost tc
               join m_transaction tct on tc.m_transaction_id = tct.m_transaction_id
             where tct.m_product_id = '689293E13F6B4DBDB835AB3506CC6876'
       -- and tct.m_locator_id in ('BCDE2DA62BD048869B1899590E8E0484', '8D1543D981594A56891E4BC21472A88F')
             group by tc.m_transaction_id, tct.movementqty) as tcost on tcost.m_transaction_id = t.m_transaction_id
  join ad_ref_list rl on t.movementtype = rl.value and rl.ad_reference_id = '189'
where t.m_product_id = '689293E13F6B4DBDB835AB3506CC6876'
-- and t.m_locator_id in ('BCDE2DA62BD048869B1899590E8E0484', '8D1543D981594A56891E4BC21472A88F')
group by t.m_transaction_id, tcost.cost, c.m_costing_id, rl.seqno
order by trunc(t.movementdate), trxprocessdate asc, rl.seqno, movementqty desc, t.m_transaction_id asc;

- Check that cumulative stock is correct i.e 260 and cumulative cost is 2600.

(0177204)
hgbot   
2025-03-25 10:15   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/openbravo [^]
Changeset: af439d33188bc50e360af3cac7638b917808f1e3
Author: Sandra Huguet <s.huguet@orisha.com>
Date: 25-03-2025 13:47:19
URL: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/openbravo/-/commit/af439d33188bc50e360af3cac7638b917808f1e3 [^]

Fixed ISSUE-58052 truncate movementDate in order to calculate correct the accumulated cost

---
M src/org/openbravo/costing/AverageCostAdjustment.java
M src/org/openbravo/costing/CostingUtils.java
---
(0177205)
hgbot   
2025-03-25 10:15   
Merge request merged: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/openbravo/-/merge_requests/1601 [^]