feat: finalize voucher handling and discount display in summary and overview

This commit is contained in:
Björn Fromme committed 2025-11-26 17:29:15 +01:00
1 parent 32bef9a4e9
commit f4691ec67e
15 files changed
+762 -46

No files matched your search

+19
View File
@@ -6,14 +6,33 @@ namespace App\BusProNet\Model;
/**
* Represents payment terms from the booking response.
*
* Contains deposit/final payment details and any applied purchase vouchers.
*/
class PaymentTerms
{
/**
* @param array<array{nummer: string, betrag: float}> $appliedPurchaseVouchers
*/
public function __construct(
public readonly ?float $depositAmount = null,
public readonly ?string $depositDate = null,
public readonly ?float $finalPaymentAmount = null,
public readonly ?string $finalPaymentDate = null,
public readonly array $appliedPurchaseVouchers = [],
) {
}
/**
* Gets the total discount from purchase vouchers.
*/
public function getPurchaseVoucherDiscount(): float
{
$total = 0.0;
foreach ($this->appliedPurchaseVouchers as $voucher) {
$total += $voucher['betrag'];
}
return round($total, 2);
}
}