cleaned up email
This commit is contained in:
parent
24da761a17
commit
fcb6b01e4e
@ -8,7 +8,6 @@ import webnotes.defaults
|
|||||||
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
||||||
get_first_day, get_last_day
|
get_first_day, get_last_day
|
||||||
|
|
||||||
from webnotes.utils.email_lib import sendmail
|
|
||||||
from webnotes.utils import comma_and, get_url
|
from webnotes.utils import comma_and, get_url
|
||||||
from webnotes.model.doc import make_autoname
|
from webnotes.model.doc import make_autoname
|
||||||
from webnotes.model.bean import getlist
|
from webnotes.model.bean import getlist
|
||||||
@ -689,7 +688,7 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
|||||||
webnotes.conn.begin()
|
webnotes.conn.begin()
|
||||||
webnotes.conn.sql("update `tabSales Invoice` set \
|
webnotes.conn.sql("update `tabSales Invoice` set \
|
||||||
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
|
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
|
||||||
notify_errors(ref_invoice, ref_wrapper.doc.owner)
|
notify_errors(ref_invoice, ref_wrapper.doc.customer, ref_wrapper.doc.owner)
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
|
|
||||||
exception_list.append(webnotes.get_traceback())
|
exception_list.append(webnotes.get_traceback())
|
||||||
@ -738,101 +737,23 @@ def make_new_invoice(ref_wrapper, posting_date):
|
|||||||
|
|
||||||
def send_notification(new_rv):
|
def send_notification(new_rv):
|
||||||
"""Notify concerned persons about recurring invoice generation"""
|
"""Notify concerned persons about recurring invoice generation"""
|
||||||
subject = "Invoice : " + new_rv.doc.name
|
|
||||||
|
|
||||||
com = new_rv.doc.company
|
|
||||||
|
|
||||||
hd = '''<div><h2>%s</h2></div>
|
|
||||||
<div><h3>Invoice: %s</h3></div>
|
|
||||||
<table cellspacing= "5" cellpadding="5" width = "100%%">
|
|
||||||
<tr>
|
|
||||||
<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
|
|
||||||
<td width = "50%%">Invoice Date : %s<br>Invoice Period : %s to %s <br>Due Date : %s</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
|
|
||||||
getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
|
|
||||||
getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
|
|
||||||
|
|
||||||
|
from webnotes.core.doctype.print_format.print_format import get_html
|
||||||
tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
|
webnotes.sendmail(new_rv.doc.notification_email_address,
|
||||||
<tr>
|
subject="New Invoice : " + new_rv.doc.name,
|
||||||
<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
|
message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice"))
|
||||||
<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
|
|
||||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
|
|
||||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
|
|
||||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
|
|
||||||
</tr>
|
|
||||||
'''
|
|
||||||
for d in getlist(new_rv.doclist, 'entries'):
|
|
||||||
tbl += '<tr><td>' + cstr(d.item_code) +'</td><td>' + cstr(d.description) + \
|
|
||||||
'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) + \
|
|
||||||
'</td><td>' + cstr(d.amount) +'</td></tr>'
|
|
||||||
tbl += '</table>'
|
|
||||||
|
|
||||||
totals ='''<table cellspacing= "5" cellpadding="5" width = "100%%">
|
|
||||||
<tr>
|
|
||||||
<td width = "50%%"></td>
|
|
||||||
<td width = "50%%">
|
|
||||||
<table width = "100%%">
|
|
||||||
<tr>
|
|
||||||
<td width = "50%%">Net Total: </td><td>%s </td>
|
|
||||||
</tr><tr>
|
|
||||||
<td width = "50%%">Total Tax: </td><td>%s </td>
|
|
||||||
</tr><tr>
|
|
||||||
<td width = "50%%">Grand Total: </td><td>%s</td>
|
|
||||||
</tr><tr>
|
|
||||||
<td width = "50%%">In Words: </td><td>%s</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr><td>Terms and Conditions:</td></tr>
|
|
||||||
<tr><td>%s</td></tr>
|
|
||||||
</table>
|
|
||||||
''' % (new_rv.doc.net_total,
|
|
||||||
new_rv.doc.other_charges_total,new_rv.doc.grand_total,
|
|
||||||
new_rv.doc.in_words,new_rv.doc.terms)
|
|
||||||
|
|
||||||
|
|
||||||
msg = hd + tbl + totals
|
|
||||||
|
|
||||||
sendmail(new_rv.doc.notification_email_address, subject=subject, msg = msg)
|
|
||||||
|
|
||||||
def notify_errors(inv, owner):
|
def notify_errors(inv, customer, owner):
|
||||||
import webnotes
|
|
||||||
|
|
||||||
exception_msg = """
|
|
||||||
Dear User,
|
|
||||||
|
|
||||||
An error occured while creating recurring invoice from %s (at %s).
|
|
||||||
|
|
||||||
May be there are some invalid email ids mentioned in the invoice.
|
|
||||||
|
|
||||||
To stop sending repetitive error notifications from the system, we have unchecked
|
|
||||||
"Convert into Recurring" field in the invoice %s.
|
|
||||||
|
|
||||||
|
|
||||||
Please correct the invoice and make the invoice recurring again.
|
|
||||||
|
|
||||||
<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
|
|
||||||
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
|
|
||||||
of this invoice for generating the recurring invoice.</b>
|
|
||||||
|
|
||||||
Regards,
|
|
||||||
Administrator
|
|
||||||
|
|
||||||
""" % (inv, get_url(), inv)
|
|
||||||
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
|
|
||||||
|
|
||||||
from webnotes.profile import get_system_managers
|
from webnotes.profile import get_system_managers
|
||||||
recipients = get_system_managers()
|
|
||||||
owner_email = webnotes.conn.get_value("Profile", owner, "email")
|
webnotes.sendmail(recipients=get_system_managers() + [webnotes.conn.get_value("Profile", owner, "email")],
|
||||||
if not owner_email in recipients:
|
subject="[Urgent] Error while creating recurring invoice for %s" % inv,
|
||||||
recipients.append(owner_email)
|
message = webnotes.get_template("template/emails/recurring_invoice_failed.html").render({
|
||||||
|
"name": inv,
|
||||||
assign_task_to_owner(inv, exception_msg, recipients)
|
"customer": customer
|
||||||
sendmail(recipients, subject=subj, msg = exception_msg)
|
})
|
||||||
|
|
||||||
|
assign_task_to_owner(inv, "Recurring Invoice Failed", recipients)
|
||||||
|
|
||||||
def assign_task_to_owner(inv, msg, users):
|
def assign_task_to_owner(inv, msg, users):
|
||||||
for d in users:
|
for d in users:
|
||||||
|
12
erpnext/templates/emails/recurring_invoice_failed.html
Normal file
12
erpnext/templates/emails/recurring_invoice_failed.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<h2>Recurring Invoice Failed</h2>
|
||||||
|
|
||||||
|
<p>An error occured while creating recurring invoice <b>{{ name }}</b> for <b>{{ customer }}</b>.</p>
|
||||||
|
<p>This could be because of some invalid email ids in the invoice.</p>
|
||||||
|
<p>To stop sending repetitive error notifications from the system, we have unchecked
|
||||||
|
"Convert into Recurring" field in the invoice {{ name }}.</p>
|
||||||
|
<p><b>Please correct the invoice and make the invoice recurring again.</b></p>
|
||||||
|
<hr>
|
||||||
|
<p><b>It is necessary to take this action today itself for the above mentioned recurring invoice \
|
||||||
|
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
|
||||||
|
of this invoice for generating the recurring invoice.</b></p>
|
||||||
|
<p>[This email is autogenerated]</p>
|
Loading…
x
Reference in New Issue
Block a user