Synchronise approved AQMM across staff and review boards
This commit is contained in:
@@ -34,6 +34,7 @@ from app.modules.services.execution import (
|
||||
apply_task_checklist_response,
|
||||
recalculate_task_aqmm_status,
|
||||
submit_task_for_review,
|
||||
synchronise_approved_engagement_acceptance_tasks,
|
||||
)
|
||||
|
||||
EMPLOYEE_STATUS = ["active", "inactive", "relieved"]
|
||||
@@ -4077,6 +4078,31 @@ def get_employee_engagement_work_board(
|
||||
document, checklist, AQMM and lock controls remain the source of truth.
|
||||
"""
|
||||
today = date.today()
|
||||
|
||||
# Cross-view AQMM self-heal: an engagement that has already passed the
|
||||
# engagement-level AQMM acceptance must never continue to show the four
|
||||
# duplicated setup rows as pending in the Staff work board. Reconcile the
|
||||
# persisted execution rows before the board queries them. The synchroniser
|
||||
# is deliberately limited to untouched acceptance/team/independence/KYC
|
||||
# setup rows and does not modify normal execution history, evidence or rework.
|
||||
subscription_stmt = select(ClientServiceSubscription).where(
|
||||
ClientServiceSubscription.id == int(engagement_id),
|
||||
ClientServiceSubscription.tenant_id == int(scope.tenant_id),
|
||||
)
|
||||
if scope.branch_id is not None:
|
||||
subscription_stmt = subscription_stmt.where(
|
||||
ClientServiceSubscription.branch_id == int(scope.branch_id)
|
||||
)
|
||||
subscription_for_sync = db.execute(subscription_stmt).scalar_one_or_none()
|
||||
if subscription_for_sync is not None:
|
||||
repaired = synchronise_approved_engagement_acceptance_tasks(
|
||||
db,
|
||||
subscription=subscription_for_sync,
|
||||
actor_user_id=int(scope.own_user_id),
|
||||
)
|
||||
if repaired:
|
||||
db.commit()
|
||||
|
||||
assigned_stmt = _employee_work_task_query(
|
||||
db, scope, assigned_only=True, financial_year=financial_year
|
||||
).where(ClientServiceTaskInstance.subscription_id == engagement_id)
|
||||
|
||||
Reference in New Issue
Block a user