salix/db/routines/vn/procedures/bankPolicy_notifyExpired.sql

21 lines
672 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`bankPolicy_notifyExpired`()
BEGIN
/**
*
* Manda correo cuando caduca un seguro
* de los leasing
*
*/
INSERT INTO mail (receiver,replyTo,subject,body)
SELECT 'administracion@verdnatura.es' receiver,
'noreply@verdnatura.es' replyTo,
2024-03-14 07:36:19 +00:00
CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') subject,
CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') body
FROM bankPolicy bp
LEFT JOIN supplier s ON s.id = bp.supplierFk
LEFT JOIN accounting a ON a.id = bp.accountingFk
WHERE bp.insuranceExpired = util.VN_CURDATE();
END$$
DELIMITER ;