36 lines
1.0 KiB
SQL
36 lines
1.0 KiB
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT)
|
|
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 ;
|