diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 700821592..6c556f1ff 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -70,7 +70,7 @@ BEGIN FROM itemShelvingSale WHERE saleFk = vSaleFk; - IF vRemainingQuantity = 0 THEN + IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN CALL saleTracking_new( vSaleFk, TRUE, @@ -89,7 +89,9 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - CALL itemShelvingSale_reallocate(vItemShelvingFk, vQuantity); + INSERT INTO itemShelvingSaleReserv (saleFk) + SELECT vSaleFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); END IF; END$$ DELIMITER ; \ No newline at end of file