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
@@ -32,6 +32,7 @@ final class QuickSale
private array $lines,
private ?int $creditsSaleId,
private ?EmailAddress $receiptEmail = null,
private ?int $orderId = null,
) {
if ($lines === []) {
throw new QuickSaleEmpty;
@@ -44,9 +45,9 @@ final class QuickSale
*
* @throws QuickSaleEmpty
*/
public static function sell(int $sellerId, ?int $customerId, PaymentMethod $paymentMethod, array $lines, DateTimeImmutable $soldAt, DateTimeImmutable $soldOn, ?EmailAddress $receiptEmail = null): self
public static function sell(int $sellerId, ?int $customerId, PaymentMethod $paymentMethod, array $lines, DateTimeImmutable $soldAt, DateTimeImmutable $soldOn, ?EmailAddress $receiptEmail = null, ?int $orderId = null): self
{
return new self(null, $sellerId, $customerId, $paymentMethod, $soldAt, $soldOn, $lines, null, $receiptEmail);
return new self(null, $sellerId, $customerId, $paymentMethod, $soldAt, $soldOn, $lines, null, $receiptEmail, $orderId);
}
/**
@@ -74,9 +75,9 @@ final class QuickSale
/**
* @param list<QuickSaleLine> $lines
*/
public static function reconstitute(int $id, int $sellerId, ?int $customerId, PaymentMethod $paymentMethod, DateTimeImmutable $soldAt, DateTimeImmutable $soldOn, array $lines, ?int $creditsSaleId, ?EmailAddress $receiptEmail = null): self
public static function reconstitute(int $id, int $sellerId, ?int $customerId, PaymentMethod $paymentMethod, DateTimeImmutable $soldAt, DateTimeImmutable $soldOn, array $lines, ?int $creditsSaleId, ?EmailAddress $receiptEmail = null, ?int $orderId = null): self
{
return new self($id, $sellerId, $customerId, $paymentMethod, $soldAt, $soldOn, $lines, $creditsSaleId, $receiptEmail);
return new self($id, $sellerId, $customerId, $paymentMethod, $soldAt, $soldOn, $lines, $creditsSaleId, $receiptEmail, $orderId);
}
public function totalCents(): int
@@ -136,4 +137,12 @@ final class QuickSale
{
return $this->receiptEmail;
}
/**
* The quick sale order this sale paid, if any.
*/
public function orderId(): ?int
{
return $this->orderId;
}
}