Record used material on tasks and suggest workflow steps' default materials
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -15,6 +15,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\TaskMaterialsSuggested;
|
||||
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidEstimatedHours;
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskReference;
|
||||
@@ -31,7 +32,8 @@ use App\Modules\Users\Application\Contracts\Clock;
|
||||
* assignee entered for it (without an entry, the adder is the assignee).
|
||||
* When asked, a task with a due date is scheduled to end on it, booked
|
||||
* backwards from the due date (TaskPlanner::planBackwards). The tasks are
|
||||
* copies, so later changes to the template do not touch them.
|
||||
* copies, so later changes to the template do not touch them. A step's
|
||||
* default materials are published as suggestions for its task.
|
||||
*/
|
||||
final class AddTasksFromWorkflowTemplate
|
||||
{
|
||||
@@ -98,6 +100,14 @@ final class AddTasksFromWorkflowTemplate
|
||||
if ($added !== null) {
|
||||
$this->events->dispatch($added);
|
||||
}
|
||||
|
||||
if ($step->materials !== []) {
|
||||
$this->events->dispatch(new TaskMaterialsSuggested(
|
||||
(int) $task->id(),
|
||||
$jobId,
|
||||
array_map(fn ($material): array => ['stockItemId' => $material->stockItemId, 'quantityMilli' => $material->quantityMilli], $step->materials),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return new TemplateTasksResult(count($template->steps), $scheduled, $late);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Events;
|
||||
|
||||
/**
|
||||
* A task was made of a workflow step with default materials (spec 19.4):
|
||||
* the stock items and quantities (in thousandths) suggested to be recorded
|
||||
* as used on the task once its assignee confirms them.
|
||||
*/
|
||||
final readonly class TaskMaterialsSuggested
|
||||
{
|
||||
/**
|
||||
* @param list<array{stockItemId: int, quantityMilli: int}> $materials
|
||||
*/
|
||||
public function __construct(
|
||||
public int $taskId,
|
||||
public int $jobId,
|
||||
public array $materials,
|
||||
) {}
|
||||
}
|
||||
@@ -475,6 +475,7 @@ new class extends Component
|
||||
<livewire:jobs::task-comments :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'comments-'.$task->id" />
|
||||
|
||||
<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" />
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
@if ($canChangeStatus)
|
||||
|
||||
Reference in New Issue
Block a user