fix: refs #6861 setQuantity
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Sergio De la torre 2024-10-17 12:44:05 +02:00
parent 76415e507d
commit 989b68c33a
1 changed files with 12 additions and 3 deletions

View File

@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQ
vItemShelvingSaleFk INT(10), vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0), vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN, vIsItemShelvingSaleEmpty BOOLEAN,
vSectorFk INT vSectorFk INT,
vShelvingFk VARCHAR(10)
) )
BEGIN BEGIN
/** /**
@ -24,6 +25,7 @@ BEGIN
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vTotalQuantity INT; DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45); DECLARE vStateCode VARCHAR(45);
DECLARE vCurrentShelvingFk VARCHAR(10);
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
@ -45,18 +47,25 @@ BEGIN
iss.saleFk, iss.saleFk,
iss.itemShelvingFk, iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)), SUM(IFNULL(iss.quantity,0)),
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
ish.shelvingFk
INTO vItemFk, INTO vItemFk,
vSaleFk, vSaleFk,
vItemShelvingFk, vItemShelvingFk,
vReservedQuantity, vReservedQuantity,
vStateCode vStateCode,
vCurrentShelvingFk
FROM itemShelvingSale iss FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk JOIN sale s ON s.id = iss.saleFk
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked; AND NOT iss.isPicked;
IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN
CALL util.throw('The shelving can not be different from the shelving reserved');
END IF;
IF vQuantity > vReservedQuantity IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN