feat(catalog): add scope to filter available variants and update related queries; enhance seeder and tests for stock validation
This commit is contained in:
@@ -63,8 +63,8 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'attribute_codes' => ['color', 'talle'],
|
||||
'variants' => collect(['Verde', 'Blanco'])
|
||||
->crossJoin(['14', 'S', 'M', 'L', 'XL', 'XXL'])
|
||||
->map(fn (array $values): array => [
|
||||
'real_stock' => 0,
|
||||
->map(fn (array $values, int $index): array => [
|
||||
'real_stock' => [24, 3, 18, 0, 12, 2, 25, 0, 14, 1, 19, 8][$index],
|
||||
'values' => ['color' => $values[0], 'talle' => $values[1]],
|
||||
])->all(),
|
||||
]);
|
||||
@@ -75,8 +75,8 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'category_id' => $categories['alojamientos']->id,
|
||||
'precio' => 35000,
|
||||
'attribute_codes' => ['tipo_alojamiento'],
|
||||
'variants' => collect(['Carpa', 'Motorhome'])->map(fn (string $type): array => [
|
||||
'real_stock' => 0,
|
||||
'variants' => collect(['Carpa', 'Motorhome'])->map(fn (string $type, int $index): array => [
|
||||
'real_stock' => [0, 3][$index],
|
||||
'values' => ['tipo_alojamiento' => $type],
|
||||
])->all(),
|
||||
]);
|
||||
@@ -89,8 +89,8 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'attribute_codes' => ['event_date', 'horario', 'servicio'],
|
||||
'variants' => $eventDates
|
||||
->crossJoin(['Desayuno', 'Almuerzo', 'Cena'], ['Comedor', 'Vianda'])
|
||||
->map(fn (array $values): array => [
|
||||
'real_stock' => 0,
|
||||
->map(fn (array $values, int $index): array => [
|
||||
'real_stock' => [80, 3, 65, 0, 42, 2, 70, 18, 0, 5, 55, 40, 90, 1, 35, 0, 60, 8, 75, 22, 0, 4, 50, 30][$index],
|
||||
'event_date_ids' => [(int) $values[0]->id],
|
||||
'descripcion' => sprintf(
|
||||
'%s del %s - %s',
|
||||
@@ -112,7 +112,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'attribute_codes' => ['event_date'],
|
||||
'multi_select_attribute_codes' => ['event_date'],
|
||||
'variants' => [[
|
||||
'real_stock' => 0,
|
||||
'real_stock' => 120,
|
||||
'event_date_ids' => $dateIds->all(),
|
||||
]],
|
||||
]);
|
||||
@@ -142,7 +142,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
return $this->catalogService->create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'descripcion' => $data['nombre'],
|
||||
'inventory_policy' => InventoryPolicy::Unlimited->value,
|
||||
'inventory_policy' => InventoryPolicy::Tracked->value,
|
||||
...$data,
|
||||
'has_tickets' => true,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user