Make quick sale products on machines as orders paid when ready

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 17:11:54 +02:00
co-authored by Claude Sonnet 5.5
parent 920fecdeb2
commit 38b8075a9c
58 changed files with 3435 additions and 26 deletions
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Modules\Machines\Domain\Contracts;
use App\Modules\Machines\Domain\ValueObjects\ProductionStep;
interface ProductionProcessRepository
{
/**
* Replaces the product's production process; no steps removes it.
*
* @param list<ProductionStep> $steps
*/
public function replace(int $productId, array $steps): void;
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Modules\Machines\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
final class InvalidProductionStep extends DomainException
{
public function __construct()
{
parent::__construct('A production step needs a work type, a duration of 0-24 h in quarters and materials with positive quantities.');
}
}
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Modules\Machines\Domain\Exceptions;
use App\Modules\Shared\Domain\Exceptions\DomainException;
final class ProductionMachineNotAllowed extends DomainException
{
public function __construct()
{
parent::__construct('The machine of a production step must be in use and belong to the service unit of the work type of the product.');
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Modules\Machines\Domain\ValueObjects;
use App\Modules\Machines\Domain\Exceptions\InvalidProductionStep;
/**
* A step of a product's production process (spec 19.7): made on a machine
* or by hand ($machineId null, e.g. finishing or lamination), taking
* $durationQuarters per piece on $workTypeId, and using materials per
* piece (stock item ids with quantities in thousandths). A step by hand
* holds the auxiliary materials no machine needs.
*/
final readonly class ProductionStep
{
public const int MAX_QUARTERS = 96;
/**
* @param list<array{stockItemId: int, quantityMilli: int}> $materials
*
* @throws InvalidProductionStep
*/
public function __construct(
public ?int $machineId,
public int $durationQuarters,
public int $workTypeId,
public array $materials = [],
) {
if ($durationQuarters < 0 || $durationQuarters > self::MAX_QUARTERS || $workTypeId < 1) {
throw new InvalidProductionStep;
}
foreach ($materials as $material) {
if ($material['stockItemId'] < 1 || $material['quantityMilli'] < 1) {
throw new InvalidProductionStep;
}
}
}
}