salix/db/changes/10271-wisemen/02-triggerReceipt.sql

18 lines
365 B
SQL

DROP TRIGGER IF EXISTS vn.receipt_beforInsert;
DELIMITER $$
$$
CREATE TRIGGER receipt_beforInsert
BEFORE INSERT
ON receipt FOR EACH ROW
BEGIN
SELECT isAutoConciliated INTO @isAutoConciliated
FROM accounting a
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
WHERE a.id =NEW.bankFk;
SET NEW.isConciliate = @isAutoConciliated;
END
$$
DELIMITER ;