<?php

namespace App\Models;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use App\Models\Accounting\ChartOfAccount;
use Illuminate\Database\Eloquent\SoftDeletes;

class AccReceivableDetails extends Model
{
    use SoftDeletes;
    protected $table = 'acc_receivable_details';
    protected $fillable = [
        'id',
        'branch_id',
        'loan_id',
        'client_id',
        'co_id',
        'currency_id',
        'acc_id',
        'chart_of_acc_id',
        'closing_date',
        'closing_by',
        'approved_by',
        'waiv_penalty',
        'invoice_number',
        'created_by'
    ];
    public function acc_receivable()
    {
        return $this->belongsTo(AccReceivables::class, 'acc_id');
    }

    public function payment_methods()
    {
        return $this->belongsTo(ChartOfAccount::class, 'chart_of_acc_id');
    }

    public function currency()
    {
        return $this->belongsTo(Currency::class, 'currency_id');
    }

    public function co()
    {
        return $this->belongsTo(User::class, 'co_id');
    }

    public function loan()
    {
        return $this->belongsTo(Loan::class, 'loan_id');
    }

    public function client()
    {
        return $this->belongsTo(Client::class, 'client_id');
    }
    public function createdBy()
    {
        return $this->belongsTo(User::class, 'created_by');
    }
}
