feat: complete jobcard management workflows and UI
This commit is contained in:
@@ -20,9 +20,14 @@ final class SlaReport
|
||||
ReportAudience::validate($audience);
|
||||
$filters = $this->filters ?? new ReportFilters();
|
||||
$mapper = $this->mapper ?? new ReportDataMapper();
|
||||
// SLA status is derived below; apply all source-field filters first and
|
||||
// apply the SLA filter to the computed status after usage is calculated.
|
||||
$sourceFilters = $filters->sla === null
|
||||
? $filters
|
||||
: new ReportFilters($filters->clientId, $filters->dateFrom, $filters->dateTo, $filters->technicianId, $filters->status, $filters->priority);
|
||||
$rows = [];
|
||||
foreach ($agreements as $agreement) {
|
||||
if (!$filters->matches($agreement)) continue;
|
||||
if (!$sourceFilters->matches($agreement)) continue;
|
||||
$allocated = max(0.0, (float)($agreement['allocated_hours'] ?? 0));
|
||||
$used = 0.0;
|
||||
foreach ((array)($agreement['hours'] ?? []) as $hours) $used += max(0.0, (float)$hours);
|
||||
@@ -30,6 +35,7 @@ final class SlaReport
|
||||
$remaining = round(max(0.0, $allocated - $used), 2);
|
||||
$percentage = $allocated > 0 ? round(($used / $allocated) * 100, 2) : ($used > 0 ? 100.0 : 0.0);
|
||||
$status = $used > $allocated ? 'exceeded' : ($percentage >= 90 ? 'critical' : ($percentage >= 75 ? 'warning' : 'within_limit'));
|
||||
if ($filters->sla !== null && $filters->sla !== $status) continue;
|
||||
$record = [
|
||||
'client_id' => (int)($agreement['client_id'] ?? 0),
|
||||
'client_name' => (string)($agreement['client_name'] ?? ''),
|
||||
|
||||
Reference in New Issue
Block a user