24 lines
556 B
MySQL
24 lines
556 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`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 ;
|