feat: finalize voucher handling and discount display in summary and overview
This commit is contained in:
1 parent
32bef9a4e9
commit
f4691ec67e
15 files changed
+762
-46
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user