fix: refs #7916 itemShelving_transfer
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-09-03 07:45:25 +02:00
parent 89f8e987dc
commit b436ac0518
1 changed files with 20 additions and 16 deletions

View File

@ -5,28 +5,26 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transf
)
BEGIN
/**
* Transfiere producto de una ubicación a otra, fusionando si coincide el
* packing y la fecha.
* 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;
DECLARE vNewItemShelvingFk INT;
SELECT MAX(ish.id)
INTO vNewItemShelvingFk
SELECT MAX(ish.id) INTO vNewItemShelvingFk
FROM itemShelving ish
JOIN (
SELECT
itemFk,
packing,
created,
buyFk
SELECT itemFk,
packing,
created,
buyFk
FROM itemShelving
WHERE id = vItemShelvingFk
) ish2 ON ish2.itemFk = ish.itemFk
AND ish2.packing = ish.packing
AND date(ish2.created) = date(ish.created)
AND DATE(ish2.created) = DATE(ish.created)
AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
@ -39,10 +37,16 @@ BEGIN
DELETE FROM itemShelving
WHERE id = vItemShelvingFk;
ELSE
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;
IF (SELECT EXISTS(SELECT id FROM shelving
WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;
ELSE
CALL util.throw('The shelving not exists');
END IF;
END IF;
SELECT true;
SELECT TRUE;
END$$
DELIMITER ;
DELIMITER ;