diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
index 8bc45f1303f..2f6ae86848c 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-05-17 17:27:49',
+ 'creation': '2012-05-16 14:07:31',
'docstatus': 0,
- 'modified': '2012-05-17 17:53:54',
+ 'modified': '2012-06-04 16:02:12',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -14,7 +14,7 @@
{
'doc_type': u'Sales Invoice',
'doctype': 'Print Format',
- 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
+ 'html': u'\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
'module': u'Accounts',
'name': '__common__',
'standard': u'Yes'
diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
index c0957980a04..114650362e5 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-05-17 17:27:49',
+ 'creation': '2012-05-16 14:07:31',
'docstatus': 0,
- 'modified': '2012-05-17 17:57:23',
+ 'modified': '2012-06-04 16:01:46',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -14,7 +14,7 @@
{
'doc_type': u'Sales Invoice',
'doctype': 'Print Format',
- 'html': u'\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
+ 'html': u'\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
'module': u'Accounts',
'name': '__common__',
'standard': u'Yes'
diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
index 01dd7654a55..77e6ef3830a 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-05-17 17:27:49',
+ 'creation': '2012-05-16 14:07:31',
'docstatus': 0,
- 'modified': '2012-05-17 17:58:06',
+ 'modified': '2012-06-04 16:01:09',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -14,7 +14,7 @@
{
'doc_type': u'Sales Invoice',
'doctype': 'Print Format',
- 'html': u'\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
+ 'html': u'\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n
\n\n\t\n\t\n
\n\n\t\n\t\n
\n',
'module': u'Accounts',
'name': '__common__',
'standard': u'Yes'
diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py
index c16bb95ef16..87b326499a5 100644
--- a/erpnext/accounts/doctype/gl_control/gl_control.py
+++ b/erpnext/accounts/doctype/gl_control/gl_control.py
@@ -485,7 +485,8 @@ def manage_recurring_invoices():
and notify the concerned people
"""
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0) = 1
- and next_date = %s and next_date <= end_date and docstatus=1 order by next_date desc""", nowdate())
+ and next_date = %s and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate(), debug=1)
+ msgprint(rv)
for d in rv:
if not webnotes.conn.sql("""select name from `tabSales Invoice` where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
@@ -503,6 +504,8 @@ def create_new_invoice(prev_rv):
new_rv.doc.posting_date = new_rv.doc.next_date
new_rv.doc.aging_date = new_rv.doc.next_date
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
+ new_rv.doc.invoice_period_from_date = get_next_month_date(new_rv.doc.invoice_period_from_date)
+ new_rv.doc.invoice_period_to_date = get_next_month_date(new_rv.doc.invoice_period_to_date)
new_rv.doc.owner = prev_rv.doc.owner
new_rv.doc.save()
@@ -512,6 +515,21 @@ def create_new_invoice(prev_rv):
return new_rv
+def get_next_month_date(dt):
+ import datetime
+ m = getdate(dt).month + 1
+ y = getdate(dt).year
+ d = getdate(dt).day
+ if m > 12:
+ m, y = 1, y+1
+ try:
+ next_month_date = datetime.date(y, m, d)
+ except:
+ import calendar
+ last_day = calendar.monthrange(y, m)[1]
+ next_month_date = datetime.date(y, m, last_day)
+ return next_month_date.strftime("%Y-%m-%d")
+
def send_notification(new_rv):
"""Notify concerned persons about recurring invoice generation"""
@@ -528,7 +546,7 @@ def send_notification(new_rv):
''' % (com, new_rv.doc.name, new_rv.doc.customer, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
- getdate(add_days(add_months(new_rv.doc.posting_date, -1), 1)).strftime("%d-%m-%Y"), 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"))
@@ -569,6 +587,6 @@ def send_notification(new_rv):
msg = hd + tbl + totals
+ msgprint(msg)
from webnotes.utils.email_lib import sendmail
- sendmail(recipients = new_rv.doc.notification_email_address.split(", "), \
- sender=new_rv.doc.owner, subject=subject, parts=[['text/plain', msg]])
+ sendmail(new_rv.doc.notification_email_address.split(", "), subject=subject, msg = msg)
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 5cf557eeaf5..620d8dd5c05 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -683,6 +683,8 @@ class DocType(TransactionBase):
def convert_into_recurring(self):
if self.doc.convert_into_recurring_invoice:
+ if not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date:
+ msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1)
self.set_next_date()
if not self.doc.recurring_id:
webnotes.conn.set(self.doc, 'recurring_id', make_autoname('RECINV/.#####'))
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
index b1b4f4b4c9c..d2439c81132 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -5,7 +5,7 @@
{
'creation': '2012-04-13 11:56:18',
'docstatus': 0,
- 'modified': '2012-05-14 14:09:43',
+ 'modified': '2012-06-04 14:40:59',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -1498,11 +1498,25 @@
{
'allow_on_submit': 1,
'depends_on': u'eval:doc.convert_into_recurring_invoice==1',
- 'description': u'The date on which recurring invoice will be stop',
+ 'description': u'Start date of the invoice period',
'doctype': u'DocField',
- 'fieldname': u'end_date',
+ 'fieldname': u'invoice_period_from_date',
'fieldtype': u'Date',
- 'label': u'End Date',
+ 'label': u'Invoice Period From Date',
+ 'no_copy': 1,
+ 'permlevel': 0,
+ 'print_hide': 1
+ },
+
+ # DocField
+ {
+ 'allow_on_submit': 1,
+ 'depends_on': u'eval:doc.convert_into_recurring_invoice==1',
+ 'description': u'End date of the invoice period',
+ 'doctype': u'DocField',
+ 'fieldname': u'invoice_period_to_date',
+ 'fieldtype': u'Date',
+ 'label': u'Invoice Period To Date',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
@@ -1559,6 +1573,20 @@
'print_hide': 1
},
+ # DocField
+ {
+ 'allow_on_submit': 1,
+ 'depends_on': u'eval:doc.convert_into_recurring_invoice==1',
+ 'description': u'The date on which recurring invoice will be stop',
+ 'doctype': u'DocField',
+ 'fieldname': u'end_date',
+ 'fieldtype': u'Date',
+ 'label': u'End Date',
+ 'no_copy': 1,
+ 'permlevel': 0,
+ 'print_hide': 1
+ },
+
# DocField
{
'doctype': u'DocField',