<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class ShowAccReceivableDetailResource extends JsonResource
{
   
    public function toArray($request)
    {
        return [
            'id'                => $this->id,
            'client_name'       => $this->client->name,
            'client_code'       => $this->client->code,
            'client_phone'      => $this->client->phone,
            'client_id'         => $this->client_id,
            'chart_of_acc_id'   => $this->chart_of_acc_id,
            'invoice_number'    => $this->invoice_number,
            'payment_method'    => $this->payment_methods->chart_name??'',
            'currency_id'       => $this->currency_id,
            'co_name'           => $this->co->name,
            'loan_code'         => $this->loan->loan_code??'',
            'level_loan'        => $this->loan->level_loan??'',
            'payment_status_id' => $this->acc_receivable->payment_status_id??'',
            'payment_date'      => $this->acc_receivable->payment_date??'',
            'payment_per_month' => $this->acc_receivable->payment_per_month??'',
            'received_date'     => $this->received_date,
            'closing_date'      => $this->closing_date,
            'closing_by'        => $this->closing_by,
            'approved_by'       => $this->approved_by,
            // Value
            'paid_principal'    => $this->paid_principal,
            'paid_interest'     => $this->paid_interest,
            'received'          => $this->received,
            'unreceived'        => $this->unreceived,
            'total_collected'   => $this->received,
            'paid_penalty'      => $this->paid_penalty,
            'status'            => $this->status,
            'note'              => $this->note,
            'deleted_at'        => $this->deleted_at,
            'create_by'         => $this->createdBy->name??'',
        ];
    }
}
