<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class StockAdjustmentItem extends Model
{
    protected $fillable = [
        'adjustment_id', 'product_id', 'unit_id',
        'current_qty', 'adjustment_qty', 'new_qty', 'base_qty',
        'unit_cost', 'total_cost',
    ];

    protected $casts = [
        'current_qty'    => 'decimal:4',
        'adjustment_qty' => 'decimal:4',
        'new_qty'        => 'decimal:4',
        'base_qty'       => 'decimal:4',
        'unit_cost'      => 'decimal:4',
        'total_cost'     => 'decimal:4',
    ];

    public function adjustment()
    {
        return $this->belongsTo(StockAdjustment::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    public function unit()
    {
        return $this->belongsTo(Unit::class);
    }
}
