refactor(inventory): update stock validation rules and enforce stock_difference requirement
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user