Merge pull request 'fix: refs #6861 itemShelvingSale transaction' (!2983) from 6861-itemShelvingSalesTransaction into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2983
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
Sergio De la torre 2024-09-17 11:17:40 +00:00
commit ee234577a3
1 changed files with 12 additions and 7 deletions

View File

@ -48,6 +48,13 @@ proc: BEGIN
RESIGNAL;
END;
START TRANSACTION;
SELECT id INTO vSaleFk
FROM sale
WHERE id = vSaleFk
FOR UPDATE;
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
INTO vLastPickingOrder, vOutStanding, vSaleQuantity
FROM sale s
@ -58,6 +65,7 @@ proc: BEGIN
WHERE s.id = vSaleFk;
IF vOutStanding <= 0 THEN
COMMIT;
LEAVE proc;
END IF;
@ -85,8 +93,6 @@ proc: BEGIN
LEAVE l;
END IF;
START TRANSACTION;
SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
@ -115,9 +121,8 @@ proc: BEGIN
WHERE id = vItemShelvingFk;
END IF;
COMMIT;
END LOOP;
CLOSE vItemShelvingAvailable;
COMMIT;
END$$
DELIMITER ;