7430_devToTest #2490
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
"vn": {
|
||||
"view": {
|
||||
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb"
|
||||
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
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
|
||||
|
||||
/**
|
||||
* Obtiene el precio y visible de un item
|
||||
*
|
||||
|
@ -9,82 +11,45 @@ BEGIN
|
|||
* @param vShelvingFK Ubicación actual del artículo
|
||||
*/
|
||||
DECLARE vIsItem BOOL;
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vItemCost DECIMAL(10,4);
|
||||
DECLARE vCacheVisibleFk INT;
|
||||
DECLARE vBuyFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vVisible INT;
|
||||
|
||||
|
||||
SELECT COUNT(*)>0 INTO vIsItem
|
||||
FROM vn.item
|
||||
SELECT COUNT(*) > 0 INTO vIsItem
|
||||
FROM item
|
||||
WHERE id = vBarcodeItem;
|
||||
|
||||
IF NOT 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
|
||||
|
||||
IF vIsItem THEN
|
||||
SELECT warehouseFk INTO vWarehouseFk
|
||||
FROM operator
|
||||
WHERE workerFk = account.myUser_getId();
|
||||
|
||||
SELECT barcodeToItem(vBarcodeItem) INTO vItemFk;
|
||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
||||
|
||||
IF vItemFk IS NULL THEN
|
||||
CALL util.throw ('Item not valid');
|
||||
ELSE
|
||||
CALL buyUltimate(vWarehouseFk, util.VN_CURDATE());
|
||||
|
||||
SELECT IFNULL(b.buyingValue, 0) +
|
||||
IFNULL(b.freightValue, 0) +
|
||||
IFNULL(b.comissionValue, 0) +
|
||||
IFNULL(b.packageValue, 0) itemCost,
|
||||
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;
|
||||
|
||||
END IF;
|
||||
SELECT buyFk INTO vBuyFk
|
||||
FROM tmp.buyUltimate
|
||||
WHERE itemFk = vBarcodeItem
|
||||
AND warehouseFk = vWarehouseFk;
|
||||
|
||||
DELETE FROM tmp.buyUltimate;
|
||||
ELSE
|
||||
SELECT vBarcodeItem INTO vBuyFk;
|
||||
END IF;
|
||||
|
||||
IF vItemCost IS NULL THEN
|
||||
CALL util.throw ('Item not valid');
|
||||
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$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue