Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-09-03 07:52:05 +02:00
commit 8e34e78964
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 BEGIN
/** /**
* Transfiere producto de una ubicación a otra, fusionando si coincide el * Transfiere producto de una ubicación a otra
* packing y la fecha. * fusionando si coincide el packing y la fecha.
* *
* @param vItemShelvingFk Identificador de itemShelving * @param vItemShelvingFk Identificador de itemShelving
* @param vShelvingFk Identificador de shelving * @param vShelvingFk Identificador de shelving
*/ */
DECLARE vNewItemShelvingFk INT DEFAULT 0; DECLARE vNewItemShelvingFk INT;
SELECT MAX(ish.id) SELECT MAX(ish.id) INTO vNewItemShelvingFk
INTO vNewItemShelvingFk
FROM itemShelving ish FROM itemShelving ish
JOIN ( JOIN (
SELECT SELECT itemFk,
itemFk, packing,
packing, created,
created, buyFk
buyFk
FROM itemShelving FROM itemShelving
WHERE id = vItemShelvingFk WHERE id = vItemShelvingFk
) ish2 ON ish2.itemFk = ish.itemFk ) ish2 ON ish2.itemFk = ish.itemFk
AND ish2.packing = ish.packing AND ish2.packing = ish.packing
AND date(ish2.created) = date(ish.created) AND DATE(ish2.created) = DATE(ish.created)
AND ish2.buyFk = ish.buyFk AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
@ -39,10 +37,16 @@ BEGIN
DELETE FROM itemShelving DELETE FROM itemShelving
WHERE id = vItemShelvingFk; WHERE id = vItemShelvingFk;
ELSE ELSE
UPDATE itemShelving IF (SELECT EXISTS(SELECT id FROM shelving
SET shelvingFk = vShelvingFk WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
WHERE id = vItemShelvingFk;
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;
ELSE
CALL util.throw('The shelving not exists');
END IF;
END IF; END IF;
SELECT true; SELECT TRUE;
END$$ END$$
DELIMITER ; DELIMITER ;