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,21 @@
<?php
declare(strict_types=1);
namespace App\Modules\Sales\Application\DTOs;
/**
* A quick sale order as entered: quantities by product id, an optional
* customer and an optional name to call the customer by.
*/
final readonly class OrderData
{
/**
* @param array<int, int> $quantities
*/
public function __construct(
public array $quantities,
public ?int $customerId = null,
public ?string $customerName = null,
) {}
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Modules\Sales\Application\DTOs;
/**
* A line of a quick sale order with its production: the steps (machine ids,
* null for a step by hand), the step now being made ($currentStep, from 0;
* null when made or with no process) and its materials per piece.
*/
final readonly class OrderLineSummary
{
/**
* @param list<?int> $stepMachineIds
* @param list<array{stockItemId: int, quantityMilli: int}> $currentMaterials
*/
public function __construct(
public int $id,
public int $orderId,
public int $pickupNumber,
public ?string $customerName,
public string $orderedAt,
public string $productName,
public int $quantity,
public int $totalCents,
public array $stepMachineIds,
public ?int $currentStep,
public array $currentMaterials,
public bool $isMade,
) {}
public function hasProduction(): bool
{
return $this->stepMachineIds !== [];
}
public function currentMachineId(): ?int
{
return $this->currentStep === null ? null : $this->stepMachineIds[$this->currentStep];
}
}
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace App\Modules\Sales\Application\DTOs;
/**
* A quick sale order sent to production: its id, the day's pickup number
* and the total with VAT.
*/
final readonly class OrderResult
{
public function __construct(
public int $orderId,
public int $pickupNumber,
public int $totalCents,
) {}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Modules\Sales\Application\DTOs;
use App\Modules\Sales\Domain\Enums\OrderStatus;
/**
* A quick sale order as listed. $orderedAt is "Y-m-d H:i" in the company's
* time zone; $saleId is the sale that paid it.
*/
final readonly class OrderSummary
{
/**
* @param list<OrderLineSummary> $lines
*/
public function __construct(
public int $id,
public int $pickupNumber,
public string $orderedOn,
public string $orderedAt,
public string $sellerName,
public ?int $customerId,
public ?string $customerName,
public OrderStatus $status,
public ?int $saleId,
public int $totalCents,
public array $lines,
) {}
public function isPaid(): bool
{
return $this->saleId !== null;
}
/**
* Whether making has not started on any line, so the order can still be
* cancelled without anything recorded.
*/
public function isOpen(): bool
{
return $this->status === OrderStatus::InProduction || $this->status === OrderStatus::Ready;
}
}