<?php

namespace App\Models\Finance;

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

class Payable extends Model
{
    use SoftDeletes;

    protected $table = 'payables';

    protected $fillable = [
        'tenant_id',
        'vendor_name',
        'invoice_no',
        'issue_date',
        'due_date',
        'category',
        'amount',
        'paid_amount',
        'status',
        'description',
        'memo',
        'tax_invoice_issued',
    ];

    protected $casts = [
        'amount' => 'integer',
        'paid_amount' => 'integer',
        'issue_date' => 'date',
        'due_date' => 'date',
        'tax_invoice_issued' => 'boolean',
    ];

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