Compare commits
5 Commits
dev
...
7763_renam
Author | SHA1 | Date |
---|---|---|
Sergio De la torre | 664bdc981d | |
Sergio De la torre | 5a7201a9fd | |
Sergio De la torre | 3ca64f51a9 | |
Sergio De la torre | ff4a35ee2e | |
Sergio De la torre | 0673e8ea5f |
|
@ -12,45 +12,38 @@ BEGIN
|
||||||
/**
|
/**
|
||||||
* Añade registro o lo actualiza si ya existe.
|
* Añade registro o lo actualiza si ya existe.
|
||||||
*
|
*
|
||||||
* @param vShelvingFk matrícula del carro
|
* @param vShelvingFk Matrícula del carro
|
||||||
* @param vBarcode el id del registro
|
* @param vBarcode El id del registro
|
||||||
* @param vQuantity indica la cantidad del producto
|
* @param vQuantity Indica la cantidad del producto
|
||||||
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
|
* @param vPackagingFk El packaging, NULL para coger el de la ultima compra
|
||||||
* @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra
|
* @param vGrouping El grouping, NULL para coger el de la ultima compra
|
||||||
* @param vPacking el packing del producto, NULL para coger el de la ultima compra
|
* @param vPacking El packing, NULL para coger el de la ultima compra
|
||||||
* @param vWarehouseFk indica el sector
|
* @param vWarehouseFk Indica el sector
|
||||||
*
|
*/
|
||||||
**/
|
DECLARE vItemFk INT DEFAULT barcodeToItem(vBarcode);
|
||||||
DECLARE vItemFk INT;
|
DECLARE vBuyFk INT DEFAULT (SELECT id FROM buy WHERE id = vBarcode);
|
||||||
DECLARE vBuyFk INT;
|
|
||||||
|
|
||||||
SELECT id INTO vBuyFk
|
|
||||||
FROM buy WHERE id = vBarcode;
|
|
||||||
|
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
|
||||||
|
|
||||||
IF vBuyFk IS NULL THEN
|
IF vBuyFk IS NULL THEN
|
||||||
CALL util.throw('The buy is required');
|
CALL util.throw('The buy is required');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vPacking IS NULL
|
IF vPacking IS NULL THEN
|
||||||
THEN
|
|
||||||
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
||||||
SET vQuantity = vQuantity * vPacking;
|
SET vQuantity = vQuantity * vPacking;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
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
|
AND packing = vPacking
|
||||||
AND buyFk = vBuyFk) THEN
|
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
|
||||||
|
|
||||||
INSERT INTO itemShelving(
|
INSERT INTO itemShelving(
|
||||||
itemFk,
|
itemFk,
|
||||||
shelvingFk,
|
shelvingFk,
|
||||||
|
@ -68,6 +61,8 @@ BEGIN
|
||||||
id
|
id
|
||||||
FROM buy b
|
FROM buy b
|
||||||
WHERE id = vBuyFk;
|
WHERE id = vBuyFk;
|
||||||
|
|
||||||
|
SELECT LAST_INSERT_ID();
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
Loading…
Reference in New Issue