Files
Toiminnanohjaus/app/Modules/Jobs/Domain/Enums/JobStatus.php
T
petriandClaude Sonnet 5.5 487a7d34ba Replace the demo home page with a dashboard
Everyone sees their open tasks on an agenda, their open jobs, this
week's hours and quick links. Admin and management also get a lazily
loaded management panel: things to do, the month so far against the
previous month, jobs and late work, and everyone's workload.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-25 09:20:02 +02:00

91 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Domain\Enums;
/**
* Tila (spec 5.3). The cases are in their usual order; any status may be
* chosen. The statuses are also the columns of the job Kanban board.
*/
enum JobStatus: string
{
case Prospect = 'prospect';
case Tentative = 'tentative';
case QuoteRequest = 'quote_request';
case Order = 'order';
case InProduction = 'in_production';
case OnHold = 'on_hold';
case Done = 'done';
case Invoiced = 'invoiced';
case Billed = 'billed';
case Archived = 'archived';
/**
* Statuses set when the job is invoiced: only management and the
* job's biller may set them.
*/
public function isBillingStatus(): bool
{
return $this === self::Invoiced || $this === self::Billed;
}
/**
* Tasks can be added from a quote request on (K36), not to an archived job.
*/
public function allowsTasks(): bool
{
return ! in_array($this, [self::Prospect, self::Tentative, self::Archived], true);
}
/**
* Once a job is done its hours and expenses are locked (K21).
*/
public function locksTime(): bool
{
return in_array($this, [self::Done, self::Invoiced, self::Billed, self::Archived], true);
}
/**
* Work still to be done: a job past its due date in such a status is late.
*/
public function isOpen(): bool
{
return ! $this->locksTime();
}
/**
* @return list<self>
*/
public static function openStatuses(): array
{
return array_values(array_filter(self::cases(), fn (self $status): bool => $status->isOpen()));
}
/**
* Whether moving from this status to $to opens the lock on hours and expenses.
*/
public function unlocksTo(self $to): bool
{
return $this->locksTime() && ! $to->locksTime();
}
/**
* The Kanban columns: every status except archived.
*
* @return list<self>
*/
public static function kanbanStatuses(): array
{
$statuses = [];
foreach (self::cases() as $status) {
if ($status !== self::Archived) {
$statuses[] = $status;
}
}
return $statuses;
}
}