Merge pull request 'hotFix reservas refs #6861' (!2759) from 6861_hotFix_resevas into master
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details

Reviewed-on: #2759
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
Sergio De la torre 2024-07-18 15:22:22 +00:00
commit 117da914f7
3 changed files with 20 additions and 9 deletions

View File

@ -20,17 +20,20 @@ BEGIN
START TRANSACTION;
SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
FOR UPDATE;
UPDATE itemShelving
SET visible = 0,
available = 0
WHERE id = vItemShelvingFk
AND itemFk = vItemFk;
SELECT iss.id
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND iss.itemFk = vItemFk
AND NOT iss.isPicked
FOR UPDATE;
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
SELECT DISTINCT iss.saleFk
FROM itemShelvingSale iss

View File

@ -31,6 +31,12 @@ BEGIN
RESIGNAL;
END;
IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
CALL util.throw('The quantity cannot be different from the reserved');
END IF;
IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN
CALL util.throw('Reservation completed');
END IF;
@ -52,9 +58,8 @@ BEGIN
AND NOT iss.isPicked;
IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND
(NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL))
OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN
CALL util.throw('The quantity cannot be different from the reserved');
END IF;
@ -99,7 +104,7 @@ BEGIN
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
SELECT vSaleFk;
SELECT vSaleFk, vSectorFk;
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
END IF;
END$$

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.itemShelvingSale MODIFY COLUMN IF EXISTS isPicked tinyint(1) DEFAULT 1 NOT NULL;