fix: consider holiday list for SLA

This commit is contained in:
Shariq Ansari 2024-01-26 14:16:49 +05:30
parent 6bdcc08a23
commit d2d1b09c10

View File

@ -114,7 +114,7 @@ class CRMServiceLevelAgreement(Document):
):
res = get_datetime(start_at)
time_needed = duration_seconds
holidays = []
holidays = self.get_holidays()
weekdays = get_weekdays()
workdays = self.get_workdays()
while time_needed:
@ -214,3 +214,12 @@ class CRMServiceLevelAgreement(Document):
start_time, end_time = working_hours.get(day_of_week, (0, 0))
date_time = timedelta(hours=date_time.hour, minutes=date_time.minute, seconds=date_time.second)
return start_time <= date_time < end_time
def get_holidays(self):
res = []
if not self.holiday_list:
return res
holiday_list = frappe.get_doc("CRM Holiday List", self.holiday_list)
for row in holiday_list.holidays:
res.append(row.date)
return res