<?php

namespace App\Modules\Finance\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UtilityFee extends Model
{
    /** @use HasFactory<\Database\Factories\UtilityFeeFactory> */
    use HasFactory;

    protected $fillable = [
        'transaction_date',
        'category',
        'amount',
        'invoice_number',
        'description',
    ];

    protected $casts = [
        'transaction_date' => 'date',
        'amount' => 'decimal:2',
    ];

    public function tapActivity(\Spatie\Activitylog\Contracts\Activity $activity, string $eventName)
    {
        $activity->properties = $activity->properties->put('snapshot', [
            'transaction_date' => $this->transaction_date->format('Y-m-d'),
            'category' => $this->category,
            'amount' => $this->amount,
            'invoice_number' => $this->invoice_number,
        ]);
    }
}
