refs #4979 feat:getInfoDetails && item_devalueA2
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
9288f08b91
commit
9b73cdfa6f
|
@ -0,0 +1,90 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(vBarcodeItem INT, vShelvingFK VARCHAR(10) )
|
||||
BEGIN
|
||||
|
||||
/**
|
||||
* Obtiene el precio y visible de un item
|
||||
*
|
||||
* @param vBarcodeItem barcode de artículo
|
||||
* @param vBarcodeItem Ubicación actual del artículo
|
||||
*/
|
||||
DECLARE vIsItem BOOL;
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vItemCost DECIMAL(10,4);
|
||||
DECLARE vCacheVisibleFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vVisible INT;
|
||||
|
||||
|
||||
SELECT COUNT(*)>0 INTO vIsItem
|
||||
FROM vn.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
|
||||
|
||||
SELECT warehouseFk INTO vWarehouseFk
|
||||
FROM operator
|
||||
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());
|
||||
|
||||
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;
|
||||
|
||||
END IF;
|
||||
|
||||
IF vItemCost IS NULL THEN
|
||||
CALL util.throw ('Item not valid');
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -14,6 +14,7 @@ BEGIN
|
|||
* @param vSelf Id de artículo a devaluar
|
||||
* @param vShelvingFK Ubicación actual del artículo
|
||||
* @param vBuyingValue Nuevo precio de coste
|
||||
* @param vQuantity Cantidad del ítem a pasar a A2
|
||||
*/
|
||||
DECLARE vItemA2Fk INT;
|
||||
DECLARE vLastBuyFk BIGINT;
|
||||
|
@ -28,6 +29,7 @@ BEGIN
|
|||
DECLARE vCurrentVisible INT;
|
||||
DECLARE vDevalueTravelFk INT;
|
||||
DECLARE vCurdate DATE;
|
||||
DECLARE vBuyingValueOriginal DECIMAL(10,4);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
@ -86,19 +88,23 @@ BEGIN
|
|||
SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate
|
||||
FROM `entry` e
|
||||
WHERE DATE(dated) = vCurdate
|
||||
AND typeFk ='devaluation'
|
||||
AND typeFk = 'devaluation'
|
||||
AND travelFk = vDevalueTravelFk
|
||||
ORDER BY created DESC
|
||||
LIMIT 1;
|
||||
|
||||
CALL buyUltimate(vWarehouseFk, vCurdate);
|
||||
|
||||
SELECT b.entryFk, bu.buyFk INTO vLastEntryFk,vLastBuyFk
|
||||
SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN vn.buy b ON b.id =bu.buyFk
|
||||
JOIN vn.buy b ON b.id = bu.buyFk
|
||||
WHERE bu.itemFk = vSelf
|
||||
AND bu.warehouseFk = vWarehouseFk;
|
||||
|
||||
|
||||
IF vBuyingValue > vBuyingValueOriginal THEN
|
||||
CALL util.throw ('Price not valid');
|
||||
END IF;
|
||||
|
||||
IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN
|
||||
CALL util.throw ('The item has not a buy');
|
||||
END IF;
|
||||
|
|
Loading…
Reference in New Issue