Fix timezone handling in employee engagement SLA

This commit is contained in:
A R R R Associates
2026-08-07 15:45:54 +05:30
parent a512aec512
commit 84443f5b36
+10 -2
View File
@@ -3263,8 +3263,16 @@ def _engagement_sla(subscription: ClientServiceSubscription | None, tasks: list[
if due_date is None:
dates = [getattr(task, "internal_target_date", None) for task in tasks if getattr(task, "internal_target_date", None)]
due_date = max(dates) if dates else None
started_dates = [getattr(task, "started_at_utc", None) for task in tasks if getattr(task, "started_at_utc", None)]
created_at = getattr(subscription, "created_at_utc", None) if subscription is not None else None
started_dates = [
_as_utc_aware(getattr(task, "started_at_utc", None))
for task in tasks
if getattr(task, "started_at_utc", None)
]
created_at = (
_as_utc_aware(getattr(subscription, "created_at_utc", None))
if subscription is not None
else None
)
anchor = min(started_dates) if started_dates else created_at
age_days = max((datetime.now(timezone.utc) - anchor).days, 0) if anchor else 0
days_remaining = (due_date - today).days if due_date else None