2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* DEPRECATED usar zoneGetFirstShipped
|
|
|
|
* Devuelve la primera fecha de envio disponible para una agencia en una direccion y un warehouse
|
|
|
|
*
|
|
|
|
* @param vAgencyMode id de la agencia en vn.agencyMode
|
|
|
|
* @param vAddress id de la direccion
|
|
|
|
* @param vWarehouse id del warehouse
|
|
|
|
* @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida
|
|
|
|
*/
|
|
|
|
DECLARE vAgency INT;
|
|
|
|
DECLARE vShipped DATE;
|
|
|
|
DECLARE vLanded DATE DEFAULT util.VN_CURDATE();
|
|
|
|
SELECT agencyFk INTO vAgency FROM agencyMode WHERE id= vAgencyMode;
|
|
|
|
|
|
|
|
l: LOOP
|
|
|
|
|
|
|
|
CALL agencyHourGetShipped(vLanded,vAddress,vAgency);
|
|
|
|
SELECT shipped INTO vShipped
|
|
|
|
FROM tmp.agencyHourGetShipped
|
|
|
|
WHERE warehouseFk = vWarehouse LIMIT 1;
|
|
|
|
|
|
|
|
IF vShipped THEN
|
|
|
|
LEAVE l;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SET vLanded = DATE_ADD(vLanded, INTERVAL +1 DAY);
|
|
|
|
|
|
|
|
END LOOP;
|
|
|
|
|
|
|
|
SELECT vShipped,vLanded;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|