DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate`
	BEFORE UPDATE ON `travel`
	FOR EACH ROW
BEGIN
	SET NEW.editorFk = account.myUser_getId();

	IF NOT (NEW.landed <=> OLD.landed)
	OR NOT (NEW.shipped <=> OLD.shipped) THEN
		CALL travel_checkDates(NEW.shipped, NEW.landed);
	END IF;

	IF NOT (NEW.isReceived <=> OLD.isReceived) THEN
		CALL travel_checkPackaging(NEW.id);
	END IF;

	IF NOT (NEW.warehouseInFk <=> OLD.warehouseInFk) THEN
		CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
	END IF;
END$$
DELIMITER ;
