@php
$formatAmount = function ($value) {
$value = (float) ($value ?? 0);
return rtrim(rtrim(number_format($value, 2, '.', ','), '0'), '.');
};
@endphp
{{-- COMPANY HEADER --}}
{{ $company['contact_person'] ?: $company['name'] }}
@if($company['address'])
{{ $company['address'] }}
@endif
@if($company['phone1'] || $company['phone2'])
@if($company['phone1']) {{ $company['phone1'] }} @endif
@if($company['phone1'] && $company['phone2']) | @endif
@if($company['phone2']) {{ $company['phone2'] }} @endif
@endif
{{-- INVOICE INFO --}}
Invoice #:
{{ $sale->invoice_no }}
Date:
{{ $sale->sale_date->format('d/m/Y H:i') }}
Customer:
{{ $sale->customer->name ?? $sale->walk_in_name ?? 'Walk-in Customer' }}
@if($sale->location && $sale->location->name)
Location:
{{ $sale->location->name }}
@endif
{{-- SALE ITEMS --}}
@foreach($sale->items as $index => $item)
|
{{ $index + 1 }}. {{ $item->product->name ?? 'Product' }}
|
|
{{ $formatAmount($item->quantity) }} x {{ $formatAmount($item->unit_price) }}
|
{{ $formatAmount($item->total_price) }}
|
@endforeach
{{-- PAYMENT SUMMARY --}}
| Invoice Total |
{{ $formatAmount($sale->total) }} |
@if($balanceInfo)
|
Previous Balance
@if($balanceInfo['previous_balance'] > 0)
(Will Pay)
@elseif($balanceInfo['previous_balance'] < 0)
(Has Advance)
@else
(Settled)
@endif
|
{{ $formatAmount(abs($balanceInfo['previous_balance'])) }}
|
@endif
| Paid Now |
{{ $formatAmount($sale->paid) }} |
{{-- TOTAL OUTSTANDING --}}
|
Total Outstanding
@if($balanceInfo && $balanceInfo['total_outstanding'] > 0)
(Will Pay)
@elseif($balanceInfo && $balanceInfo['total_outstanding'] < 0)
(Has Advance)
@endif
|
{{ $formatAmount(abs($balanceInfo ? $balanceInfo['total_outstanding'] : $sale->due)) }}
|
{{-- FOOTER --}}
Thank you for your business!