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 ;
