I have a logistics system where every vehicle has multiple permits and licenses (insurance, NTSA inspection, TGL, port pass, etc.), each with an expiry date.
I want to set up a daily scheduled job (e.g. running at a time like 7:00 AM) that:
- Compiles all vehicles’ permit/license records across the system
- Classifies each one by how close it is to expiring:
- Red — already expired
- Orange — expires within 1 week
- Yellow — expires within 1 month
- Generates an HTML table like:
Vehicle Permit Expiry Date Status
SS-RR-LL-NNNN Vehicle Insurance 2026-09-15 Expired (Red)
SS-RR-LL-NNNN NTSA Inspection 2026-10-01 1 week left (Orange)
SS-RR-LL-NNNN Trailer Insurance 2026-10-20 1 month left (Yellow)
- Emails this compiled table automatically, every day, without manual intervention . we are sending via code
I’ve implemented this using scheduler_events with a cron expression in hooks.py, a Python function that pulls the records with frappe.get_all, classifies them by date difference, builds the HTML, and sends it via frappe.sendmail().
Is this the right/idiomatic approach in Frappe, or is there a better built-in pattern (e.g. Notification doctype, Auto Email Report, etc.) for this kind of recurring, computed, multi-record digest email? Would appreciate any pointers or best practices.
Thanks!