feat: promotional and purchase vouchers

This commit is contained in:
Björn Fromme
2025-11-20 18:41:46 +01:00
parent 26681e5c62
commit aaa7e9f4c3
21 changed files with 847 additions and 6 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
/**
* Promo voucher validation response from BPN API.
*
* Represents a validated promotional voucher (Aktionsgutschein) applied per participant.
* These vouchers provide discounts either as fixed amounts or percentages.
*/
final readonly class PromoVoucher
{
public const APPLICABILITY_PER_PERSON = 'P';
public const APPLICABILITY_PER_BOOKING = 'B';
public function __construct(
public string $code,
public string $description,
public string $applicability,
public float $discountAmount,
public float $discountPercentage,
public float $minimumPrice,
) {
}
public function isPerPerson(): bool
{
return self::APPLICABILITY_PER_PERSON === $this->applicability;
}
public function isPerBooking(): bool
{
return self::APPLICABILITY_PER_BOOKING === $this->applicability;
}
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
final readonly class PromoVoucherValidationResult
{
public function __construct(
public bool $isValid,
public ?PromoVoucher $voucher = null,
public ?string $errorMessage = null,
public ?int $errorCode = null,
) {
}
}
+27
View File
@@ -0,0 +1,27 @@
<?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 function __construct(
public string $voucherNumber,
public string $redemptionCode,
public int $voucherId,
public float $remainingBalance,
public string $type,
) {
}
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
final readonly class PurchaseVoucherValidationResult
{
public function __construct(
public bool $isValid,
public ?PurchaseVoucher $voucher = null,
public ?string $errorMessage = null,
public ?int $errorCode = null,
) {
}
}