salix/db/routines/vn/functions/currency_getCommission.sql

24 lines
554 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`currency_getCommission`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Devuelve el tipo de cambio en el dia de hoy dada el tipo de moneda
*
* @param vSelf id del tipo de moneda
* @return devuelve la comision
*/
DECLARE vCommission INT;
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
FROM referenceCurrent r
WHERE r.currencyFk = vSelf
AND r.`dated` <= util.VN_CURDATE()
ORDER BY r.`dated` DESC
LIMIT 1;
RETURN vCommission;
END$$
DELIMITER ;