- Added ValidityTime model and migration to manage ticket validity periods. - Updated TicketGeneratorService to resolve and assign validity times to tickets. - Refactored ticket generation logic to remove legacy date fields and use validity time. - Introduced timezone support for tenants to handle service dates correctly. - Updated migrations to remove deprecated columns and add foreign keys for validity times. - Modified seeders and tests to accommodate new validity time structure. - Enhanced tests to validate ticket generation and validity time behavior.
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Exceptions;
|
|
|
|
use App\Domains\Catalog\Models\CatalogItem;
|
|
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 ambiguousValidityTime(CatalogItem $catalogItem): self
|
|
{
|
|
return new self("Catalog item {$catalogItem->id} resolves more than one validity time.");
|
|
}
|
|
|
|
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]));
|
|
}
|
|
}
|