@php $invoiceNumber = 'INV-' . str_pad($sale->id, 6, '0', STR_PAD_LEFT); $invoiceDate = $sale->sale_date ? \Illuminate\Support\Carbon::parse($sale->sale_date)->format('F j, Y') : $sale->created_at->format('F j, Y'); $lead = $sale->lead; $company = $lead?->company; $totalPaid = $sale->sale_payment->sum('amount'); $balanceDue = $sale->total - $totalPaid; @endphp
Invoice
@if($logoPath ?? null) {{ $account->name }} @else
{{ strtoupper(substr($account->name ?? 'C', 0, 1)) }}
@endif
{{ $account->name ?? config('app.name') }}
@if($account?->address)
{{ $account->address }}
@endif
Invoice No
{{ $invoiceNumber }}
Invoice Date
{{ $invoiceDate }}
Bill To
{{ $company?->name ?? $lead?->name ?? 'N/A' }}
@if($lead?->name && $company?->name)
Attn: {{ $lead->name }}
@endif @if($company?->address)
{{ $company->address }}{{ $company->city ? ', ' . $company->city : '' }}
@endif @if($lead?->email)
{{ $lead->email }}
@endif @if($lead?->phone)
{{ $lead->country_code }}{{ $lead->phone }}
@endif
{{ ucfirst($sale->payment_status) }} {{ ucfirst($sale->approval_status) }}
Product Price Quantity Incentive Total
{{ $sale->product?->name ?? 'N/A' }} @if($sale->product?->description)
{{ $sale->product->description }}
@endif @if($sale->remarks)
Remarks: {{ $sale->remarks }}
@endif
{{ number_format($sale->price, 2) }} {{ number_format($sale->quantity, fmod($sale->quantity, 1) == 0 ? 0 : 2) }} {{ number_format($sale->incentive ?? 0, 2) }} {{ number_format($sale->total, 2) }}
Total Amount Rs. {{ number_format($sale->total, 2) }}
Amount Paid Rs. {{ number_format($totalPaid, 2) }}
Balance Due Rs. {{ number_format($balanceDue, 2) }}

Payment History
@if($sale->sale_payment && $sale->sale_payment->count() > 0) @foreach($sale->sale_payment as $payment) @endforeach
Date Payment Type Amount Remarks
{{ $payment->payment_date ? \Illuminate\Support\Carbon::parse($payment->payment_date)->format('M j, Y') : '-' }} {{ $payment->payment_type?->name ?? '-' }} {{ number_format($payment->amount, 2) }} {{ $payment->remarks ?? '-' }}
@else
No payments recorded yet.
@endif