<?php

namespace App\Modules\Inventory\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class InventoryCountItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'count_doc_id',
        'product_id',
        'batch_number',
        'system_qty',
        'counted_qty',
        'diff_qty',
        'notes',
    ];

    protected $casts = [
        'system_qty' => 'decimal:2',
        'counted_qty' => 'decimal:2',
        'diff_qty' => 'decimal:2',
    ];

    public function doc(): BelongsTo
    {
        return $this->belongsTo(InventoryCountDoc::class, 'count_doc_id');
    }

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