Merge pull request 'feat: refs #7654 entry_splitByShelving' (!2673) from 7654-entry_splitByShelvingCreateColumn into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2673 Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
commit
87e4a78092
|
@ -13,60 +13,45 @@ BEGIN
|
|||
DECLARE vBuyStickers INT;
|
||||
DECLARE vDone BOOLEAN DEFAULT FALSE;
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT bb.id buyFk,
|
||||
FLOOR(ish.visible / ish.packing) ishStickers,
|
||||
bb.stickers buyStickers
|
||||
FROM vn.itemShelving ish
|
||||
FROM itemShelving ish
|
||||
JOIN (SELECT b.id, b.itemFk, b.stickers
|
||||
FROM vn.buy b
|
||||
WHERE b.entryFk = vFromEntryFk
|
||||
ORDER BY b.stickers DESC
|
||||
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
|
||||
AND bb.stickers >= FLOOR(ish.visible / ish.packing)
|
||||
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
|
||||
GROUP BY ish.id;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Cantidades de la matrícula que exceden la de las entradas
|
||||
SELECT ish.itemFk,
|
||||
i.longName,
|
||||
FLOOR(ish.visible / ish.packing) AS etiEnMatricula,
|
||||
bb.stickers etiEnEntrada
|
||||
FROM vn.itemShelving ish
|
||||
JOIN vn.item i ON i.id = ish.itemFk
|
||||
LEFT JOIN (SELECT b.id, b.itemFk, b.stickers
|
||||
FROM vn.buy b
|
||||
FROM buy b
|
||||
WHERE b.entryFk = vFromEntryFk
|
||||
ORDER BY b.stickers DESC
|
||||
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
|
||||
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci
|
||||
AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing)
|
||||
AND bb.stickers >= FLOOR(ish.visible / ish.packing)
|
||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
|
||||
AND NOT ish.isSplit
|
||||
GROUP BY ish.id;
|
||||
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN cur;
|
||||
|
||||
read_loop: LOOP
|
||||
SET vDone = FALSE;
|
||||
|
||||
FETCH cur INTO vBuyFk, vIshStickers, vBuyStickers;
|
||||
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
|
||||
|
||||
IF vIshStickers = vBuyStickers THEN
|
||||
UPDATE vn.buy
|
||||
UPDATE buy
|
||||
SET entryFk = vToEntryFk
|
||||
WHERE id = vBuyFk;
|
||||
ELSE
|
||||
UPDATE vn.buy
|
||||
UPDATE buy
|
||||
SET stickers = stickers - vIshStickers,
|
||||
quantity = stickers * packing
|
||||
WHERE id = vBuyFk;
|
||||
|
||||
INSERT INTO vn.buy(entryFk,
|
||||
|
||||
INSERT INTO buy(entryFk,
|
||||
itemFk,
|
||||
quantity,
|
||||
buyingValue,
|
||||
|
@ -117,13 +102,16 @@ BEGIN
|
|||
weight,
|
||||
deliveryFk,
|
||||
itemOriginalFk
|
||||
FROM vn.buy
|
||||
FROM buy
|
||||
WHERE id = vBuyFk;
|
||||
|
||||
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
UPDATE itemShelving
|
||||
SET isSplit = TRUE
|
||||
WHERE shelvingFk = vShelvingFk;
|
||||
END LOOP;
|
||||
CLOSE cur;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.itemShelving ADD isSplit tinyint(1) NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda';
|
Loading…
Reference in New Issue