feat(event): filter event dates to exclude rescheduled and suspended entries
This commit is contained in:
parent
b1e09b71ad
commit
c27d9628fd
|
|
@ -59,6 +59,8 @@ class Attribute extends Model
|
||||||
public function eventDates(): HasMany
|
public function eventDates(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(EventDate::class, 'tenant_code', 'tenant_codigo')
|
return $this->hasMany(EventDate::class, 'tenant_code', 'tenant_codigo')
|
||||||
|
->whereNull('rescheduled_to_event_date_id')
|
||||||
|
->whereNull('suspended_at')
|
||||||
->orderBy('date')
|
->orderBy('date')
|
||||||
->orderBy('time_start');
|
->orderBy('time_start');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,18 @@ class CatalogItemDetailControllerTest extends TestCase
|
||||||
'time_start' => '10:00',
|
'time_start' => '10:00',
|
||||||
'time_end' => '19: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');
|
$item = $this->createItem($tenant, 'Entry');
|
||||||
$attribute = Attribute::query()->create([
|
$attribute = Attribute::query()->create([
|
||||||
'tenant_codigo' => $tenant->codigo,
|
'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.0.validity_time.type', 'fixed_window')
|
||||||
->assertJsonPath('data.attributes.0.options.1.id', $unusedEventDate->id)
|
->assertJsonPath('data.attributes.0.options.1.id', $unusedEventDate->id)
|
||||||
->assertJsonPath('data.attributes.0.options.1.value', (string) $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.value', (string) $eventDate->id)
|
||||||
->assertJsonPath(
|
->assertJsonPath(
|
||||||
'data.variants.0.values.event_date.label',
|
'data.variants.0.values.event_date.label',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue