<?php

namespace Modules\Vrc\Entities;

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

class VrcRepairOrderService extends Model
{
    protected $table = 'vrc_repair_order_services';

    protected $fillable = [
        'business_id', 'repair_order_id', 'service_id', 'description', 'hsn_sac',
        'labor_hours', 'labor_rate', 'qty', 'unit_price', 'discount',
        'discount_type', 'tax_rate_id', 'line_total', 'status',
        'assigned_technician_id', 'work_center_id', 'stage_status', 'stage_entered_at', 'sort_order',
    ];

    protected $casts = [
        'labor_hours'      => 'decimal:2',
        'labor_rate'       => 'decimal:2',
        'qty'              => 'decimal:2',
        'unit_price'       => 'decimal:2',
        'discount'         => 'decimal:2',
        'line_total'       => 'decimal:2',
        'stage_entered_at' => 'datetime',
    ];

    public function workCenter(): BelongsTo
    {
        return $this->belongsTo(VrcWorkCenter::class, 'work_center_id');
    }

    public function repairOrder(): BelongsTo
    {
        return $this->belongsTo(VrcRepairOrder::class, 'repair_order_id');
    }
}
