From a6dfdc971afc6cfd1bbe002641cb237be424197d Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 20 Jan 2021 13:54:55 +0100 Subject: [PATCH] receipt_beforInsert --- db/changes/10270-wisemen/02-triggerReceipt.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/changes/10270-wisemen/02-triggerReceipt.sql diff --git a/db/changes/10270-wisemen/02-triggerReceipt.sql b/db/changes/10270-wisemen/02-triggerReceipt.sql new file mode 100644 index 000000000..9b08a302f --- /dev/null +++ b/db/changes/10270-wisemen/02-triggerReceipt.sql @@ -0,0 +1,17 @@ +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 ;