'decimal:6', 'pos_stock' => 'decimal:6', 'ecommerce_stock' => 'decimal:6', 'purchase_reserved_stock' => 'decimal:6', 'asset_stock' => 'decimal:6', 'last_cost' => 'decimal:2', 'average_cost' => 'decimal:2', 'total_last_cost' => 'decimal:2', 'total_average_cost' => 'decimal:2', 'total_identified_cost' => 'decimal:2', 'costing_method' => 'integer', ]; /** * Verificar que el stock en áreas no supere el stock total */ public static function boot() { parent::boot(); static::saving(function ($inventory) { $totalReserved = $inventory->pos_stock + $inventory->ecommerce_stock + $inventory->purchase_reserved_stock + $inventory->asset_stock; if ($totalReserved > $inventory->quantity) { throw new \Exception("Error: El stock reservado no puede ser mayor al stock total."); } }); } public function product() { return $this->belongsTo(Product::class, 'product_id'); } public function store(): BelongsTo { return $this->belongsTo(Store::class, 'store_id'); } public function warehouse() { return $this->belongsTo(Warehouse::class, 'warehouse_id'); } }