Skip to content

Commit

Permalink
fix: updated filter to exclude past and current date shift assignment
Browse files Browse the repository at this point in the history
(cherry picked from commit ac81cd4)
  • Loading branch information
asmitahase authored and mergify[bot] committed Jan 20, 2025
1 parent ecc377c commit 20796be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hrms/hr/doctype/shift_type/shift_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,16 @@ def get_assigned_employees(self, from_date=None, consider_default_shift=False) -
assigned_employees = frappe.get_all("Shift Assignment", filters=filters, pluck="employee")

if consider_default_shift:
filters["start_date"] = ("=", from_date)
default_shift_employees = self.get_employees_with_default_shift(filters)
default_shift_employees = self.get_employees_with_default_shift(filters, from_date)
assigned_employees = set(assigned_employees + default_shift_employees)

# exclude inactive employees
inactive_employees = frappe.db.get_all("Employee", {"status": "Inactive"}, pluck="name")

return list(set(assigned_employees) - set(inactive_employees))

def get_employees_with_default_shift(self, filters: dict) -> list:
def get_employees_with_default_shift(self, filters: dict, from_date) -> list:
filters["start_date"] = ("<=", from_date)
default_shift_employees = frappe.get_all(
"Employee", filters={"default_shift": self.name, "status": "Active"}, pluck="name"
)
Expand All @@ -260,6 +260,7 @@ def get_employees_with_default_shift(self, filters: dict) -> list:
return []

# exclude employees from default shift list if any other valid shift assignment exists
# that starts before the attendance processing date
del filters["shift_type"]
filters["employee"] = ("in", default_shift_employees)

Expand Down

0 comments on commit 20796be

Please sign in to comment.