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

24 lines
678 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;