<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StockAdjustment extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id', 'product_id', 'local_product_id',
        'product_name', 'type', 'quantity_before', 'quantity_change',
        'quantity_after', 'reason', 'notes', 'adjustment_date',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'quantity_before' => 'float',
        'quantity_change' => 'float',
        'quantity_after' => 'float',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
        'adjustment_date' => 'datetime',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
