Skip to content

Commit

Permalink
fix: creation of neverending shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Jun 17, 2024
1 parent 48ceb27 commit 587868b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hrms/api/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def break_shift(assignment: str | ShiftAssignment, date: str) -> None:

@frappe.whitelist()
def insert_shift(
employee: str, company: str, shift_type: str, start_date: str, end_date: str, status: str
employee: str, company: str, shift_type: str, start_date: str, end_date: str | None, status: str
) -> None:
filters = {
"doctype": "Shift Assignment",
Expand All @@ -141,7 +141,9 @@ def insert_shift(
"status": status,
}
prev_shift = frappe.db.exists(dict({"end_date": add_days(start_date, -1)}, **filters))
next_shift = frappe.db.exists(dict({"start_date": add_days(end_date, 1)}, **filters))
next_shift = (
frappe.db.exists(dict({"start_date": add_days(end_date, 1)}, **filters)) if end_date else None
)

if prev_shift:
if next_shift:
Expand Down

0 comments on commit 587868b

Please sign in to comment.