From b0f6dde7bfe9801673774a70c9a41c548623879b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 14 Dec 2012 16:23:33 +0530 Subject: [PATCH 1/5] permission control: get parent doctype doclist in get permissions --- setup/doctype/permission_control/permission_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/doctype/permission_control/permission_control.py b/setup/doctype/permission_control/permission_control.py index 8162c39c56..cb0575d938 100644 --- a/setup/doctype/permission_control/permission_control.py +++ b/setup/doctype/permission_control/permission_control.py @@ -51,7 +51,7 @@ class DocType: # ------------------------------------------------------------------- def get_permissions(self,doctype): import webnotes.model.doctype - doclist = webnotes.model.doctype.get(doctype) + doclist = webnotes.model.doctype.get(doctype).get_parent_doclist() ptype = [{ 'role': perm.role, From ff4e996a8fee071f91db80d544dd3f8eed641ab1 Mon Sep 17 00:00:00 2001 From: webnotes Date: Sat, 15 Dec 2012 17:51:24 +0530 Subject: [PATCH 2/5] fixed syntax error in recurring sales invoice code --- accounts/doctype/sales_invoice/sales_invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index a146e932ef..ef6f66ceec 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -719,7 +719,7 @@ def get_next_date(dt, mcount, day=None): if not day: day = getdate(dt).day if month > 12: - month, year = m-12, y+1 + month, year = month-12, year+1 try: next_month_date = datetime.date(year, month, day) except: @@ -909,4 +909,4 @@ def get_bank_cash_account(mode_of_payment): webnotes.msgprint("Default Bank / Cash Account not set in Mode of Payment: %s. Please add a Default Account in Mode of Payment master." % mode_of_payment) return { "cash_bank_account": val - } \ No newline at end of file + } From 5f17be83644cffe7978f05237e255e8fc1613246 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Sat, 15 Dec 2012 18:38:18 +0530 Subject: [PATCH 3/5] added payment link in expiry banner --- public/js/startup.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/js/startup.js b/public/js/startup.js index a5ed4c4416..1b9e3ea795 100644 --- a/public/js/startup.js +++ b/public/js/startup.js @@ -57,17 +57,18 @@ erpnext.startup.start = function() { var today = dateutil.str_to_obj(wn.boot.server_date); var expires_on = dateutil.str_to_obj(wn.boot.expires_on); var diff = dateutil.get_diff(expires_on, today); + var payment_link = "See Payment Options."; if (0 <= diff && diff <= 15) { var expiry_string = diff==0 ? "today" : repl("in %(diff)s day(s)", { diff: diff }); $('header').append(repl('
\ Your ERPNext subscription will expire %(expiry_string)s. \ Please renew your subscription to continue using ERPNext \ - (and remove this annoying banner). \ -
', { expiry_string: expiry_string })); + (and remove this annoying banner). %(payment_link)s\ + ', { expiry_string: expiry_string, payment_link: payment_link })); } else if (diff < 0) { $('header').append(repl('
\ - This ERPNext subscription has expired. \ -
', { expiry_string: expiry_string })); + This ERPNext subscription has expired. %(payment_link)s\ + ', { expiry_string: expiry_string, payment_link: payment_link })); } } erpnext.set_about(); @@ -179,4 +180,4 @@ erpnext.setup_mousetrap = function() { // start $(document).bind('startup', function() { erpnext.startup.start(); -}); \ No newline at end of file +}); From 506f7a3f7bba9d82d17f2e285e7786866c62deba Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 17 Dec 2012 10:49:20 +0530 Subject: [PATCH 4/5] fixed null issue in recurring invoice --- accounts/doctype/sales_invoice/sales_invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index a146e932ef..49b044f4e1 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -822,7 +822,9 @@ def send_notification(new_rv): ''' for d in getlist(new_rv.doclist, 'entries'): - tbl += '' + d.item_code +'' + d.description+'' + cstr(d.qty) +'' + cstr(d.basic_rate) +'' + cstr(d.amount) +'' + tbl += '' + cstr(d.item_code) +'' + cstr(d.description) + \ + '' + cstr(d.qty) +'' + cstr(d.basic_rate) + \ + '' + cstr(d.amount) +'' tbl += '' totals =''' From 49415d90fc15a3ae71f7d8ad967587702bb3a947 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 17 Dec 2012 11:09:08 +0530 Subject: [PATCH 5/5] create recurring invoices on any date --- .../doctype/sales_invoice/sales_invoice.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 7dcaa4d39f..ebc6dd3515 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -728,24 +728,25 @@ def get_next_date(dt, mcount, day=None): next_month_date = datetime.date(year, month, last_day) 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 and notify the concerned people """ + next_date = next_date or nowdate() recurring_invoices = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1 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 = [] for ref_invoice, recurring_id in recurring_invoices: if not webnotes.conn.sql("""select name from `tabSales Invoice` where posting_date=%s and recurring_id=%s and docstatus=1""", - (nowdate(), recurring_id)): + (next_date, recurring_id)): try: 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) webnotes.conn.commit() except Exception, e: @@ -765,19 +766,17 @@ def manage_recurring_invoices(): exception_message = "\n\n".join([cstr(d) for d in exception_list]) raise Exception, exception_message -def make_new_invoice(ref_wrapper): +def make_new_invoice(ref_wrapper, posting_date): from webnotes.model.wrapper import clone new_invoice = clone(ref_wrapper) mcount = month_map[ref_wrapper.doc.recurring_type] - - today = nowdate() - - new_invoice.doc.fields.update({ - "posting_date": today, - "aging_date": today, - "due_date": add_days(today, cint(date_diff(ref_wrapper.doc.due_date, + new_invoice.doc.fields.update({ + "posting_date": posting_date, + "aging_date": posting_date, + + "due_date": add_days(posting_date, cint(date_diff(ref_wrapper.doc.due_date, ref_wrapper.doc.posting_date))), "invoice_period_from_date": \