2024-06-11 10:44:25 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
2024-06-11 10:44:25 +00:00
|
|
|
vItemShelvingFk INT(10),
|
|
|
|
vItemFk INT(10)
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-06-11 16:43:26 +00:00
|
|
|
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
2024-06-11 10:44:25 +00:00
|
|
|
*
|
|
|
|
* @param vItemShelvingFk Id itemShelving
|
|
|
|
*/
|
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
|
|
|
ROLLBACK;
|
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
|
2024-06-11 16:43:26 +00:00
|
|
|
SELECT id INTO vItemShelvingFk
|
2024-06-11 10:44:25 +00:00
|
|
|
FROM itemShelving
|
|
|
|
WHERE id = vItemShelvingFk
|
|
|
|
FOR UPDATE;
|
|
|
|
|
|
|
|
UPDATE itemShelving
|
|
|
|
SET visible = 0,
|
|
|
|
available = 0
|
|
|
|
WHERE id = vItemShelvingFk
|
|
|
|
AND itemFk = vItemFk;
|
|
|
|
|
2024-06-24 11:30:03 +00:00
|
|
|
INSERT INTO itemShelvingSaleReserve (saleFk)
|
2024-06-11 10:44:25 +00:00
|
|
|
SELECT DISTINCT iss.saleFk
|
|
|
|
FROM itemShelvingSale iss
|
|
|
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
|
|
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
|
|
|
AND ish.itemFk = vItemFk
|
|
|
|
AND NOT iss.isPicked;
|
|
|
|
|
|
|
|
DELETE iss
|
|
|
|
FROM itemShelvingSale iss
|
|
|
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
|
|
|
WHERE iss.itemShelvingFk = vItemShelvingFk
|
|
|
|
AND ish.itemFk = vItemFk
|
|
|
|
AND NOT iss.isPicked;
|
|
|
|
COMMIT;
|
|
|
|
|
|
|
|
CALL itemShelvingSale_doReserve();
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|