{{-- resources/views/customers/show.blade.php --}} @extends('layouts.app') @section('title', $customer->name) @section('content') @php // Opening balance $opening = (float) ($customer->opening_balance ?? 0); // সব সেল controller থেকে $sales হিসেবে আসছে (DESC order) $totalSales = isset($sales) ? (float) $sales->sum('total') : 0; $totalPaid = isset($sales) ? (float) $sales->sum('paid') : 0; // returns $totalReturns = (float) $returns->sum('total'); // Final হিসাব: // Opening + Total sales - Total paid - customer returns $currentDue = $opening + $totalSales - $totalPaid - $totalReturns; @endphp
No sales for this customer yet.
@else| Date | Invoice | Total | Paid | Due | Status | Next Due | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $sale->date ? \Carbon\Carbon::parse($sale->date)->format('d-m-Y') : '-' }} | {{ $sale->invoice_no }} | {{ number_format($sale->total ?? 0, 2) }} | {{ number_format($sale->paid ?? 0, 2) }} | {{ number_format($sale->due ?? 0, 2) }} | @if($sale->status === 'paid') Paid @else Due @endif | {{ $sale->next_due_date ? \Carbon\Carbon::parse($sale->next_due_date)->format('d-m-Y') : '-' }} | ||||||||||||
|
||||||||||||||||||
No payments from this customer yet.
@else| Date | Method | Amount | Ref No | Note |
|---|---|---|---|---|
| {{ $pay->date ? \Carbon\Carbon::parse($pay->date)->format('d-m-Y') : '-' }} | {{ $pay->method }} | {{ number_format($pay->amount ?? 0, 2) }} | {{ $pay->ref_no ?? '-' }} | {{ $pay->note ?? '-' }} |
No return entries for this customer.
@else| Date | Product | Qty | Unit Price | Total | Note |
|---|---|---|---|---|---|
| {{ $r->date ? $r->date->format('d-m-Y') : '-' }} | {{ optional($r->product)->name ?? '—' }} | {{ $r->qty }} | {{ number_format($r->unit_price, 2) }} | {{ number_format($r->total, 2) }} | {{ $r->note ?? '-' }} |