feat(ticket): implement validity time management for tickets and catalog items

- 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.
This commit is contained in:
2026-08-06 15:52:19 -03:00
parent 7f01adab73
commit 448ffb4102
30 changed files with 556 additions and 381 deletions

View File

@@ -14,6 +14,8 @@ use App\Domains\Catalog\Models\FeaturedGroup;
use App\Domains\Catalog\Services\CatalogService;
use App\Domains\Event\Models\Event;
use App\Domains\Tenant\Models\Tenant;
use App\Domains\Ticket\Enums\ValidityTimeType;
use App\Domains\Ticket\Models\ValidityTime;
use Illuminate\Database\Seeder;
use RuntimeException;
@@ -79,6 +81,11 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
$dates = $eventDates->keys()->all();
$minimumUseDate = $dates[0].' 00:00:00';
$maximumUseDate = $dates[array_key_last($dates)].' 23:59:59';
$eventValidityTime = ValidityTime::query()->firstOrCreate([
'type' => ValidityTimeType::FixedWindow,
'fixed_starts_at' => $minimumUseDate,
'fixed_expires_at' => $maximumUseDate,
]);
$generalAdmission = $this->catalogService->create([
'tenant_code' => $tenant->codigo,
@@ -91,8 +98,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
'precio' => 10000,
'inventory_policy' => InventoryPolicy::Unlimited->value,
'has_tickets' => true,
'minimum_use_date' => $minimumUseDate,
'maximum_use_date' => $maximumUseDate,
'validity_time_id' => $eventValidityTime->id,
'variants' => array_map(
fn (string $date): array => [
'real_stock' => 0,
@@ -120,8 +126,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
'descripcion' => $item['descripcion'] ?? $item['nombre'],
'inventory_policy' => InventoryPolicy::Unlimited->value,
'real_stock' => 0,
'minimum_use_date' => $minimumUseDate,
'maximum_use_date' => $maximumUseDate,
'validity_time_id' => $eventValidityTime->id,
...$item,
]);
}