DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `srt`.`expedition_weighing`(vWeight DECIMAL(10,2), vExpeditionFk INT, OUT vExpeditionOutFk INT )
BEGIN
	
	/**
	 * Actualiza el peso de una expedición
	 *
	 * @param vWeight Peso en kilos
	 * @param vExpeditionFk Identificador de srt.expedition
	 * 
	 * @return vExpeditionOutFk Identificador de srt.expedition
	 */
	
	SET vExpeditionOutFk = srt.expedition_check(vExpeditionFk);
	
	UPDATE srt.expedition e
		JOIN srt.expeditionState es on es.description = 'WEIGHED'
		SET weight = vWeight,
		stateFk = es.id
        WHERE e.id = vExpeditionOutFk;
    
END$$
DELIMITER ;
