39 lines
973 B
PHP
39 lines
973 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
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);
|
|
}
|
|
}
|