feat(event): filter event dates to exclude rescheduled and suspended entries

This commit is contained in:
2026-09-14 16:48:06 -03:00
parent b1e09b71ad
commit c27d9628fd
2 changed files with 22 additions and 0 deletions

View File

@@ -59,6 +59,8 @@ class Attribute extends Model
public function eventDates(): HasMany
{
return $this->hasMany(EventDate::class, 'tenant_code', 'tenant_codigo')
->whereNull('rescheduled_to_event_date_id')
->whereNull('suspended_at')
->orderBy('date')
->orderBy('time_start');
}

View File

@@ -220,6 +220,18 @@ class CatalogItemDetailControllerTest extends TestCase
'time_start' => '10:00',
'time_end' => '19:00',
]);
$rescheduledEventDate = $tenant->eventDates()->create([
'date' => '2026-10-08',
'time_start' => '10:00',
'time_end' => '19:00',
'rescheduled_to_event_date_id' => $unusedEventDate->id,
]);
$suspendedEventDate = $tenant->eventDates()->create([
'date' => '2026-10-11',
'time_start' => '10:00',
'time_end' => '19:00',
'suspended_at' => now(),
]);
$item = $this->createItem($tenant, 'Entry');
$attribute = Attribute::query()->create([
'tenant_codigo' => $tenant->codigo,
@@ -245,6 +257,14 @@ class CatalogItemDetailControllerTest extends TestCase
->assertJsonPath('data.attributes.0.options.0.validity_time.type', 'fixed_window')
->assertJsonPath('data.attributes.0.options.1.id', $unusedEventDate->id)
->assertJsonPath('data.attributes.0.options.1.value', (string) $unusedEventDate->id)
->assertJsonMissing([
'id' => $rescheduledEventDate->id,
'value' => (string) $rescheduledEventDate->id,
])
->assertJsonMissing([
'id' => $suspendedEventDate->id,
'value' => (string) $suspendedEventDate->id,
])
->assertJsonPath('data.variants.0.values.event_date.value', (string) $eventDate->id)
->assertJsonPath(
'data.variants.0.values.event_date.label',