Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def set_resolution_date(self, doc: Document):
doc.resolution_date = None
doc.resolution_time = None
return
doc.resolution_date = now_datetime()
doc.resolution_date = frappe.utils.nowdate()
start_at = doc.service_level_agreement_creation
end_at = doc.resolution_date
time_took = self.calc_elapsed_time(start_at, end_at)
Expand Down Expand Up @@ -355,11 +355,21 @@ def calc_time(
current_datetime, current_date
)
start_time = max(
current_workday_doc.start_time.total_seconds(), current_time_in_seconds
timedelta(
hours=current_workday_doc.start_time.hour,
minutes=current_workday_doc.start_time.minute,
seconds=current_workday_doc.start_time.second,
).total_seconds(),
Comment on lines +358 to +362
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start_time is a datetime.time field, it won't have total_seconds(), only datetime.timedelta has that.

current_time_in_seconds,
)
till_start_time = max(start_time - current_time_in_seconds, 0)
end_time = max(
current_workday_doc.end_time.total_seconds(), current_time_in_seconds
timedelta(
hours=current_workday_doc.end_time.hour,
minutes=current_workday_doc.end_time.minute,
seconds=current_workday_doc.end_time.second,
).total_seconds(),
current_time_in_seconds,
)
time_left = max(end_time - start_time, 0)
if not time_left:
Expand Down
10 changes: 5 additions & 5 deletions helpdesk/setup/install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import date

import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
Expand Down Expand Up @@ -132,14 +132,14 @@ def add_default_sla():
def add_default_holiday_list():
if frappe.db.exists("HD Service Holiday List", "Default"):
return

year = date.today().year
frappe.get_doc(
{
"doctype": "HD Service Holiday List",
"holiday_list_name": "Default",
"from_date": datetime.strptime(f"Jan 1 {datetime.now().year}", "%b %d %Y"),
"to_date": datetime.strptime(
f"Jan 1 {datetime.now().year + 1}", "%b %d %Y"
),
"from_date": date(year, 1, 1),
"to_date": date(year + 1, 1, 1),
}
).insert()

Expand Down
Loading