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`.`getDueDate`(vDated DATE, vDayToPay INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS date
|
|
|
|
NOT DETERMINISTIC
|
|
|
|
NO SQL
|
|
|
|
BEGIN
|
|
|
|
DECLARE vDued DATE;
|
|
|
|
|
|
|
|
IF vDayToPay = 0 THEN
|
|
|
|
RETURN vDated;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SET vDued = TIMESTAMPADD(DAY,vDayToPay MOD 30, LAST_DAY(TIMESTAMPADD(MONTH, vDayToPay DIV 30, vDated)));
|
|
|
|
|
|
|
|
RETURN vDued;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|