52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\BusProNet\Model;
|
|
|
|
/**
|
|
* Purchase voucher validation response from BPN API.
|
|
*
|
|
* Represents a validated purchase voucher (Gutschein) with redemption code.
|
|
* These vouchers have a remaining balance that can be redeemed against bookings.
|
|
* The voucher reduces the booking price by its balance until depleted.
|
|
*
|
|
* Purchase vouchers can be regular purchased vouchers or goodwill vouchers (Kulanz)
|
|
* issued to customers for complaints or other reasons.
|
|
*/
|
|
final readonly class PurchaseVoucher
|
|
{
|
|
public const TYPE_PURCHASE = 'Kauf';
|
|
public const TYPE_GOODWILL = 'Kulanz';
|
|
|
|
public function __construct(
|
|
public string $voucherNumber,
|
|
public string $redemptionCode,
|
|
public int $voucherId,
|
|
public float $remainingBalance,
|
|
public string $type,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Checks if this voucher is a purchase voucher.
|
|
*
|
|
* Purchase vouchers (Kauf) are aggregated into <gutscheine>.
|
|
*/
|
|
public function isPurchase(): bool
|
|
{
|
|
return self::TYPE_PURCHASE === $this->type;
|
|
}
|
|
|
|
/**
|
|
* Checks if this voucher is a goodwill voucher.
|
|
*
|
|
* Goodwill vouchers (Kulanz) must be treated as promo vouchers and added
|
|
* per participant as <aktionscode>, not aggregated into <gutscheine>.
|
|
*/
|
|
public function isGoodwill(): bool
|
|
{
|
|
return self::TYPE_GOODWILL === $this->type;
|
|
}
|
|
}
|