Add machines with day-by-day work lists for job tasks

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:43:55 +02:00
co-authored by Claude Sonnet 5.5
parent 0de0e332b2
commit aac579257a
59 changed files with 3803 additions and 1 deletions
@@ -6,14 +6,21 @@ namespace App\Modules\Jobs\Application\UseCases;
use App\Modules\Jobs\Domain\Contracts\TaskRepository;
use App\Modules\Jobs\Domain\Enums\TaskStatus;
use App\Modules\Jobs\Domain\Events\TaskCompleted;
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
use App\Modules\Shared\Application\Contracts\EventDispatcher;
use App\Modules\Shared\Application\Contracts\TransactionManager;
/**
* Changes a task's status. A task newly marked done is published as
* completed, so that e.g. a machine's work list closes its row.
*/
final class ChangeTaskStatus
{
public function __construct(
private TaskRepository $tasks,
private TransactionManager $transactions,
private EventDispatcher $events,
) {}
/**
@@ -23,8 +30,14 @@ final class ChangeTaskStatus
{
$this->transactions->run(function () use ($jobId, $taskId, $status): void {
$task = $this->tasks->findForJob($jobId, $taskId) ?? throw new TaskNotFound($jobId, $taskId);
$wasDone = $task->status() === TaskStatus::Done;
$task->changeStatus($status);
$this->tasks->save($task);
if (! $wasDone && $status === TaskStatus::Done) {
$this->events->dispatch(new TaskCompleted($taskId, $jobId));
}
});
}
}
@@ -12,6 +12,7 @@ use App\Modules\Jobs\Domain\Contracts\TaskRepository;
use App\Modules\Jobs\Domain\Entities\Task;
use App\Modules\Jobs\Domain\Enums\TaskStatus;
use App\Modules\Jobs\Domain\Events\PeopleAddedToTask;
use App\Modules\Jobs\Domain\Events\TaskCompleted;
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskReference;
use App\Modules\Jobs\Domain\Exceptions\PlanEndsBeforeStart;
@@ -49,6 +50,7 @@ final class UpdateTask
$before = self::planningInput($task);
$peopleBefore = PeopleAddedToTask::peopleOf($task);
$wasDone = $task->status() === TaskStatus::Done;
$task->changeDetails(
$data->workTypeId,
@@ -75,6 +77,10 @@ final class UpdateTask
if ($added !== null) {
$this->events->dispatch($added);
}
if (! $wasDone && $task->status() === TaskStatus::Done) {
$this->events->dispatch(new TaskCompleted($taskId, $jobId));
}
});
}
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Domain\Events;
/**
* A task was marked done (valmis). A machine's work list closes the task's
* row on it (spec 19.4).
*/
final readonly class TaskCompleted
{
public function __construct(
public int $taskId,
public int $jobId,
) {}
}
@@ -476,6 +476,7 @@ new class extends Component
<livewire:jobs::task-images :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'images-'.$task->id" />
<livewire:inventory::task-materials :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'materials-'.$task->id" />
<livewire:machines::task-machine :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'machine-'.$task->id" />
<div class="flex flex-wrap items-end gap-3">
@if ($canChangeStatus)