def _test(i):
		obj.assertEquals(i+1, frappe.db.sql("""select count(*) from `tab%s`
			where recurring_id=%s and (docstatus=1 or docstatus=0)""" % (base_doc.doctype, '%s'),
			(base_doc.recurring_id))[0][0])

		next_date = get_next_date(base_doc.get(date_field), no_of_months,
			base_doc.repeat_on_day_of_month)

		manage_recurring_documents(base_doc.doctype, next_date=next_date, commit=False)

		recurred_documents = frappe.db.sql("""select name from `tab%s`
			where recurring_id=%s and (docstatus=1 or docstatus=0) order by name desc"""
			% (base_doc.doctype, '%s'), (base_doc.recurring_id))

		obj.assertEquals(i+2, len(recurred_documents))

		new_doc = frappe.get_doc(base_doc.doctype, recurred_documents[0][0])

		for fieldname in ["is_recurring", "recurring_type",
			"repeat_on_day_of_month", "notification_email_address"]:
				obj.assertEquals(base_doc.get(fieldname),
					new_doc.get(fieldname))

		obj.assertEquals(new_doc.get(date_field), getdate(next_date))

		obj.assertEquals(new_doc.from_date,	getdate(add_months(base_doc.from_date, no_of_months)))

		if first_and_last_day:
			obj.assertEquals(new_doc.to_date, getdate(get_last_day(add_months(base_doc.to_date, no_of_months))))
		else:
			obj.assertEquals(new_doc.to_date, getdate(add_months(base_doc.to_date, no_of_months)))

		return new_doc
Example #2
0
	def _test(i):
		obj.assertEquals(i+1, frappe.db.sql("""select count(*) from `tab%s`
			where recurring_id=%s and (docstatus=1 or docstatus=0)""" % (base_doc.doctype, '%s'),
			(base_doc.recurring_id))[0][0])

		next_date = get_next_date(base_doc.get(date_field), no_of_months,
			base_doc.repeat_on_day_of_month)

		manage_recurring_documents(base_doc.doctype, next_date=next_date, commit=False)

		recurred_documents = frappe.db.sql("""select name from `tab%s`
			where recurring_id=%s and (docstatus=1 or docstatus=0) order by name desc"""
			% (base_doc.doctype, '%s'), (base_doc.recurring_id))

		obj.assertEquals(i+2, len(recurred_documents))

		new_doc = frappe.get_doc(base_doc.doctype, recurred_documents[0][0])

		for fieldname in ["is_recurring", "recurring_type",
			"repeat_on_day_of_month", "notification_email_address"]:
				obj.assertEquals(base_doc.get(fieldname),
					new_doc.get(fieldname))

		obj.assertEquals(new_doc.get(date_field), getdate(next_date))

		obj.assertEquals(new_doc.from_date,	getdate(add_months(base_doc.from_date, no_of_months)))

		if first_and_last_day:
			obj.assertEquals(new_doc.to_date, getdate(get_last_day(add_months(base_doc.to_date, no_of_months))))
		else:
			obj.assertEquals(new_doc.to_date, getdate(add_months(base_doc.to_date, no_of_months)))

		return new_doc
def execute():

	frappe.db.sql("""update `tabSales Invoice` 
				set is_recurring=1 where (docstatus=1 or docstatus=0)
				and (next_date='2016-06-25' or next_date='2016-06-26') and is_recurring=0 and name!='SINV-12230'""")
	
	manage_recurring_documents("Sales Invoice", "2016-06-25")
	manage_recurring_documents("Sales Invoice", "2016-06-26")