Invoice - Quick Phone
@php
$currency = $all_settings->currency ?? 'BDT';
@endphp
Invoice No: INV-{{ $sale->id }}
Date: {{ $sale->created_at->format('d/m/Y') }}
Time: {{ $sale->created_at->format('H:i:s') }}
Payment Method: {{ ucfirst($sale->payment_method) }}
Payment Status: {{ ucfirst($sale->payment_status) }}
Bill To:
{{ $sale->customer->name ?? 'Walk-in Customer' }}
@if($sale->customer && $sale->customer->phone)
Phone: {{ $sale->customer->phone }}
@endif
@if($sale->customer && $sale->customer->address)
Address: {{ $sale->customer->address }}
@endif
| # |
Product |
Brand |
Model |
IMEI/SN |
Qty |
Price |
Subtotal |
@php $itemCount = 1; @endphp
@foreach ($sale->sellTransactions as $transaction)
| {{ $itemCount++ }} |
{{ $transaction->name ?? 'N/A' }} |
{{ $transaction->product->ProductBrand->name ?? 'N/A' }} |
{{ $transaction->product->ProductModel->name ?? 'N/A' }} |
{{ $transaction->product->imei_or_sn ?? 'N/A' }} |
{{ $transaction->sold_quantity ?? 0 }} |
{{ $currency }} {{ number_format($transaction->sell_price, 2) }} |
{{ $currency }} {{ number_format($transaction->sell_price * $transaction->sold_quantity, 2) }} |
@endforeach
@if($sale->exchanges && $sale->exchanges->count() > 0)
@foreach ($sale->exchanges as $exchange)
| {{ $itemCount++ }} |
Exchanged: {{ $exchange->brand->name ?? 'N/A' }} {{ $exchange->mobileModel->name ?? 'N/A' }} |
{{ $exchange->brand->name ?? 'N/A' }} |
{{ $exchange->mobileModel->name ?? 'N/A' }} |
{{ $exchange->imei ?? 'N/A' }} |
1 |
{{ $currency }} {{ number_format($exchange->price, 2) }} |
{{ $currency }} {{ number_format($exchange->price, 2) }} |
@endforeach
@endif
| Subtotal: |
{{ $currency }} {{ number_format($sale->total_amount, 2) }} |
@if ($sale->discount > 0)
| Exchange Discount: |
-{{ $currency }} {{ number_format($sale->discount, 2) }} |
| Net Amount: |
{{ $currency }} {{ number_format($sale->net_amount, 2) }} |
@endif
| Paid Amount: |
{{ $currency }} {{ number_format($sale->paid_amount, 2) }} |
@if ($sale->due_amount > 0)
| Due Amount: |
{{ $currency }} {{ number_format($sale->due_amount, 2) }} |
@endif
@php
// Calculate customer total outstanding
$customerTotalDue = 0;
if ($sale->customer) {
// Get customer's previous due amount (before this sale)
$previousDue = \App\Models\Sale::where('customer_id', $sale->customer->id)
->where('id', '!=', $sale->id)
->where('return_status', '!=', 'returned')
->sum('due_amount');
// Add current sale's due amount (0 for paid invoices, amount for credit invoices)
$currentSaleDue = $sale->due_amount ?? 0;
// Subtract any payments made towards previous due
$previousDuePayments = \App\Models\CustomerPayment::where('customer_id', $sale->customer->id)
->where('type', 'due_payment')
->sum('amount');
// For paid invoices: currentSaleDue = 0, so only previous due remains
// For credit invoices: currentSaleDue = sale amount, so total increases
$customerTotalDue = $previousDue + $currentSaleDue - $previousDuePayments;
}
@endphp
@if ($sale->customer && $customerTotalDue > 0)
| Customer Total Outstanding: |
{{ $currency }} {{ number_format($customerTotalDue, 2) }} |
@endif