diff --git a/app/Domains/Catalog/Models/Attribute.php b/app/Domains/Catalog/Models/Attribute.php index 58e1f99..c4c9dee 100644 --- a/app/Domains/Catalog/Models/Attribute.php +++ b/app/Domains/Catalog/Models/Attribute.php @@ -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'); } diff --git a/tests/Feature/Catalog/CatalogItemDetailControllerTest.php b/tests/Feature/Catalog/CatalogItemDetailControllerTest.php index 5d8d3a8..b466afb 100644 --- a/tests/Feature/Catalog/CatalogItemDetailControllerTest.php +++ b/tests/Feature/Catalog/CatalogItemDetailControllerTest.php @@ -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',