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:
2026-11-24 18:13:11 +02:00
co-authored by Claude Opus 5.5
parent dfe4941f02
commit b4f2f1cfaa
134 changed files with 6930 additions and 45 deletions
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Contracts;
use App\Modules\Catalog\Domain\Entities\WorkflowTemplate;
interface WorkflowTemplateRepository
{
public function findById(int $id): ?WorkflowTemplate;
/**
* Inserts a new template or updates a stored one, replacing its steps,
* and returns the stored template.
*/
public function save(WorkflowTemplate $template): WorkflowTemplate;
/**
* Whether another template of the work type than $exceptId has this name, ignoring case.
*/
public function isNameTaken(int $workTypeId, string $name, ?int $exceptId = null): bool;
}
@@ -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;
}
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
/**
* A step title is empty or longer than 255 characters. $stepIndex (from 0)
* tells which step, when the caller knows it.
*/
final class InvalidWorkflowStepTitle extends DomainException
{
public function __construct(public readonly ?int $stepIndex = null)
{
parent::__construct('A workflow step title must be 1–255 characters long.');
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
/**
* A step's own work type is not in use, or belongs neither to the template
* work type's service unit nor to the shared unit. $stepIndex counts from 0.
*/
final class WorkflowStepWorkTypeNotAllowed extends DomainException
{
public function __construct(public readonly int $stepIndex)
{
parent::__construct("The work type of workflow step {$stepIndex} is not allowed.");
}
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
final class WorkflowTemplateNameTaken extends DomainException
{
public function __construct()
{
parent::__construct('The work type already has a workflow template with this name.');
}
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
final class WorkflowTemplateNeedsSteps extends DomainException
{
public function __construct()
{
parent::__construct('A workflow template needs at least one step.');
}
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
final class WorkflowTemplateNotFound extends DomainException
{
public function __construct(public readonly int $id)
{
parent::__construct("Workflow template {$id} was not found.");
}
}
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\ValueObjects;
/**
* One step of a workflow template. A task is made of it: the title, the
* description and the work type, which is the template's own when
* $workTypeId is null.
*/
final readonly class WorkflowStep
{
public ?string $description;
public function __construct(
public WorkflowStepTitle $title,
?string $description = null,
public ?int $workTypeId = null,
) {
$description = $description === null ? '' : trim($description);
$this->description = $description === '' ? null : $description;
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\ValueObjects;
use App\Modules\Catalog\Domain\Exceptions\InvalidWorkflowStepTitle;
/**
* Title of a workflow step, e.g. "Editointi". It becomes a task title, so
* its length limit is the same as a task title's.
*/
final readonly class WorkflowStepTitle
{
public const int MAX_LENGTH = 255;
public string $value;
public function __construct(string $value)
{
$value = trim(preg_replace('/\s+/u', ' ', $value) ?? $value);
if ($value === '' || mb_strlen($value) > self::MAX_LENGTH) {
throw new InvalidWorkflowStepTitle;
}
$this->value = $value;
}
}