<?php

namespace App\Models\Finance;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Receivable extends Model
{
    use SoftDeletes;

    protected $table = 'receivables';

    protected $fillable = [
        'tenant_id',
        'customer_name',
        'invoice_no',
        'issue_date',
        'due_date',
        'category',
        'amount',
        'collected_amount',
        'status',
        'description',
        'memo',
    ];

    protected $casts = [
        'amount' => 'integer',
        'collected_amount' => 'integer',
        'issue_date' => 'date',
        'due_date' => 'date',
    ];

    public function scopeForTenant($query, $tenantId)
    {
        return $query->where('tenant_id', $tenantId);
    }
}
