fix: holiday update in tests

This commit is contained in:
pateljannat 2020-12-22 19:40:41 +05:30
parent 4ebee5014e
commit 6cf018c762
2 changed files with 14 additions and 10 deletions

View File

@ -81,18 +81,12 @@ class Project(Document):
def calculate_start_date(self, task_details):
self.start_date = add_days(self.expected_start_date, task_details.start)
self.start_date = self.update_if_holiday(self.start_date)
self.start_date = update_if_holiday(self.holiday_list, self.start_date)
return self.start_date
def calculate_end_date(self, task_details):
self.end_date = add_days(self.start_date, task_details.duration)
return self.update_if_holiday(self.end_date)
def update_if_holiday(self, date):
holiday_list = self.holiday_list or get_holiday_list()
while is_holiday(holiday_list, date):
date = add_days(date, 1)
return date
return update_if_holiday(self.holiday_list, self.end_date)
def dependency_mapping(self, template_tasks, project_tasks):
for template_task in template_tasks:
@ -547,3 +541,9 @@ def set_project_status(project, status):
project.status = status
project.save()
def update_if_holiday(holiday_list, date):
holiday_list = holiday_list or get_holiday_list()
while is_holiday(holiday_list, date):
date = add_days(date, 1)
return date

View File

@ -8,7 +8,7 @@ test_records = frappe.get_test_records('Project')
test_ignore = ["Sales Order"]
from erpnext.projects.doctype.project_template.test_project_template import make_project_template
from erpnext.projects.doctype.project.project import set_project_status
from erpnext.projects.doctype.project.project import set_project_status, update_if_holiday
from erpnext.projects.doctype.task.test_task import create_task
from frappe.utils import getdate, nowdate, add_days
@ -128,4 +128,8 @@ def task_exists(subject):
return frappe.get_doc("Task", result[0].name)
def calculate_end_date(project, start, duration):
return getdate(add_days(project.expected_start_date, start + duration))
start = add_days(project.expected_start_date, start)
start = update_if_holiday(project.holiday_list, start)
end = add_days(start, duration)
end = update_if_holiday(project.holiday_list, end)
return getdate(end)