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

View File

@@ -27,7 +27,6 @@ use App\Domains\Shared\Enums\FieldType;
use App\Domains\Tenant\Models\Tenant;
use App\Domains\Ticket\Models\Ticket;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Carbon;
use Tests\TestCase;
class CatalogModelsTest extends TestCase
@@ -160,24 +159,6 @@ class CatalogModelsTest extends TestCase
$this->assertSame('catalog_items_attachments', $variant->attachments()->getTable());
}
public function test_variant_use_dates_override_or_inherit_catalog_item_dates(): void
{
$item = new CatalogItem;
$item->minimum_use_date = Carbon::parse('2026-08-01 09:00:00');
$item->maximum_use_date = Carbon::parse('2026-08-31 18:00:00');
$variant = new Variant;
$variant->maximum_use_date = Carbon::parse('2026-08-15 18:00:00');
$variant->setRelation('catalogItem', $item);
$this->assertTrue(
$variant->getMinimumUseDate()->equalTo($item->minimum_use_date),
);
$this->assertTrue(
$variant->getMaximumUseDate()->equalTo($variant->maximum_use_date),
);
}
public function test_event_date_identifies_a_variant_without_catalog_attributes(): void
{
$item = new CatalogItem;
@@ -189,15 +170,12 @@ class CatalogModelsTest extends TestCase
$eventDate->time_end = '18:00:00';
$variant = new Variant;
$variant->minimum_use_date = Carbon::parse('2026-10-09 08:00:00');
$variant->maximum_use_date = Carbon::parse('2026-10-09 20:00:00');
$variant->setRelation('catalogItem', $item);
$variant->setRelation('eventDate', $eventDate);
$variant->setRelation('definitions', new EloquentCollection);
$this->assertSame('Entrada General', $variant->getName());
$this->assertSame('2026-10-09 09:00:00', $variant->getMinimumUseDate()->format('Y-m-d H:i:s'));
$this->assertSame('2026-10-09 18:00:00', $variant->getMaximumUseDate()->format('Y-m-d H:i:s'));
$this->assertSame('2026-10-09', $variant->eventDate->date->format('Y-m-d'));
}
public function test_inventory_maps_stock_without_a_polymorphic_owner(): void