<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SupplierPartPrice extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'company_id', 'supplier_id', 'part_id', 'purchase_id',
        'price', 'currency', 'observed_at',
    ];

    protected $casts = [
        'price' => 'decimal:2',
        'observed_at' => 'datetime',
    ];

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

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

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