Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7663-setWeight
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-09-03 09:08:56 +02:00
commit a0ac2be203
1 changed files with 20 additions and 16 deletions

View File

@ -5,20 +5,18 @@ 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
@ -26,7 +24,7 @@ BEGIN
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
IF (SELECT EXISTS(SELECT id FROM shelving
WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
UPDATE itemShelving UPDATE itemShelving
SET shelvingFk = vShelvingFk SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk; WHERE id = vItemShelvingFk;
ELSE
CALL util.throw('The shelving not exists');
END IF; END IF;
SELECT true; END IF;
SELECT TRUE;
END$$ END$$
DELIMITER ; DELIMITER ;