DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT)
proc: BEGIN
/**
 * Aparca una preparación previa en un parking
 *
 * @param vSaleGroupFk id de la preparación previa
 * @param vParkingFk id del parking
 */
	UPDATE vn.saleGroup sg
		SET sg.parkingFk = vParkingFk
			WHERE sg.id = vSaleGroupFk
				AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());

	CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk));
END$$
DELIMITER ;
