2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeUpdate`
|
|
|
|
BEFORE UPDATE ON `invoiceInDueDay`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
DECLARE vIsNotified BOOLEAN;
|
|
|
|
|
2024-04-04 16:05:45 +00:00
|
|
|
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
2024-01-15 11:31:03 +00:00
|
|
|
SET NEW.editorFk = account.myUser_getId();
|
|
|
|
|
|
|
|
SELECT isNotified INTO vIsNotified
|
|
|
|
FROM vn.invoiceIn ii
|
|
|
|
JOIN vn.supplier s ON s.id = ii.supplierFk
|
|
|
|
JOIN vn.payMethod pm ON pm.id = s.payMethodFk
|
|
|
|
WHERE ii.id = NEW.invoiceInFk;
|
|
|
|
|
|
|
|
IF (NEW.dueDated <= util.VN_CURDATE() AND vIsNotified)
|
|
|
|
THEN
|
|
|
|
CALL mail_insert(
|
|
|
|
'begonya@verdnatura.es',
|
|
|
|
'begonya@verdnatura.es',
|
|
|
|
'Añadido vencimiento en el pasado',
|
|
|
|
CONCAT(
|
|
|
|
account.myUser_getName(), ' ha añadido un vencimiento de ',
|
|
|
|
NEW.amount,'€ en una fecha pasada en la recibida ',NEW.invoiceInFk
|
|
|
|
)
|
|
|
|
);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|