@if ($invoice->receivable)

@if ($invoice->receivable_type === 'App\Models\Patient\Patient') {{ __('basic.client') }} @elseif ($invoice->receivable_type === 'App\Models\User') {{ __('basic.supplier') }} @elseif ($invoice->receivable_type === 'App\Models\Invoice\Debtor') {{ __('basic.supplier') }} @endif

{{ $invoice->receivable->full_name }}

{{ date('d M Y h:i a', strtotime($invoice->created_at)) }}

@else The invoice is for no receiver @endif

{{ __('basic.type') }}

@if ($invoice->type == 0) {{ __('basic.purchase') }} @else {{ __('basic.income') }} @endif

{{ __('basic.branch') }}

{{ $invoice->branch->name }}

@if($invoice->paid_date)

{{ __('basic.created') }}

{{ date('d M Y h:i a', strtotime($invoice->paid_date)) }}

@endif

@foreach ($invoice->invoice_items as $item) @endforeach
{{ __('basic.item') }} {{ __('basic.description') }} {{ __('basic.unit price') }} {{ __('basic.quantity') }} {{ __('basic.tax') }} {{ __('basic.final price') }}
{{ $item->categorizable->name }} {{ $item->description }}
{{ $item->price }} {{ $invoice->currency->code }}
{{ $item->qty }}
{{ $item->tax }} {{ $invoice->currency->code }}
{{ $item->subtotal }} {{ $invoice->currency->code }}

{{ __('basic.subtotal') }}
{{ $invoice->items_price }} {{ __('basic.egp') }}
{{ __('basic.discount') }}
@if (!empty($invoice->discount)) {{ $invoice->discount }} {{ $invoice->currency->code }} @else 0 @endif
{{ __('basic.tax') }}
@if (!empty($invoice->total_tax)) {{ $invoice->total_tax }} {{ $invoice->currency->code }} @else 0 @endif
{{ __('basic.final price') }}
{{ $invoice->final_price }} {{ $invoice->currency->code }}
{{ __('basic.remaining amount') }}
{{ $invoice->final_price - $invoice->sum_payment }} {{ $invoice->currency->code }}
{{-- for payments --}} @if (count($invoice->payment) > 0)
@foreach ($invoice->payment as $item_p) @endphp
@if ($item_p->worker)

{{ __('basic.shift') }}: {{ $item_p->worker->name }}

@endif
{{ $item_p->amount }} {{ __('basic.egp') }}
@endforeach
{{ __('basic.total payments') }}
@if ($invoice->sum_payment) {{ $invoice->sum_payment }} @else 0 @endif {{ __('basic.egp') }}
@if ($invoice->status !== 3)
{{ __('basic.remaining amount') }}
{{ $invoice->final_price - $invoice->sum_payment }} {{ __('basic.egp') }}
@endif @endif
{{ $invoice->client_note }}
@if ($invoice->status == 0)

{{ __('basic.not paid') }}

@elseif (in_array($invoice->status, [1, 2]))
{{ __('basic.remaining amount') }}

{{ $invoice->final_price - $invoice->sum_payment }} {{ __('basic.egp') }}

@else
{{ __('patientappo.amount to pay') }}

{{ $invoice->final_price }} {{ __('basic.egp') }}

@endif
{{ $invoice_rule }}