22 lines
491 B
SQL
22 lines
491 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE)
|
|
RETURNS double
|
|
NOT DETERMINISTIC
|
|
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 ;
|