refactor(inventory): enhance error reporting for negative stock validation

This commit is contained in:
2026-09-25 15:31:43 -03:00
parent a05d15d17f
commit ad054127aa
2 changed files with 37 additions and 3 deletions

View File

@@ -113,12 +113,16 @@ class InventoryStockMovementMigrationTest extends TestCase
public function test_migration_rejects_an_inventory_with_negative_available_stock(): void
{
DB::table('inventories')->insert([
'id' => 23,
'real_stock' => 1,
'reserved_stock' => 2,
]);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('stock disponible actual es negativo');
$this->expectExceptionMessage(
'stock disponible actual es negativo. Inventarios detectados (máximo 20): '
.'id=23 [real=1, vendidas=0, reintegradas=0, reservadas=2, reservas_entradas=0, resultado=-1]'
);
$this->stockMigration()->up();
}