29 lines
884 B
Python
29 lines
884 B
Python
|
|
||
|
import frappe
|
||
|
from frappe import sendmail
|
||
|
from frappe.utils import nowdate
|
||
|
from frappe.core.doctype.communication.email import make
|
||
|
|
||
|
def send_email_reminders():
|
||
|
|
||
|
reminder = frappe.get_doc('Rent Reminders')
|
||
|
if(reminder.is_enabled):
|
||
|
records = frappe.get_all('Contract Details', filters={
|
||
|
'type': 'For-Rent',
|
||
|
},fields=["*"])
|
||
|
for record in records:
|
||
|
subject = "Reminder: Rent Amount"
|
||
|
message = f"Dear Tenant, please pay the rent amount on time."
|
||
|
tenant = frappe.get_doc("Shop Tenant",{"first_name",record.tenant_name})
|
||
|
recipients = [ tenant.email ]
|
||
|
|
||
|
# Send email
|
||
|
comm = sendmail(
|
||
|
recipients= recipients,
|
||
|
subject=subject,
|
||
|
message=message,
|
||
|
)
|
||
|
return comm
|
||
|
else:
|
||
|
return "Reminder not enabled"
|