salix/db/routines/vn/triggers/travel_beforeUpdate.sql

22 lines
564 B
SQL

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 ;