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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user