From 3ca64f51a985e1cd357b976666cb5c6a13b9a901 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 6 Aug 2024 13:47:20 +0200 Subject: [PATCH] feat rename refs #7763 --- .../vn/procedures/itemShelving_add.sql | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 416e75d72..d35897071 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -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 ; \ No newline at end of file