feat: implement multi-tenant cart system with stock reservation and inventory tracking

This commit is contained in:
2026-07-01 16:21:53 -03:00
parent 230ea57ce0
commit 6a0b08c9d7
8 changed files with 144 additions and 18 deletions

View File

@@ -83,7 +83,8 @@ class CartControllerTest extends TestCase
$this->assertDatabaseHas('productos_variantes', [
'id' => $variant->id,
'stock' => 8,
'stock_real' => 10,
'stock_reservado' => 2,
]);
}
@@ -124,7 +125,8 @@ class CartControllerTest extends TestCase
]);
$this->assertDatabaseHas('productos_variantes', [
'id' => $variant->id,
'stock' => 7,
'stock_real' => 12,
'stock_reservado' => 5,
]);
}
@@ -162,7 +164,8 @@ class CartControllerTest extends TestCase
]);
$this->assertDatabaseHas('productos_variantes', [
'id' => $variant->id,
'stock' => 5,
'stock_real' => 10,
'stock_reservado' => 5,
]);
}
@@ -194,7 +197,8 @@ class CartControllerTest extends TestCase
$this->assertDatabaseCount('carrito_items', 0);
$this->assertDatabaseHas('productos_variantes', [
'id' => $variant->id,
'stock' => 10,
'stock_real' => 10,
'stock_reservado' => 0,
]);
}

View File

@@ -143,10 +143,10 @@ class ProductControllerTest extends TestCase
$this->assertDatabaseHas('productos_variantes', [
'producto_id' => $product->id,
'stock' => 10,
'stock_real' => 10,
]);
$variantS = ProductVariant::where('producto_id', $product->id)->where('stock', 10)->firstOrFail();
$variantS = ProductVariant::where('producto_id', $product->id)->where('stock_real', 10)->firstOrFail();
$this->assertDatabaseHas('productos_variantes_values', [
'producto_variante_id' => $variantS->id,
'products_attribute_id' => $productAttributes['size']->id,
@@ -321,7 +321,7 @@ class ProductControllerTest extends TestCase
// Variant should still exist untouched
$this->assertDatabaseHas('productos_variantes', [
'id' => $v1->id,
'stock' => 5,
'stock_real' => 5,
]);
}