7430_devToTest #2490
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"vn": {
|
"vn": {
|
||||||
"view": {
|
"view": {
|
||||||
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb"
|
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(vBarcodeItem INT, vShelvingFK VARCHAR(10) )
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
|
||||||
|
vBarcodeItem INT,
|
||||||
|
vShelvingFK VARCHAR(10)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtiene el precio y visible de un item
|
* Obtiene el precio y visible de un item
|
||||||
*
|
*
|
||||||
|
@ -9,82 +11,45 @@ BEGIN
|
||||||
* @param vShelvingFK Ubicación actual del artículo
|
* @param vShelvingFK Ubicación actual del artículo
|
||||||
*/
|
*/
|
||||||
DECLARE vIsItem BOOL;
|
DECLARE vIsItem BOOL;
|
||||||
DECLARE vItemFk INT;
|
DECLARE vBuyFk INT;
|
||||||
DECLARE vItemCost DECIMAL(10,4);
|
|
||||||
DECLARE vCacheVisibleFk INT;
|
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vVisible INT;
|
|
||||||
|
|
||||||
|
|
||||||
SELECT COUNT(*) > 0 INTO vIsItem
|
SELECT COUNT(*) > 0 INTO vIsItem
|
||||||
FROM vn.item
|
FROM item
|
||||||
WHERE id = vBarcodeItem;
|
WHERE id = vBarcodeItem;
|
||||||
|
|
||||||
IF NOT vIsItem THEN
|
IF vIsItem THEN
|
||||||
|
|
||||||
SELECT IFNULL(b.buyingValue, 0) +
|
|
||||||
IFNULL(b.freightValue, 0) +
|
|
||||||
IFNULL(b.comissionValue, 0) +
|
|
||||||
IFNULL(b.packageValue, 0),
|
|
||||||
SUM(is2.visible) ,
|
|
||||||
b.itemFk
|
|
||||||
INTO vItemCost, vVisible, vItemFk
|
|
||||||
FROM itemShelving is2
|
|
||||||
JOIN buy b ON b.itemFk = is2.itemFk AND b.id = vBarcodeItem
|
|
||||||
WHERE is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
|
|
||||||
GROUP BY shelvingFK;
|
|
||||||
|
|
||||||
SELECT vItemFk itemFk,
|
|
||||||
vShelvingFK shelvingFk,
|
|
||||||
vItemCost itemCost,
|
|
||||||
vVisible quantity;
|
|
||||||
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF vItemCost IS NULL THEN
|
|
||||||
|
|
||||||
SELECT warehouseFk INTO vWarehouseFk
|
SELECT warehouseFk INTO vWarehouseFk
|
||||||
FROM operator
|
FROM operator
|
||||||
WHERE workerFk = account.myUser_getId();
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT barcodeToItem(vBarcodeItem) INTO vItemFk;
|
|
||||||
|
|
||||||
IF vItemFk IS NULL THEN
|
|
||||||
CALL util.throw ('Item not valid');
|
|
||||||
ELSE
|
|
||||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
SELECT IFNULL(b.buyingValue, 0) +
|
SELECT buyFk INTO vBuyFk
|
||||||
IFNULL(b.freightValue, 0) +
|
FROM tmp.buyUltimate
|
||||||
IFNULL(b.comissionValue, 0) +
|
WHERE itemFk = vBarcodeItem
|
||||||
IFNULL(b.packageValue, 0) itemCost,
|
AND warehouseFk = vWarehouseFk;
|
||||||
SUM(is2.visible) visible,
|
|
||||||
is2.itemFk
|
|
||||||
INTO vItemCost, vVisible, vItemFk
|
|
||||||
FROM itemShelving is2
|
|
||||||
JOIN tmp.buyUltimate bu ON bu.itemFk = is2.itemFk
|
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
|
||||||
WHERE is2.itemFk = vBarcodeItem AND
|
|
||||||
is2.shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci;
|
|
||||||
|
|
||||||
IF vItemFk IS NULL THEN
|
|
||||||
CALL util.throw ('Item not valid');
|
|
||||||
ELSE
|
|
||||||
SELECT vItemFk itemFk,
|
|
||||||
vShelvingFK shelvingFk,
|
|
||||||
vItemCost itemCost,
|
|
||||||
vVisible quantity;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
DELETE FROM tmp.buyUltimate;
|
DELETE FROM tmp.buyUltimate;
|
||||||
|
ELSE
|
||||||
END IF;
|
SELECT vBarcodeItem INTO vBuyFk;
|
||||||
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF vItemCost IS NULL THEN
|
|
||||||
CALL util.throw ('Item not valid');
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
WITH visible AS(
|
||||||
|
SELECT itemFk,
|
||||||
|
IFNULL(buyingValue, 0) +
|
||||||
|
IFNULL(freightValue, 0) +
|
||||||
|
IFNULL(comissionValue, 0) +
|
||||||
|
IFNULL(packageValue, 0) itemCost
|
||||||
|
FROM vn.buy b
|
||||||
|
WHERE b.id = vBuyFk
|
||||||
|
) SELECT v.itemFk,
|
||||||
|
vShelvingFK,
|
||||||
|
v.itemCost,
|
||||||
|
SUM(ish.visible) visible
|
||||||
|
FROM vn.itemShelving ish
|
||||||
|
JOIN visible v
|
||||||
|
WHERE ish.shelvingFK = vShelvingFK
|
||||||
|
AND ish.itemFk = v.itemFk;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
Loading…
Reference in New Issue