7806_devToTest_2332 #2801

Merged
alexm merged 126 commits from 7806_devToTest_2330 into test 2024-07-30 06:14:09 +00:00
1 changed files with 24 additions and 20 deletions
Showing only changes of commit 0c51a97a17 - Show all commits

View File

@ -139,8 +139,9 @@ proc: BEGIN
CALL item_getAtp(vDate);
CALL travel_upcomingArrivals(vWarehouseFk, vDate);
UPDATE tmp.itemInventory ai
JOIN (
CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT it.itemFk,
SUM(it.quantity) quantity,
im.quantity minQuantity
@ -152,18 +153,21 @@ proc: BEGIN
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
t.landing,
vDateToTomorrow)
GROUP BY it.itemFk
) sub ON sub.itemFk = ai.id
SET ai.avalaible = IF(sub.minQuantity > 0,
ai.avalaible,
ai.avalaible + sub.minQuantity),
ai.sd = ai.inventory + sub.quantity;
GROUP BY it.itemFk;
UPDATE tmp.itemInventory it
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
SET it.avalaible = IF(iac.minQuantity > 0,
it.avalaible,
it.avalaible + iac.minQuantity),
it.sd = it.inventory + iac.quantity;
DROP TEMPORARY TABLE
tmp.itemTravel,
tmp.itemCalc,
tmp.itemAtp,
tItemInventoryCalc,
tItemVisibleCalc;
tItemVisibleCalc,
tItemAvailableCalc;
END$$
DELIMITER ;