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

21 lines
411 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_getCurrency`(vCurrency INT,
vSupplierFk INT
)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE vIsDollarAccount BOOL;
SELECT account LIKE '___4______' INTO vIsDollarAccount
FROM vn.supplier WHERE id = vSupplierFk;
IF vIsDollarAccount THEN
RETURN 2;
ELSE
RETURN vCurrency;
END IF;
END$$
DELIMITER ;