2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`itemShelvingRadar_Entry_State_beta`(vEntryFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vWarehouseFk INT DEFAULT 1;
|
|
|
|
DECLARE vCalcVisibleFk INT;
|
|
|
|
DECLARE vCalcAvailableFk INT;
|
|
|
|
DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(util.VN_CURDATE());
|
|
|
|
|
|
|
|
CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1);
|
|
|
|
CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE());
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
|
|
|
CREATE TEMPORARY TABLE tmp.item
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT DISTINCT itemFk
|
|
|
|
FROM vn.buy
|
|
|
|
WHERE entryFk = vEntryFk;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.item2;
|
|
|
|
CREATE TEMPORARY TABLE tmp.item2
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT *
|
|
|
|
FROM tmp.item;
|
|
|
|
|
|
|
|
SELECT i.id as itemFk,
|
|
|
|
CAST(IFNULL(iss.visible,0) - IFNULL(v.visible,0) AS DECIMAL(10,0)) as outShelving
|
|
|
|
FROM vn.item i
|
|
|
|
JOIN tmp.item ti ON ti.itemFk = i.id
|
|
|
|
LEFT JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = i.id
|
|
|
|
LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id;
|
|
|
|
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.item;
|
|
|
|
DROP TEMPORARY TABLE tmp.item2;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|