- Time entries store who approved them and when. Approved hours are locked: cells, task page edits and removals are refused. - "Hyväksy viikko" in the weekly view approves the user's own week; subcontractors' hours are approved by management. - Management gets an approval page (unapproved weeks by person, recently approved weeks) and can open anyone's week read-only to approve it or cancel its approval, which only management may do. - Only management may move a done job back to an earlier status, which opens the lock on its hours and expenses; the history marks it. - The Clock contract gets now() for approval times. Co-Authored-By: Claude Opus 5.5 <[email protected]>
75 lines
1.8 KiB
PHP
75 lines
1.8 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);
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
}
|