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:
@@ -6,6 +6,7 @@ namespace App\Modules\Jobs\Domain\Entities;
|
||||
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
use App\Modules\Jobs\Domain\Exceptions\PlanEndsBeforeStart;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TasksNotAllowedYet;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\EstimatedHours;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\TaskTitle;
|
||||
@@ -14,6 +15,7 @@ use DateTimeImmutable;
|
||||
/**
|
||||
* A task (tehtävä) of a customer job: one step of the work, done by its
|
||||
* assignees under one work type. Time entries are recorded on tasks.
|
||||
* Its planned schedule (planned from–to) places it in the task calendar.
|
||||
*/
|
||||
final class Task
|
||||
{
|
||||
@@ -31,14 +33,18 @@ final class Task
|
||||
private ?EstimatedHours $estimatedHours,
|
||||
private array $assigneeUserIds,
|
||||
private int $createdBy,
|
||||
private ?DateTimeImmutable $plannedFrom = null,
|
||||
private ?DateTimeImmutable $plannedTo = null,
|
||||
) {
|
||||
$this->assigneeUserIds = self::normaliseIds($assigneeUserIds);
|
||||
self::checkPlan($plannedFrom, $plannedTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
*
|
||||
* @throws TasksNotAllowedYet
|
||||
* @throws PlanEndsBeforeStart
|
||||
*/
|
||||
public static function create(
|
||||
int $jobId,
|
||||
@@ -51,12 +57,14 @@ final class Task
|
||||
?EstimatedHours $estimatedHours,
|
||||
array $assigneeUserIds,
|
||||
int $createdBy,
|
||||
?DateTimeImmutable $plannedFrom = null,
|
||||
?DateTimeImmutable $plannedTo = null,
|
||||
): self {
|
||||
if (! $jobStatus->allowsTasks()) {
|
||||
throw new TasksNotAllowedYet;
|
||||
}
|
||||
|
||||
return new self(null, $jobId, $workTypeId, $title, self::text($description), $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy);
|
||||
return new self(null, $jobId, $workTypeId, $title, self::text($description), $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy, ...self::plan($plannedFrom, $plannedTo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +81,10 @@ final class Task
|
||||
?EstimatedHours $estimatedHours,
|
||||
array $assigneeUserIds,
|
||||
int $createdBy,
|
||||
?DateTimeImmutable $plannedFrom = null,
|
||||
?DateTimeImmutable $plannedTo = null,
|
||||
): self {
|
||||
return new self($id, $jobId, $workTypeId, $title, $description, $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy);
|
||||
return new self($id, $jobId, $workTypeId, $title, $description, $status, $dueOn, $estimatedHours, $assigneeUserIds, $createdBy, $plannedFrom, $plannedTo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,6 +113,25 @@ final class Task
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the planned schedule. A start without an end lasts one day;
|
||||
* null as the start removes the schedule.
|
||||
*
|
||||
* @throws PlanEndsBeforeStart
|
||||
*/
|
||||
public function schedule(?DateTimeImmutable $from, ?DateTimeImmutable $to): void
|
||||
{
|
||||
[$this->plannedFrom, $this->plannedTo] = self::plan($from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $assigneeUserIds
|
||||
*/
|
||||
public function changeAssignees(array $assigneeUserIds): void
|
||||
{
|
||||
$this->assigneeUserIds = self::normaliseIds($assigneeUserIds);
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -143,6 +172,21 @@ final class Task
|
||||
return $this->estimatedHours;
|
||||
}
|
||||
|
||||
public function plannedFrom(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->plannedFrom;
|
||||
}
|
||||
|
||||
public function plannedTo(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->plannedTo;
|
||||
}
|
||||
|
||||
public function isScheduled(): bool
|
||||
{
|
||||
return $this->plannedFrom !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
@@ -168,6 +212,33 @@ final class Task
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: ?DateTimeImmutable, 1: ?DateTimeImmutable}
|
||||
*
|
||||
* @throws PlanEndsBeforeStart
|
||||
*/
|
||||
private static function plan(?DateTimeImmutable $from, ?DateTimeImmutable $to): array
|
||||
{
|
||||
if ($from === null) {
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
$to ??= $from;
|
||||
self::checkPlan($from, $to);
|
||||
|
||||
return [$from, $to];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws PlanEndsBeforeStart
|
||||
*/
|
||||
private static function checkPlan(?DateTimeImmutable $from, ?DateTimeImmutable $to): void
|
||||
{
|
||||
if ($from !== null && $to !== null && $to < $from) {
|
||||
throw new PlanEndsBeforeStart;
|
||||
}
|
||||
}
|
||||
|
||||
private static function text(?string $value): ?string
|
||||
{
|
||||
$value = $value === null ? '' : trim($value);
|
||||
|
||||
Reference in New Issue
Block a user