refactor(inventory): update stock validation rules and enforce stock_difference requirement
This commit is contained in:
@@ -97,6 +97,8 @@ class AccommodationControllerTest extends TestCase
|
||||
|
||||
$updated = $this->variantPayload('Casa Rodante Premium', 'Con electricidad', 15, 50000);
|
||||
$updated['id'] = $variantId;
|
||||
unset($updated['stock']);
|
||||
$updated['stock_difference'] = -5;
|
||||
|
||||
$this->postJson('/api/v1/adminapp/tenant/accommodations', [
|
||||
'variants' => [
|
||||
|
||||
@@ -194,7 +194,7 @@ class EntryControllerTest extends TestCase
|
||||
'title' => 'Abono actualizado',
|
||||
'description' => 'Ahora incluye ambas fechas',
|
||||
'event_date_ids' => [$firstDate->id, $secondDate->id],
|
||||
'stock' => 20,
|
||||
'stock_difference' => 10,
|
||||
'price' => 250,
|
||||
],
|
||||
[
|
||||
@@ -268,7 +268,7 @@ class EntryControllerTest extends TestCase
|
||||
'id' => $entryId,
|
||||
'title' => 'Abono editado',
|
||||
'event_date_ids' => [$date->id, $otherDate->id],
|
||||
'stock' => 30,
|
||||
'stock_difference' => 10,
|
||||
'price' => 200,
|
||||
]],
|
||||
])->assertOk()
|
||||
@@ -329,7 +329,7 @@ class EntryControllerTest extends TestCase
|
||||
'title' => 'Entrada inválida',
|
||||
'description' => null,
|
||||
'event_date_ids' => [$foreignDate->id],
|
||||
'stock' => 10,
|
||||
'stock_difference' => 0,
|
||||
'price' => 100,
|
||||
]],
|
||||
])
|
||||
@@ -371,7 +371,7 @@ class EntryControllerTest extends TestCase
|
||||
'title' => 'Entrada inválida',
|
||||
'description' => null,
|
||||
'event_date_ids' => [$eventDate->id],
|
||||
'stock' => 10,
|
||||
'stock_difference' => 0,
|
||||
'price' => 100,
|
||||
]],
|
||||
])
|
||||
|
||||
@@ -124,6 +124,8 @@ class FoodControllerTest extends TestCase
|
||||
|
||||
$updated = $this->variantPayload($secondDate->id, 'Cena', 'Vianda', 80, 8500);
|
||||
$updated['id'] = $variantId;
|
||||
unset($updated['stock']);
|
||||
$updated['stock_difference'] = -20;
|
||||
$updated['description'] = 'Cena para llevar';
|
||||
|
||||
$this->postJson('/api/v1/adminapp/tenant/foods', [
|
||||
@@ -240,7 +242,7 @@ class FoodControllerTest extends TestCase
|
||||
Inventory::query()->whereKey($replacementInventoryId)->delete();
|
||||
|
||||
$updated = $this->patchJson('/api/v1/adminapp/tenant/foods/history-stock', [
|
||||
'variants' => [['id' => $historicalVariantId, 'stock' => 45]],
|
||||
'variants' => [['id' => $historicalVariantId, 'stock_difference' => -55]],
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.history.0.variants.0.id', $historicalVariantId)
|
||||
@@ -258,7 +260,7 @@ class FoodControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->patchJson('/api/v1/adminapp/tenant/foods/history-stock', [
|
||||
'variants' => [['id' => $activeVariantId, 'stock' => 20]],
|
||||
'variants' => [['id' => $activeVariantId, 'stock_difference' => -60]],
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['variants.0.id']);
|
||||
|
||||
@@ -112,6 +112,8 @@ class MerchandiseControllerTest extends TestCase
|
||||
|
||||
$updatedVariant = $this->variantPayload('Blanco', 'M', 80, 12500);
|
||||
$updatedVariant['id'] = $variantId;
|
||||
unset($updatedVariant['stock']);
|
||||
$updatedVariant['stock_difference'] = -20;
|
||||
$updatedItem = $this->itemPayload('Camiseta oficial', 2, [
|
||||
$updatedVariant,
|
||||
$this->variantPayload('Verde', 'L', 60, 15000),
|
||||
@@ -234,6 +236,8 @@ class MerchandiseControllerTest extends TestCase
|
||||
$secondItemVariantId = $created->json('data.1.variants.0.id');
|
||||
$foreignVariant = $this->variantPayload('Azul Marino', 'XL', 20, 30000);
|
||||
$foreignVariant['id'] = $secondItemVariantId;
|
||||
unset($foreignVariant['stock']);
|
||||
$foreignVariant['stock_difference'] = 0;
|
||||
$firstItem = $this->itemPayload('Camiseta', 3, [$foreignVariant]);
|
||||
$firstItem['id'] = $firstItemId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user