<?php

namespace App\Models;

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

class FixedAssetDepreciation extends Model
{
    protected $fillable = [
        'fixed_asset_id','period_date','amount','accumulated_after','book_value_after','journal_number','notes','posted_at','posted_by',
    ];

    protected function casts(): array
    {
        return [
            'period_date' => 'date',
            'posted_at' => 'datetime',
            'amount' => 'decimal:2',
            'accumulated_after' => 'decimal:2',
            'book_value_after' => 'decimal:2',
        ];
    }

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