feat: bootstrap JOBcard CRM foundation

This commit is contained in:
Marco0300
2026-09-01 18:54:47 +02:00
commit 480494c5ed
31 changed files with 1300 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
function calculate_sla_usage(float $allocatedHours, array $hours): array
{
$used = round(array_sum(array_map(static fn ($value): float => max(0.0, (float)$value), $hours)), 2);
$remaining = round(max(0.0, $allocatedHours - $used), 2);
$percentage = $allocatedHours > 0 ? round(($used / $allocatedHours) * 100, 2) : ($used > 0 ? 100.0 : 0.0);
$status = $used > $allocatedHours ? 'exceeded' : ($percentage >= 90 ? 'critical' : ($percentage >= 75 ? 'warning' : 'within_limit'));
return ['used' => $used, 'remaining' => $remaining, 'percentage' => $percentage, 'status' => $status];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Domain\SLA;
final class SlaThresholdClassifier
{
public const WITHIN_LIMIT = 'within_limit';
public const WARNING = 'warning';
public const CRITICAL = 'critical';
public const EXCEEDED = 'exceeded';
public function classify(float $usedHours, float $allocatedHours): string
{
if ($allocatedHours < 0) throw new \InvalidArgumentException('Allocated hours must not be negative.');
$usedHours = max(0.0, $usedHours);
if ($allocatedHours === 0.0) return $usedHours > 0.0 ? self::EXCEEDED : self::WITHIN_LIMIT;
if ($usedHours > $allocatedHours) return self::EXCEEDED;
$percentage = ($usedHours / $allocatedHours) * 100;
return $percentage >= 90.0 ? self::CRITICAL : ($percentage >= 75.0 ? self::WARNING : self::WITHIN_LIMIT);
}
public function percentage(float $usedHours, float $allocatedHours): float
{
if ($allocatedHours < 0) throw new \InvalidArgumentException('Allocated hours must not be negative.');
$usedHours = max(0.0, $usedHours);
return $allocatedHours > 0.0 ? round(($usedHours / $allocatedHours) * 100, 2) : ($usedHours > 0.0 ? 100.0 : 0.0);
}
}