2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`payment_afterInsert`
|
2024-01-15 11:31:03 +00:00
|
|
|
AFTER INSERT ON `payment`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
DECLARE vIsPayMethodChecked BOOLEAN;
|
|
|
|
DECLARE vEmail VARCHAR(150);
|
|
|
|
|
|
|
|
SELECT isPayMethodChecked INTO vIsPayMethodChecked
|
|
|
|
FROM supplier
|
|
|
|
WHERE id = NEW.supplierFk;
|
|
|
|
|
|
|
|
|
|
|
|
IF vIsPayMethodChecked = FALSE THEN
|
|
|
|
|
|
|
|
SELECT notificationEmail INTO vEmail
|
|
|
|
FROM department
|
|
|
|
WHERE name = 'FINANZAS';
|
|
|
|
|
|
|
|
CALL mail_insert(
|
|
|
|
vEmail,
|
|
|
|
NULL,
|
|
|
|
'Pago con método sin verificar',
|
|
|
|
CONCAT(
|
|
|
|
'Se ha realizado el pago ',
|
|
|
|
NEW.id,
|
|
|
|
' al proveedor ',
|
|
|
|
NEW.supplierFk,
|
|
|
|
' con el método de pago sin verificar.'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|