<?php

namespace App\Models;

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

class DailyCollection extends Model
{
    protected $fillable = [
        'branch_id','financial_account_id','collection_date','amount','principal','interest','fees','penalties',
        'write_off_recoveries','write_off_recoveries_count','payments_count',
    ];

    protected function casts(): array
    {
        return [
            'collection_date'=>'date','amount'=>'decimal:2','principal'=>'decimal:2','interest'=>'decimal:2',
            'fees'=>'decimal:2','penalties'=>'decimal:2','write_off_recoveries'=>'decimal:2',
            'write_off_recoveries_count'=>'integer','payments_count'=>'integer',
        ];
    }

    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function financialAccount(): BelongsTo { return $this->belongsTo(FinancialAccount::class); }
}
