Add the task calendar, holidays, workflow templates and customer removal
Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Catalog\Domain\Entities;
|
||||
|
||||
use App\Modules\Catalog\Domain\Exceptions\WorkflowTemplateNeedsSteps;
|
||||
use App\Modules\Catalog\Domain\ValueObjects\CatalogName;
|
||||
use App\Modules\Catalog\Domain\ValueObjects\WorkflowStep;
|
||||
|
||||
/**
|
||||
* A workflow template (työnkulkupohja) of a work type, e.g. videokuvaus:
|
||||
* suunnittelu → kuvaus → editointi → tarkastus → toimitus. Its steps, in
|
||||
* order, become tasks of a customer job. A work type can have many
|
||||
* templates with different names. Templates are not deleted, only taken
|
||||
* out of use.
|
||||
*/
|
||||
final class WorkflowTemplate
|
||||
{
|
||||
/**
|
||||
* @param list<WorkflowStep> $steps
|
||||
*/
|
||||
private function __construct(
|
||||
private ?int $id,
|
||||
private int $workTypeId,
|
||||
private CatalogName $name,
|
||||
private bool $active,
|
||||
private array $steps,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param list<WorkflowStep> $steps
|
||||
*
|
||||
* @throws WorkflowTemplateNeedsSteps
|
||||
*/
|
||||
public static function create(int $workTypeId, CatalogName $name, array $steps): self
|
||||
{
|
||||
self::ensureSteps($steps);
|
||||
|
||||
return new self(null, $workTypeId, $name, true, $steps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<WorkflowStep> $steps
|
||||
*/
|
||||
public static function reconstitute(int $id, int $workTypeId, CatalogName $name, bool $active, array $steps): self
|
||||
{
|
||||
return new self($id, $workTypeId, $name, $active, $steps);
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function workTypeId(): int
|
||||
{
|
||||
return $this->workTypeId;
|
||||
}
|
||||
|
||||
public function name(): CatalogName
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<WorkflowStep>
|
||||
*/
|
||||
public function steps(): array
|
||||
{
|
||||
return $this->steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the name, the work type and the steps at once, as the template form saves them.
|
||||
*
|
||||
* @param list<WorkflowStep> $steps
|
||||
*
|
||||
* @throws WorkflowTemplateNeedsSteps
|
||||
*/
|
||||
public function change(int $workTypeId, CatalogName $name, array $steps): void
|
||||
{
|
||||
self::ensureSteps($steps);
|
||||
|
||||
$this->workTypeId = $workTypeId;
|
||||
$this->name = $name;
|
||||
$this->steps = $steps;
|
||||
}
|
||||
|
||||
public function activate(): void
|
||||
{
|
||||
$this->active = true;
|
||||
}
|
||||
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<WorkflowStep> $steps
|
||||
*/
|
||||
private static function ensureSteps(array $steps): void
|
||||
{
|
||||
if ($steps === []) {
|
||||
throw new WorkflowTemplateNeedsSteps;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user