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

21 lines
409 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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 ;