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`.`itemShelving_transfer`(
|
2024-05-27 05:46:21 +00:00
|
|
|
vItemShelvingFk INT,
|
2024-06-11 10:44:25 +00:00
|
|
|
vShelvingFk VARCHAR(10)
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Transfiere producto de una ubicación a otra, fusionando si coincide el
|
|
|
|
* packing y la fecha.
|
|
|
|
*
|
|
|
|
* @param vItemShelvingFk Identificador de itemShelving
|
|
|
|
* @param vShelvingFk Identificador de shelving
|
|
|
|
*/
|
|
|
|
DECLARE vNewItemShelvingFk INT DEFAULT 0;
|
|
|
|
|
|
|
|
SELECT MAX(ish.id)
|
|
|
|
INTO vNewItemShelvingFk
|
|
|
|
FROM itemShelving ish
|
|
|
|
JOIN (
|
|
|
|
SELECT
|
|
|
|
itemFk,
|
|
|
|
packing,
|
2024-05-20 07:39:23 +00:00
|
|
|
created,
|
|
|
|
buyFk
|
2024-01-15 11:31:03 +00:00
|
|
|
FROM itemShelving
|
|
|
|
WHERE id = vItemShelvingFk
|
2024-05-27 05:46:21 +00:00
|
|
|
) ish2 ON ish2.itemFk = ish.itemFk
|
2024-01-15 11:31:03 +00:00
|
|
|
AND ish2.packing = ish.packing
|
|
|
|
AND date(ish2.created) = date(ish.created)
|
2024-02-06 12:31:58 +00:00
|
|
|
AND ish2.buyFk = ish.buyFk
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
|
|
|
|
|
|
|
|
IF vNewItemShelvingFk THEN
|
|
|
|
UPDATE itemShelving ish
|
2024-05-27 05:46:21 +00:00
|
|
|
JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk
|
2024-01-15 11:31:03 +00:00
|
|
|
SET ish.visible = ish.visible + ish2.visible
|
|
|
|
WHERE ish.id = vNewItemShelvingFk;
|
|
|
|
|
|
|
|
DELETE FROM itemShelving
|
|
|
|
WHERE id = vItemShelvingFk;
|
|
|
|
ELSE
|
|
|
|
UPDATE itemShelving
|
|
|
|
SET shelvingFk = vShelvingFk
|
|
|
|
WHERE id = vItemShelvingFk;
|
|
|
|
END IF;
|
|
|
|
SELECT true;
|
|
|
|
END$$
|
2024-01-31 06:11:03 +00:00
|
|
|
DELIMITER ;
|