@extends('layouts.app') @section('main')

Customer Details: {{ $customer->name }}

Back to Credits
Name: {{ $customer->name }}
Phone: {{ $customer->number }}
CPR: {{ $customer->cpr ?? 'N/A' }}
Address: {{ $customer->address ?? 'N/A' }}
Total Credit

BHD {{ number_format($totalCredit, 2) }}

Total Paid

BHD {{ number_format($totalPaid, 2) }}

Outstanding Due

BHD {{ number_format($totalDue, 2) }}

@if ($totalDue > 0) @endif
Advance Amount

BHD {{ number_format($advance, 2) }}

Sales History
@foreach ($customer->sales as $sale) @endforeach
Sale ID Date Total Amount Paid Amount Due Amount Exchange Amount Payment Status Payment Method
{{ $sale->id }} {{ $sale->created_at->format('Y-m-d') }} {{ number_format($sale->total_amount, 2) }} {{ number_format($sale->paid_amount, 2) }} @php $dueAmount = $sale->due_amount; $duePayments = \App\Models\CustomerPayment::where( 'customer_id', $customer->id, ) ->where('type', 'due_payment') ->whereJsonContains('sale_ids', $sale->id) ->sum('amount'); $netDue = $dueAmount - $duePayments; @endphp {{ number_format(max(0, $netDue), 2) }} {{ $sale->exchanges->sum('price') }} {{ $netDue <= 0 ? 'Paid' : ucfirst($sale->payment_status) }} @if ($sale->payment_method == 'multiple') @foreach ($sale->payments as $payment) {{ ucfirst($payment->payment_type) }}: {{ number_format($payment->amount, 2) }}
@endforeach @else {{ ucfirst($sale->payment_method) }} @endif
Payment History
@foreach ($payments as $payment) @endforeach
Payment ID Date Type Amount Notes
{{ $payment->id }} {{ $payment->created_at->format('Y-m-d') }} {{ ucfirst(str_replace('_', ' ', $payment->type)) }} {{ number_format($payment->amount, 2) }} {{ $payment->notes ?? '-' }}
@endsection