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

24 lines
672 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_isOutClosureZone`(vSelf INT)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
/**
* Devuelve true/false si la hora actual supera la hora del cierre del ticket más el tiempo configurado en packingDelay
*
* @param vSelf Ticket id
* @return true o false
*/
DECLARE vIsTicketInTime BOOL;
SELECT TIMEDIFF(CURRENT_TIME(), zc.hour + INTERVAL tc.packingDelay HOUR) > 0 INTO vIsTicketInTime
FROM vn.ticket t
JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
LEFT JOIN vn.ticketConfig tc ON TRUE
WHERE t.id = vSelf
AND zc.dated = util.VN_CURDATE();
RETURN vIsTicketInTime;
END$$
DELIMITER ;