7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
2 changed files with 80 additions and 91 deletions
Showing only changes of commit 4f9552379e - Show all commits

View File

@ -9,70 +9,81 @@ BEGIN
* @param vToEntryFk Entrada destino * @param vToEntryFk Entrada destino
*/ */
DECLARE vBuyFk INT; DECLARE vBuyFk INT;
DECLARE vIshStickers INT; DECLARE vIshStickers INT;
DECLARE vBuyStickers INT; DECLARE vBuyStickers INT;
DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE cur CURSOR FOR
SELECT bb.id buyFk,
FLOOR(ish.visible / ish.packing) ishStickers,
bb.stickers buyStickers
FROM vn.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 DECLARE cur CURSOR FOR
SELECT ish.itemFk, SELECT bb.id buyFk,
i.longName, FLOOR(ish.visible / ish.packing) ishStickers,
FLOOR(ish.visible / ish.packing) AS etiEnMatricula, bb.stickers buyStickers
bb.stickers etiEnEntrada FROM itemShelving ish
FROM vn.itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers
JOIN vn.item i ON i.id = ish.itemFk FROM buy b
LEFT JOIN (SELECT b.id, b.itemFk, b.stickers WHERE b.entryFk = vFromEntryFk
FROM vn.buy b ORDER BY b.stickers DESC
WHERE b.entryFk = vFromEntryFk LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
ORDER BY b.stickers DESC AND bb.stickers >= FLOOR(ish.visible / ish.packing)
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci AND NOT ish.isSplit
AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) GROUP BY ish.id;
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; OPEN cur;
IF vDone THEN read_loop: LOOP
LEAVE read_loop; SET vDone = FALSE;
END IF;
IF vIshStickers = vBuyStickers THEN FETCH cur INTO vBuyFk, vIshStickers, vBuyStickers;
UPDATE vn.buy
SET entryFk = vToEntryFk IF vDone THEN
WHERE id = vBuyFk; LEAVE read_loop;
ELSE END IF;
UPDATE vn.buy
SET stickers = stickers - vIshStickers, IF vIshStickers = vBuyStickers THEN
quantity = stickers * packing UPDATE buy
WHERE id = vBuyFk; SET entryFk = vToEntryFk
WHERE id = vBuyFk;
INSERT INTO vn.buy(entryFk, ELSE
UPDATE buy
SET stickers = stickers - vIshStickers,
quantity = stickers * packing
WHERE id = vBuyFk;
INSERT INTO buy(entryFk,
itemFk,
quantity,
buyingValue,
freightValue,
isIgnored,
stickers,
packing,
`grouping`,
groupingMode,
comissionValue,
packageValue,
location,
packagingFk,
price1,
price2,
price3,
minPrice,
workerFk,
isChecked,
isPickedOff,
ektFk,
weight,
deliveryFk,
itemOriginalFk)
SELECT
vToEntryFk,
itemFk, itemFk,
quantity, vIshStickers * packing,
buyingValue, buyingValue,
freightValue, freightValue,
isIgnored, isIgnored,
stickers, vIshStickers,
packing, packing,
`grouping`, `grouping`,
groupingMode, groupingMode,
@ -90,40 +101,17 @@ BEGIN
ektFk, ektFk,
weight, weight,
deliveryFk, deliveryFk,
itemOriginalFk) itemOriginalFk
SELECT FROM buy
vToEntryFk, WHERE id = vBuyFk;
itemFk,
vIshStickers * packing, UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
buyingValue, END IF;
freightValue,
isIgnored, UPDATE itemShelving
vIshStickers, SET isSplit = TRUE
packing, WHERE shelvingFk = vShelvingFk;
`grouping`, END LOOP;
groupingMode, CLOSE cur;
comissionValue,
packageValue,
location,
packagingFk,
price1,
price2,
price3,
minPrice,
workerFk,
isChecked,
isPickedOff,
ektFk,
weight,
deliveryFk,
itemOriginalFk
FROM vn.buy
WHERE id = vBuyFk;
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
END IF;
END LOOP;
CLOSE cur;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -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';