Hello everyone,
I’m looking for a way to automate email notifications to customers regarding their outstanding payments. Specifically, I want the system to:
- Send an email reminder if the payment becomes overdue.
Hello everyone,
I’m looking for a way to automate email notifications to customers regarding their outstanding payments. Specifically, I want the system to:
To automate email reminders for overdue payments in Frappe ERPNext, you can use a Scheduled Job combined with Email Templates and a custom script. Below is a complete guide to implement this:
Automatically send email reminders to customers when their Sales Invoices are overdue.
Go to:
Email Template → New
Fill the details:
Overdue Payment Reminder
Reminder: Payment Overdue for Invoice {{ doc.name }}
Dear {{ doc.customer_name }},
This is a friendly reminder that your payment for Invoice {{ doc.name }} is overdue.
**Invoice Date**: {{ doc.posting_date }}
**Due Date**: {{ doc.due_date }}
**Outstanding Amount**: ₹{{ doc.outstanding_amount }}
We request you to kindly make the payment at the earliest.
Regards,
Accounts Team
Create a Python script in your custom app, e.g., hooks.py
and overdue_reminder.py
.
hooks.py
scheduler_events = {
"daily": [
"your_app.overdue_reminder.send_overdue_reminders"
]
}
your_app/overdue_reminder.py
import frappe
from frappe.utils import nowdate
def send_overdue_reminders():
overdue_invoices = frappe.get_all(
"Sales Invoice",
filters={
"outstanding_amount": [">", 0],
"due_date": ["<", nowdate()],
"docstatus": 1 # submitted
},
fields=["name", "customer", "customer_name", "due_date", "posting_date", "outstanding_amount", "owner"]
)
for inv in overdue_invoices:
try:
invoice_doc = frappe.get_doc("Sales Invoice", inv.name)
customer_email = frappe.db.get_value("Customer", inv.customer, "email_id")
if customer_email:
frappe.sendmail(
recipients=[customer_email],
subject=f"Reminder: Payment Overdue for Invoice {inv.name}",
template="Overdue Payment Reminder",
args={"doc": invoice_doc},
reference_doctype="Sales Invoice",
reference_name=inv.name,
)
except Exception as e:
frappe.log_error(f"Error sending overdue reminder for Invoice {inv.name}: {e}")
Ensure your site scheduler is running:
bench --site your-site-name enable-scheduler
And supervisor is configured properly (for production).
reminder_sent
in Sales Invoice to avoid duplicate emails.Let me know if you want to send SMS instead of email, or want a UI toggle to enable/disable reminders per customer.
If you want to send overdue payment email reminders in ERPNext without writing any code, you can achieve it using Email Alerts (Notifications). Here’s how you can set it up:
Go to Email Template → Click New
Fill in:
Name: Overdue Payment Reminder
Subject: Reminder: Payment Overdue for Invoice {{ doc.name }}
Message:
Dear {{ doc.customer_name }},
This is a friendly reminder that your payment for Invoice {{ doc.name }} is overdue.
**Invoice Date**: {{ doc.posting_date }}
**Due Date**: {{ doc.due_date }}
**Outstanding Amount**: ₹{{ doc.outstanding_amount }}
Please make the payment at your earliest convenience.
Thank you,
Accounts Team
Save it.
Go to Notification (Search in Awesome Bar) → Click New
Fill the following:
Document Type: Sales Invoice
Subject: Overdue Payment Reminder
Send Alert On: → Select Days After
due_date
1
(or more)Condition:
doc.outstanding_amount > 0 and doc.docstatus == 1
Is Standard: Unchecked
In Recipients table:
Customer
customer_email
(or use contact_email
or create a custom field to store customer email)Overdue Payment Reminder
(select the one you created)Save the notification.
Make sure:
ERPNext will now automatically send overdue payment reminders without any coding required.