salix/db/routines/stock/triggers/outbound_beforeInsert.sql

17 lines
351 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_beforeInsert`
BEFORE INSERT ON `outbound`
FOR EACH ROW
BEGIN
SET NEW.lack = NEW.quantity;
SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE();
CALL visible_log(
NEW.isPicked,
NEW.warehouseFk,
NEW.itemFk,
-NEW.quantity
);
END$$
DELIMITER ;