Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
6fa388c3d4
@ -728,24 +728,25 @@ def get_next_date(dt, mcount, day=None):
|
|||||||
next_month_date = datetime.date(year, month, last_day)
|
next_month_date = datetime.date(year, month, last_day)
|
||||||
return next_month_date.strftime("%Y-%m-%d")
|
return next_month_date.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
def manage_recurring_invoices():
|
def manage_recurring_invoices(next_date=None):
|
||||||
"""
|
"""
|
||||||
Create recurring invoices on specific date by copying the original one
|
Create recurring invoices on specific date by copying the original one
|
||||||
and notify the concerned people
|
and notify the concerned people
|
||||||
"""
|
"""
|
||||||
|
next_date = next_date or nowdate()
|
||||||
recurring_invoices = webnotes.conn.sql("""select name, recurring_id
|
recurring_invoices = webnotes.conn.sql("""select name, recurring_id
|
||||||
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
|
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
|
||||||
and docstatus=1 and next_date=%s
|
and docstatus=1 and next_date=%s
|
||||||
and next_date <= ifnull(end_date, '2199-12-31')""", nowdate())
|
and next_date <= ifnull(end_date, '2199-12-31')""", next_date)
|
||||||
|
|
||||||
exception_list = []
|
exception_list = []
|
||||||
for ref_invoice, recurring_id in recurring_invoices:
|
for ref_invoice, recurring_id in recurring_invoices:
|
||||||
if not webnotes.conn.sql("""select name from `tabSales Invoice`
|
if not webnotes.conn.sql("""select name from `tabSales Invoice`
|
||||||
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||||
(nowdate(), recurring_id)):
|
(next_date, recurring_id)):
|
||||||
try:
|
try:
|
||||||
ref_wrapper = webnotes.model_wrapper('Sales Invoice', ref_invoice)
|
ref_wrapper = webnotes.model_wrapper('Sales Invoice', ref_invoice)
|
||||||
new_invoice_wrapper = make_new_invoice(ref_wrapper)
|
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
||||||
send_notification(new_invoice_wrapper)
|
send_notification(new_invoice_wrapper)
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -765,19 +766,17 @@ def manage_recurring_invoices():
|
|||||||
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
||||||
raise Exception, exception_message
|
raise Exception, exception_message
|
||||||
|
|
||||||
def make_new_invoice(ref_wrapper):
|
def make_new_invoice(ref_wrapper, posting_date):
|
||||||
from webnotes.model.wrapper import clone
|
from webnotes.model.wrapper import clone
|
||||||
new_invoice = clone(ref_wrapper)
|
new_invoice = clone(ref_wrapper)
|
||||||
|
|
||||||
mcount = month_map[ref_wrapper.doc.recurring_type]
|
mcount = month_map[ref_wrapper.doc.recurring_type]
|
||||||
|
|
||||||
today = nowdate()
|
|
||||||
|
|
||||||
new_invoice.doc.fields.update({
|
new_invoice.doc.fields.update({
|
||||||
"posting_date": today,
|
"posting_date": posting_date,
|
||||||
"aging_date": today,
|
"aging_date": posting_date,
|
||||||
|
|
||||||
"due_date": add_days(today, cint(date_diff(ref_wrapper.doc.due_date,
|
"due_date": add_days(posting_date, cint(date_diff(ref_wrapper.doc.due_date,
|
||||||
ref_wrapper.doc.posting_date))),
|
ref_wrapper.doc.posting_date))),
|
||||||
|
|
||||||
"invoice_period_from_date": \
|
"invoice_period_from_date": \
|
||||||
@ -822,7 +821,9 @@ def send_notification(new_rv):
|
|||||||
</tr>
|
</tr>
|
||||||
'''
|
'''
|
||||||
for d in getlist(new_rv.doclist, 'entries'):
|
for d in getlist(new_rv.doclist, 'entries'):
|
||||||
tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
|
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>'
|
tbl += '</table>'
|
||||||
|
|
||||||
totals ='''<table cellspacing= "5" cellpadding="5" width = "100%%">
|
totals ='''<table cellspacing= "5" cellpadding="5" width = "100%%">
|
||||||
|
@ -139,3 +139,14 @@ cur_frm.fields_dict.item_customer_details.grid.get_field("customer_name").get_qu
|
|||||||
|
|
||||||
cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
|
cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
|
||||||
erpnext.utils.supplier_query;
|
erpnext.utils.supplier_query;
|
||||||
|
|
||||||
|
cur_frm.cscript.on_remove_attachment = function(doc) {
|
||||||
|
// refresh image list before unsetting image
|
||||||
|
refresh_field("image");
|
||||||
|
if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) {
|
||||||
|
// if the selected image is removed from attachment, unset it
|
||||||
|
cur_frm.set_value("image", "");
|
||||||
|
msgprint(wn._("Attachment removed. You may need to update: ")
|
||||||
|
+ wn.meta.get_docfield(doc.doctype, "description_html").label);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user