This commit is contained in:
parent
ff4a35ee2e
commit
3ca64f51a9
|
@ -12,45 +12,38 @@ BEGIN
|
|||
/**
|
||||
* Añade registro o lo actualiza si ya existe.
|
||||
*
|
||||
* @param vShelvingFk matrícula del carro
|
||||
* @param vBarcode el id del registro
|
||||
* @param vQuantity indica la cantidad del producto
|
||||
* @param vPackagingFk el packaging del producto en itemShelving, 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 vPacking el packing del producto, NULL para coger el de la ultima compra
|
||||
* @param vWarehouseFk indica el sector
|
||||
*
|
||||
**/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vBuyFk INT;
|
||||
|
||||
SELECT id INTO vBuyFk
|
||||
FROM buy WHERE id = vBarcode;
|
||||
|
||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||
* @param vShelvingFk Matrícula del carro
|
||||
* @param vBarcode El id del registro
|
||||
* @param vQuantity Indica la cantidad del producto
|
||||
* @param vPackagingFk El packaging, NULL para coger el de la ultima compra
|
||||
* @param vGrouping El grouping, 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
|
||||
*/
|
||||
DECLARE vItemFk INT DEFAULT barcodeToItem(vBarcode);
|
||||
DECLARE vBuyFk INT DEFAULT (SELECT id FROM buy WHERE id = vBarcode);
|
||||
|
||||
IF vBuyFk IS NULL THEN
|
||||
CALL util.throw('The buy is required');
|
||||
END IF;
|
||||
|
||||
IF vPacking IS NULL
|
||||
THEN
|
||||
IF vPacking IS NULL THEN
|
||||
SET vPacking = itemPacking(vBarcode, vWarehouseFk);
|
||||
SET vQuantity = vQuantity * vPacking;
|
||||
END IF;
|
||||
|
||||
IF (SELECT COUNT(*) FROM itemShelving
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||
AND itemFk = vItemFk
|
||||
AND packing = vPacking
|
||||
AND buyFk = vBuyFk) THEN
|
||||
|
||||
UPDATE itemShelving
|
||||
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
|
||||
|
||||
INSERT INTO itemShelving(
|
||||
itemFk,
|
||||
shelvingFk,
|
||||
|
@ -68,7 +61,8 @@ BEGIN
|
|||
id
|
||||
FROM buy b
|
||||
WHERE id = vBuyFk;
|
||||
SELECT LAST_INSERT_ID();
|
||||
|
||||
SELECT LAST_INSERT_ID();
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue