Allow staff work assignments across financial years
This commit is contained in:
@@ -3158,6 +3158,28 @@ def list_employee_work_kanban(
|
||||
if page_size not in {10, 25, 50}:
|
||||
page_size = 10
|
||||
|
||||
# Staff work is cross-FY by default. The global ERP FY must not silently
|
||||
# hide an engagement assigned to this employee. financial_year is therefore
|
||||
# an explicit optional filter only.
|
||||
fy_stmt = (
|
||||
select(ClientServiceTaskInstance.financial_year)
|
||||
.where(
|
||||
ClientServiceTaskInstance.tenant_id == scope.tenant_id,
|
||||
ClientServiceTaskInstance.is_active.is_(True),
|
||||
_employee_owned_task_condition(scope),
|
||||
)
|
||||
)
|
||||
if scope.branch_id is not None:
|
||||
fy_stmt = fy_stmt.where(ClientServiceTaskInstance.branch_id == scope.branch_id)
|
||||
financial_year_options = sorted(
|
||||
{
|
||||
str(value).strip()
|
||||
for value in db.execute(fy_stmt).scalars().all()
|
||||
if str(value or "").strip()
|
||||
},
|
||||
reverse=True,
|
||||
)
|
||||
|
||||
stmt = _employee_work_task_query(
|
||||
db,
|
||||
scope,
|
||||
@@ -3309,7 +3331,7 @@ def list_employee_work_kanban(
|
||||
if not is_closed and not card["next_task_name"]:
|
||||
card["next_task_name"] = task.task_name
|
||||
|
||||
# Options are derived from the employee's assigned engagements in the active FY.
|
||||
# Options are derived from the employee's assigned engagements in the selected FY, or all assigned years when no FY filter is selected.
|
||||
period_options = sorted({str(card.get("period_label") or "").strip() for card in engagement_lookup.values() if str(card.get("period_label") or "").strip()})
|
||||
service_options = sorted({str(card.get("service_name") or "").strip() for card in engagement_lookup.values() if str(card.get("service_name") or "").strip()}, key=str.casefold)
|
||||
|
||||
@@ -3493,6 +3515,7 @@ def list_employee_work_kanban(
|
||||
"status": status_filter,
|
||||
"today": today,
|
||||
"filters": {
|
||||
"financial_year": (financial_year or "").strip(),
|
||||
"period": period_filter,
|
||||
"service": service_filter,
|
||||
"due": due_filter,
|
||||
@@ -3500,6 +3523,7 @@ def list_employee_work_kanban(
|
||||
"page_size": page_size,
|
||||
},
|
||||
"filter_options": {
|
||||
"financial_years": financial_year_options,
|
||||
"periods": period_options,
|
||||
"services": service_options,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user