2022-12-19 13:39:38 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS double
|
|
|
|
NOT DETERMINISTIC
|
2022-12-19 13:39:38 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vWarehouse INT;
|
|
|
|
DECLARE vRate2 DOUBLE;
|
|
|
|
|
|
|
|
SELECT round(vRate3 * (1 + ((r.rate2 - r.rate3)/100)), 2) INTO vRate2
|
|
|
|
FROM vn.rate r
|
|
|
|
JOIN vn.priceFixed p ON p.id = vFixedPriceFk
|
|
|
|
WHERE r.dated <= p.started
|
|
|
|
AND r.warehouseFk = p.warehouseFk
|
|
|
|
ORDER BY r.dated DESC
|
|
|
|
LIMIT 1;
|
|
|
|
|
|
|
|
RETURN vRate2;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|