#7897 - masterTest_24_36 #2909

Merged
jsegarra merged 132 commits from 7897_masterTest_24_36 into master 2024-09-03 06:37:54 +00:00
1 changed files with 20 additions and 16 deletions
Showing only changes of commit 7d5cb45b3a - Show all commits

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 ;