<?php

namespace App\Models;

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

class AccReceivableDetails extends Model
{
    use SoftDeletes;
    protected $table = 'acc_receivable_details';
    protected $fillable = [
        'id',
        'branch_id',
        'loan_id',
        'client_id',
        'co_id',
        'currency_id',
        'created_by',
        'acc_id',
        'chart_of_acc_id',
        'closing_date',
        'closing_by',
        'approved_by',
        'waiv_penalty',
        'note',
        'invoice_number'
    ];
    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 branchs()
    {
      return $this->belongsTo(Branch::class, 'branch_id');
    }

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