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:
@@ -8,9 +8,11 @@ use App\Modules\Catalog\Application\DTOs\WorkflowStepData;
|
||||
use App\Modules\Catalog\Domain\Contracts\ServiceUnitRepository;
|
||||
use App\Modules\Catalog\Domain\Contracts\WorkTypeRepository;
|
||||
use App\Modules\Catalog\Domain\Entities\WorkType;
|
||||
use App\Modules\Catalog\Domain\Exceptions\InvalidWorkflowStepMaterial;
|
||||
use App\Modules\Catalog\Domain\Exceptions\InvalidWorkflowStepTitle;
|
||||
use App\Modules\Catalog\Domain\Exceptions\WorkflowStepWorkTypeNotAllowed;
|
||||
use App\Modules\Catalog\Domain\ValueObjects\WorkflowStep;
|
||||
use App\Modules\Catalog\Domain\ValueObjects\WorkflowStepMaterial;
|
||||
use App\Modules\Catalog\Domain\ValueObjects\WorkflowStepTitle;
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,7 @@ final class WorkflowStepBuilder
|
||||
* @return list<WorkflowStep>
|
||||
*
|
||||
* @throws InvalidWorkflowStepTitle with the index of the step
|
||||
* @throws InvalidWorkflowStepMaterial with the indexes of the step and the material
|
||||
*/
|
||||
public function build(array $input): array
|
||||
{
|
||||
@@ -40,7 +43,17 @@ final class WorkflowStepBuilder
|
||||
throw new InvalidWorkflowStepTitle($index);
|
||||
}
|
||||
|
||||
$steps[] = new WorkflowStep($title, $step->description, $step->workTypeId);
|
||||
$materials = [];
|
||||
|
||||
foreach ($step->materials as $materialIndex => $material) {
|
||||
try {
|
||||
$materials[] = WorkflowStepMaterial::parse($material['stockItemId'], $material['quantity']);
|
||||
} catch (InvalidWorkflowStepMaterial) {
|
||||
throw new InvalidWorkflowStepMaterial($index, $materialIndex);
|
||||
}
|
||||
}
|
||||
|
||||
$steps[] = new WorkflowStep($title, $step->description, $step->workTypeId, $materials);
|
||||
}
|
||||
|
||||
return $steps;
|
||||
|
||||
Reference in New Issue
Block a user