- Updated tests for Accommodation, Entry, Food, Merchandise, and Sale controllers to use soft deletes for variants and ensure proper inventory counts. - Enhanced ticket generation logic to resolve validity from soft-deleted catalog sources. - Introduced a new TicketValidityResolver service to manage ticket validity based on event dates and variant definitions. - Removed unnecessary database assertions and improved the clarity of validity checks in tests. - Added comprehensive tests for the new TicketValidityResolver service, ensuring correct handling of event dates and multi-select options. - Cleaned up unused code and assertions in existing tests for better maintainability.
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Exceptions;
|
|
|
|
use App\Domains\Catalog\Models\CatalogItem;
|
|
use App\Domains\Catalog\Models\Variant;
|
|
use App\Domains\Purchase\Models\Purchase;
|
|
use App\Domains\Purchase\Models\PurchaseItem;
|
|
use RuntimeException;
|
|
|
|
class TicketGenerationException extends RuntimeException
|
|
{
|
|
public static function invalidQuantity(): self
|
|
{
|
|
return new self(__('api.ticket.positive_quantity'));
|
|
}
|
|
|
|
public static function emptyBundle(CatalogItem $bundle): self
|
|
{
|
|
return new self(__('api.ticket.empty_bundle', ['bundle' => $bundle->id]));
|
|
}
|
|
|
|
public static function ticketsDisabled(CatalogItem $catalogItem): self
|
|
{
|
|
return new self(__('api.ticket.disabled', ['product' => $catalogItem->id]));
|
|
}
|
|
|
|
public static function invalidValidityConfiguration(CatalogItem $catalogItem, Variant $variant): self
|
|
{
|
|
return new self("Variant {$variant->id} from catalog item {$catalogItem->id} has an invalid validity configuration.");
|
|
}
|
|
|
|
public static function variantNotFound(
|
|
CatalogItem $catalogItem,
|
|
int $variantId,
|
|
): self {
|
|
return new self(
|
|
__('api.ticket.invalid_variant', [
|
|
'variant' => $variantId,
|
|
'product' => $catalogItem->id,
|
|
]),
|
|
);
|
|
}
|
|
|
|
public static function purchaseWithoutUser(Purchase $purchase): self
|
|
{
|
|
return new self(__('api.ticket.purchase_without_user', ['purchase' => $purchase->id]));
|
|
}
|
|
|
|
public static function catalogItemNotFound(PurchaseItem $purchaseItem): self
|
|
{
|
|
return new self(__('api.ticket.product_not_found', ['purchase_item' => $purchaseItem->id]));
|
|
}
|
|
}
|