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