7525-devToTest #2542
|
@ -1205,11 +1205,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
||||||
(32, 36, -92.324),
|
(32, 36, -92.324),
|
||||||
(32, 39, 0.994);
|
(32, 39, 0.994);
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`)
|
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(2, 'GVC', 1, 1, 1, 1106),
|
(2, 'GVC', 1, 1, 1, 2,1106),
|
||||||
(4, 'HEJ', 1, 1, 1, 1106),
|
(4, 'HEJ', 1, 1, 1, NULL,1106),
|
||||||
(1, 'UXN', 2, 12, 12, 1106);
|
(1, 'UXN', 2, 12, 12, NULL,1106);
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
|
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -17,13 +17,15 @@ BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
itemFk,
|
itemFk,
|
||||||
packing,
|
packing,
|
||||||
created
|
created,
|
||||||
|
buyFk
|
||||||
FROM itemShelving
|
FROM itemShelving
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
) ish2
|
) ish2
|
||||||
ON ish2.itemFk = ish.itemFk
|
ON ish2.itemFk = ish.itemFk
|
||||||
AND ish2.packing = ish.packing
|
AND ish2.packing = ish.packing
|
||||||
AND date(ish2.created) = date(ish.created)
|
AND date(ish2.created) = date(ish.created)
|
||||||
|
AND ish2.buyFk = ish.buyFk
|
||||||
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
|
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
|
||||||
|
|
||||||
IF vNewItemShelvingFk THEN
|
IF vNewItemShelvingFk THEN
|
||||||
|
|
|
@ -2,7 +2,6 @@ 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)
|
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
|
BEGIN
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Añade registro o lo actualiza si ya existe.
|
* Añade registro o lo actualiza si ya existe.
|
||||||
*
|
*
|
||||||
|
@ -15,11 +14,23 @@ BEGIN
|
||||||
* @param vWarehouseFk indica el sector
|
* @param vWarehouseFk indica el sector
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
|
DECLARE vBuyFk INT;
|
||||||
|
|
||||||
|
SELECT id INTO vBuyFk
|
||||||
|
FROM buy WHERE id = vBarcode;
|
||||||
|
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
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
|
IF vPacking IS NULL
|
||||||
THEN
|
THEN
|
||||||
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
||||||
|
@ -29,31 +40,32 @@ BEGIN
|
||||||
IF (SELECT COUNT(*) FROM itemShelving
|
IF (SELECT COUNT(*) FROM itemShelving
|
||||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||||
AND itemFk = vItemFk
|
AND itemFk = vItemFk
|
||||||
AND packing = vPacking) = 1 THEN
|
AND packing = vPacking
|
||||||
|
AND buyFk = vBuyFk) THEN
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET visible = visible+vQuantity
|
SET visible = visible + vQuantity
|
||||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
|
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
|
||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
CALL cache.last_buy_refresh(FALSE);
|
|
||||||
INSERT INTO itemShelving( itemFk,
|
INSERT INTO itemShelving(
|
||||||
|
itemFk,
|
||||||
shelvingFk,
|
shelvingFk,
|
||||||
visible,
|
visible,
|
||||||
grouping,
|
grouping,
|
||||||
packing,
|
packing,
|
||||||
packagingFk)
|
packagingFk,
|
||||||
|
buyFk)
|
||||||
SELECT vItemFk,
|
SELECT vItemFk,
|
||||||
vShelvingFk,
|
vShelvingFk,
|
||||||
vQuantity,
|
vQuantity,
|
||||||
IFNULL(vGrouping, b.grouping),
|
IFNULL(vGrouping, b.grouping),
|
||||||
IFNULL(vPacking, b.packing),
|
IFNULL(vPacking, b.packing),
|
||||||
IFNULL(vPackagingFk, b.packagingFk)
|
IFNULL(vPackagingFk, b.packagingFk),
|
||||||
FROM item i
|
id
|
||||||
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
|
FROM buy b
|
||||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
WHERE id = vBuyFk;
|
||||||
WHERE i.id = vItemFk;
|
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue