<?php

namespace App\Models;

use App\Support\PayrollVoucherOptions;

class FixedAssetDepreciation extends BaseModel
{
    protected $fillable = [
        'company_id', 'fixed_asset_id', 'period_year', 'period_month',
        'amount', 'posted_at', 'notes',
    ];

    protected $casts = [
        'period_year'  => 'integer',
        'period_month' => 'integer',
        'amount'       => 'decimal:2',
        'posted_at'    => 'datetime',
    ];

    public function asset()
    {
        return $this->belongsTo(FixedAsset::class, 'fixed_asset_id');
    }

    public function periodLabel(): string
    {
        return PayrollVoucherOptions::periodLabel($this->period_year, $this->period_month);
    }
}
