6281 feat:buyFk in itemShelving
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Sergio De la torre 2024-05-20 09:27:20 +02:00
parent dd76168bc3
commit 20bf2b73b6
1 changed files with 16 additions and 3 deletions

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT)
BEGIN
ç
/**
* Añade registro o lo actualiza si ya existe.
@ -18,8 +18,20 @@ BEGIN
DECLARE vItemFk INT;
DECLARE vBuyFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
CALL cache.last_buy_refresh(FALSE);
SELECT buy_id INTO vBuyFk
FROM cache.last_buy
WHERE item_id = vItemFk
AND warehouse_id = vWarehouseFk;
END IF;
IF vPacking IS NULL
THEN
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
@ -29,10 +41,11 @@ BEGIN
IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
AND packing = vPacking
AND buyFk = vBuyFk) THEN
UPDATE itemShelving
SET visible = visible+vQuantity
SET visible = visible + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
ELSE