<?php

namespace App\Models;

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

// [INTEGRATION] Line item within a supplier return — mirrors Flutter SupplierReturnItemModel
class SupplierReturnItem extends Model
{
    use HasUlids;

    protected $fillable = [
        'return_id', 'product_id', 'product_name', 'quantity', 'unit_cost', 'subtotal',
    ];

    protected $casts = [
        'quantity' => 'integer',
        'unit_cost' => 'float',
        'subtotal' => 'float',
    ];

    public function supplierReturn(): BelongsTo
    {
        return $this->belongsTo(SupplierReturn::class, 'return_id');
    }
}
