2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_zoneClosure`()
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
/* Devuelve una tabla temporal con la hora minima de un ticket sino tiene el de la zoneClosure y
|
|
|
|
* si tampoco hay el de la zona , para todos los artículos con salida hoy.
|
|
|
|
*
|
|
|
|
* @return tmp.itemZoneClosure(itemFk, timed)
|
|
|
|
*/
|
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemZoneClosure
|
|
|
|
(INDEX (itemFk))
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT s.itemFk,
|
|
|
|
MIN(DATE_FORMAT(IF(HOUR(t.shipped),t.shipped,
|
|
|
|
IFNULL(zc.hour, z.HOUR)), '%H:%i')
|
|
|
|
)timed
|
|
|
|
FROM ticket t
|
|
|
|
JOIN sale s ON s.ticketFk = t.id
|
|
|
|
LEFT JOIN `zone` z ON z.id = t.zoneFk
|
|
|
|
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
|
|
|
|
WHERE t.shipped BETWEEN util.VN_CURDATE() AND CONCAT(util.VN_CURDATE(), ' 23:59:59')
|
|
|
|
GROUP BY s.itemFk;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|