Email quick sale receipts and send them again from the sales list

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:00:15 +02:00
co-authored by Claude Sonnet 5.5
parent 3faa4cfbc6
commit d160854b79
29 changed files with 679 additions and 34 deletions
@@ -11,6 +11,8 @@ use App\Modules\Sales\Domain\ValueObjects\VatTotal;
* A quick sale as listed: amounts with VAT, negative on a credit.
* $soldAt is "Y-m-d H:i" in the company's time zone. $creditsSaleId is set
* on a credit, $creditedBySaleId on a sale that has been credited.
* $receiptEmail is the address the receipt was emailed to; it is shown
* only on the sales list, never in reports.
*/
final readonly class QuickSaleSummary
{
@@ -28,8 +30,25 @@ final readonly class QuickSaleSummary
public array $lines,
public ?int $creditsSaleId,
public ?int $creditedBySaleId,
public ?string $receiptEmail = null,
public ?string $receiptSentAt = null,
public bool $receiptFailed = false,
) {}
/**
* The emailed receipt's state: null without an address, otherwise
* 'sent', 'failed' or 'pending' (still in the queue).
*/
public function receiptStatus(): ?string
{
return match (true) {
$this->receiptEmail === null => null,
$this->receiptFailed => 'failed',
$this->receiptSentAt !== null => 'sent',
default => 'pending',
};
}
public function isCredit(): bool
{
return $this->creditsSaleId !== null;
@@ -6,7 +6,8 @@ namespace App\Modules\Sales\Application\DTOs;
/**
* Input for a quick sale: quantities by product id (zero or empty ones are
* left out by the caller), the payment method key and an optional customer.
* left out by the caller), the payment method key, an optional customer
* and an optional address the receipt is emailed to.
*/
final readonly class SaleData
{
@@ -17,5 +18,6 @@ final readonly class SaleData
public array $quantities,
public string $paymentMethod,
public ?int $customerId = null,
public ?string $receiptEmail = null,
) {}
}
@@ -5,8 +5,9 @@ declare(strict_types=1);
namespace App\Modules\Sales\Application\DTOs;
/**
* A recorded quick sale: its id and total with VAT, and the hours booked
* on the seller or left unbooked (in quarters of an hour).
* A recorded quick sale: its id and total with VAT, the hours booked on
* the seller or left unbooked (in quarters of an hour), and the address
* the receipt is being emailed to, if one was given.
*/
final readonly class SaleResult
{
@@ -15,5 +16,6 @@ final readonly class SaleResult
public int $totalCents,
public int $bookedQuarters,
public int $unbookedQuarters,
public ?string $receiptEmail = null,
) {}
}