fix: ticket #216260 buy_recalcPrices #2916
|
@ -2,25 +2,33 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`()
|
||||
BEGIN
|
||||
/**
|
||||
* Recalcula los precios para las compras insertadas en tmp.buyRecalc
|
||||
* Recalcula los precios para las compras insertadas en tmp.buyRecalc.
|
||||
*
|
||||
* @param tmp.buyRecalc (id)
|
||||
*/
|
||||
DECLARE vLanded DATE;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vHasNotPrice BOOL;
|
||||
DECLARE vBuyingValue DECIMAL(10,4);
|
||||
DECLARE vPackagingFk VARCHAR(10);
|
||||
DECLARE vIsWarehouseFloramondo BOOL;
|
||||
|
||||
SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo')
|
||||
INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vTravels CURSOR FOR
|
||||
SELECT t.landed, t.warehouseInFk, (w.code = 'flm')
|
||||
FROM tmp.buyRecalc br
|
||||
JOIN buy b ON b.id = br.id
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||
LIMIT 1;
|
||||
GROUP BY t.landed, t.warehouseInFk, (w.code = 'flm');
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vTravels;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vTravels INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL rate_getPrices(vLanded, vWarehouseFk);
|
||||
|
||||
|
@ -42,11 +50,8 @@ BEGIN
|
|||
b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2),
|
||||
b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2);
|
||||
|
||||
SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk
|
||||
INTO vHasNotPrice, vBuyingValue, vPackagingFk
|
||||
FROM vn.buy b
|
||||
WHERE b.id = @buyId AND b.buyingValue <> 0.01;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.rate;
|
||||
END LOOP;
|
||||
CLOSE vTravels;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue