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.
|
||||
*
|
||||
* @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,6 +61,8 @@ BEGIN
|
|||
id
|
||||
FROM buy b
|
||||
WHERE id = vBuyFk;
|
||||
|
||||
SELECT LAST_INSERT_ID();
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue