2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`currency_getCommission`(vSelf INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
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 ;
|