feat: Implement inventory policy for product variants

- Introduced InventoryPolicy enum to manage tracked and unlimited inventory types.
- Updated ProductVariant model to include inventory_policy and cantidad_vendida attributes.
- Modified addItem and updateItem methods in Cart to check available quantity based on inventory policy.
- Added migration to include inventory_policy and cantidad_vendida in productos_variantes table.
- Enhanced tests to validate inventory behavior for both tracked and unlimited policies.
- Updated various request and resource classes to handle new inventory fields.
This commit is contained in:
2026-07-16 08:36:59 -03:00
parent 716d8e447c
commit 10157d7c63
16 changed files with 547 additions and 73 deletions

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('productos_variantes', function (Blueprint $table) {
$table->string('inventory_policy')->default('tracked')->after('producto_id');
$table->unsignedBigInteger('cantidad_vendida')->default(0)->after('stock_reservado');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('productos_variantes', function (Blueprint $table) {
$table->dropColumn(['inventory_policy', 'cantidad_vendida']);
});
}
};