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
@@ -153,6 +153,82 @@ final class MachineWorkList
}
}
/**
* Puts a step of a quick sale order line on the machine's list for the
* day (spec 19.7); customer waiting rows are listed first.
*/
public function enqueueOrderStep(int $orderLineId, int $stepPosition, int $machineId, DateTimeImmutable $day): void
{
$this->transactions->run(function () use ($orderLineId, $stepPosition, $machineId, $day): void {
$open = $this->queue->openEntryForOrderLine($orderLineId);
if ($open !== null) {
$this->queue->delete($open);
}
$this->queue->save(QueueEntry::forOrderLine($machineId, $orderLineId, $stepPosition, $day, 0));
});
}
/**
* Closes an order line's open row as made.
*/
public function completeOrderLine(int $orderLineId, ?int $actorUserId): void
{
$this->transactions->run(function () use ($orderLineId, $actorUserId): void {
$entry = $this->queue->openEntryForOrderLine($orderLineId);
if ($entry !== null) {
$entry->complete($actorUserId, $this->clock->now());
$this->queue->save($entry);
}
});
}
/**
* Takes an order line's open row off its list (a cancelled order).
*/
public function removeOrderLine(int $orderLineId): void
{
$this->transactions->run(function () use ($orderLineId): void {
$entry = $this->queue->openEntryForOrderLine($orderLineId);
if ($entry !== null) {
$this->queue->delete($entry);
}
});
}
/**
* Moves an order line's open row to another machine of the same type.
*
* @throws QueueEntryNotFound
* @throws MachineNotFound
* @throws MachineInactive
* @throws MachineNotForTask when the machine is of another type
*/
public function moveOrderLine(int $entryId, int $machineId): void
{
$this->transactions->run(function () use ($entryId, $machineId): void {
$entry = $this->queue->findById($entryId) ?? throw new QueueEntryNotFound;
if (! $entry->isOrderLine()) {
throw new QueueEntryNotFound;
}
$current = $this->machines->findById($entry->machineId()) ?? throw new MachineNotFound;
$target = $this->machines->findById($machineId) ?? throw new MachineNotFound;
$target->ensureActive();
if ($target->type() !== $current->type()) {
throw new MachineNotForTask;
}
$entry->plan($machineId, $entry->plannedOn(), 0);
$this->queue->save($entry);
});
}
/**
* Closes the open row of a task that was marked done elsewhere.
*/