refactor: refs #7640 multipleInventoryFix #2689

Merged
guillermo merged 4 commits from 7640-multipleInventoryFix into master 2024-07-08 05:52:52 +00:00
1 changed files with 43 additions and 42 deletions
Showing only changes of commit 8ac26c7281 - Show all commits

View File

@ -76,8 +76,9 @@ proc: BEGIN
GROUP BY itemFk;
-- Cálculo del visible
UPDATE tItemInventoryCalc iic
JOIN (
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk, SUM(quantity) visible
FROM (
SELECT s.itemFk, s.quantity
@ -114,14 +115,13 @@ proc: BEGIN
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
) sub2
GROUP BY itemFk
) sub ON sub.itemFk = iic.itemFk
SET iic.visible = iic.visible + sub.visible;
GROUP BY itemFk;
UPDATE tmp.itemInventory ai
JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id
JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id
SET ai.inventory = iic.quantity,
ai.visible = iic.visible,
ai.visible = iic.quantity + ivc.visible,
ai.avalaible = iic.quantity,
ai.sd = iic.quantity;
@ -195,6 +195,7 @@ proc: BEGIN
tmp.itemTravel,
tmp.itemCalc,
tItemInventoryCalc,
tItemVisibleCalc,
tmp.itemAtp;
END$$
DELIMITER ;