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

	CALL travel_checkDates(NEW.shipped, NEW.landed);

	CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);

	IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
		CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
	END IF;

	IF NEW.awbFk IS NOT NULL THEN
		CALL travel_throwAwb(NEW.id);
	END IF;
END$$
DELIMITER ;
