[fix] Recurring test case fixed for the 1st day of the month
This commit is contained in:
parent
70885f63a5
commit
c4edcf1532
@ -85,12 +85,9 @@ def make_new_document(ref_wrapper, date_field, posting_date):
|
|||||||
|
|
||||||
# get last day of the month to maintain period if the from date is first day of its own month
|
# get last day of the month to maintain period if the from date is first day of its own month
|
||||||
# and to date is the last day of its own month
|
# and to date is the last day of its own month
|
||||||
if (cstr(get_first_day(ref_wrapper.from_date)) == \
|
if (cstr(get_first_day(ref_wrapper.from_date)) == cstr(ref_wrapper.from_date)) and \
|
||||||
cstr(ref_wrapper.from_date)) and \
|
(cstr(get_last_day(ref_wrapper.to_date)) == cstr(ref_wrapper.to_date)):
|
||||||
(cstr(get_last_day(ref_wrapper.to_date)) == \
|
to_date = get_last_day(get_next_date(ref_wrapper.to_date, mcount))
|
||||||
cstr(ref_wrapper.to_date)):
|
|
||||||
to_date = get_last_day(get_next_date(ref_wrapper.to_date,
|
|
||||||
mcount))
|
|
||||||
else:
|
else:
|
||||||
to_date = get_next_date(ref_wrapper.to_date, mcount)
|
to_date = get_next_date(ref_wrapper.to_date, mcount)
|
||||||
|
|
||||||
|
@ -5,11 +5,10 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import frappe.permissions
|
import frappe.permissions
|
||||||
from erpnext.controllers.recurring_document import date_field_map
|
from erpnext.controllers.recurring_document import date_field_map
|
||||||
from frappe.utils import getdate
|
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
|
||||||
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
def test_recurring_document(obj, test_records):
|
def test_recurring_document(obj, test_records):
|
||||||
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
|
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
|
||||||
frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1)
|
frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1)
|
||||||
today = nowdate()
|
today = nowdate()
|
||||||
base_doc = frappe.copy_doc(test_records[0])
|
base_doc = frappe.copy_doc(test_records[0])
|
||||||
@ -38,14 +37,15 @@ def test_recurring_document(obj, test_records):
|
|||||||
_test_recurring_document(obj, doc1, date_field, True)
|
_test_recurring_document(obj, doc1, date_field, True)
|
||||||
|
|
||||||
# monthly without a first and last day period
|
# monthly without a first and last day period
|
||||||
doc2 = frappe.copy_doc(base_doc)
|
if getdate(today).day != 1:
|
||||||
doc2.update({
|
doc2 = frappe.copy_doc(base_doc)
|
||||||
"from_date": today,
|
doc2.update({
|
||||||
"to_date": add_to_date(today, days=30)
|
"from_date": today,
|
||||||
})
|
"to_date": add_to_date(today, days=30)
|
||||||
doc2.insert()
|
})
|
||||||
doc2.submit()
|
doc2.insert()
|
||||||
_test_recurring_document(obj, doc2, date_field, False)
|
doc2.submit()
|
||||||
|
_test_recurring_document(obj, doc2, date_field, False)
|
||||||
|
|
||||||
# quarterly
|
# quarterly
|
||||||
doc3 = frappe.copy_doc(base_doc)
|
doc3 = frappe.copy_doc(base_doc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user