feat: refs #7646 delete scannableCodeType #2782
|
@ -139,31 +139,35 @@ 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))
|
||||||
SELECT it.itemFk,
|
ENGINE = MEMORY
|
||||||
SUM(it.quantity) quantity,
|
SELECT it.itemFk,
|
||||||
im.quantity minQuantity
|
SUM(it.quantity) quantity,
|
||||||
FROM tmp.itemCalc it
|
im.quantity minQuantity
|
||||||
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
FROM tmp.itemCalc it
|
||||||
JOIN item i ON i.id = it.itemFk
|
JOIN tmp.itemAtp im ON im.itemFk = it.itemFk
|
||||||
LEFT JOIN origin o ON o.id = i.originFk
|
JOIN item i ON i.id = it.itemFk
|
||||||
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
LEFT JOIN origin o ON o.id = i.originFk
|
||||||
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk
|
||||||
t.landing,
|
WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL,
|
||||||
vDateToTomorrow)
|
t.landing,
|
||||||
GROUP BY it.itemFk
|
vDateToTomorrow)
|
||||||
) sub ON sub.itemFk = ai.id
|
GROUP BY it.itemFk;
|
||||||
SET ai.avalaible = IF(sub.minQuantity > 0,
|
|
||||||
ai.avalaible,
|
UPDATE tmp.itemInventory it
|
||||||
ai.avalaible + sub.minQuantity),
|
JOIN tItemAvailableCalc iac ON iac.itemFk = it.id
|
||||||
ai.sd = ai.inventory + sub.quantity;
|
SET it.avalaible = IF(iac.minQuantity > 0,
|
||||||
|
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