@extends('admin.layout.print') @section('content')
{{-- HEADER --}}

{{ $admin->name ?? '' }}

{{ $admin->address ?? '' }}

{{ $admin->whatsapp ?? '' }} {{ $admin->phone ?? '' }}

{{-- CUSTOMER / BILL INFO --}}

Bill No: {{ $sale->bill_no ?? "" }}

Date: {{ \Carbon\Carbon::parse($sale->date)->format('d/m/Y H:i') }}

Customer: {{ $sale->customer?->name ?? '' }}

Phone: {{ $sale->customer?->phone ?? '' }}

Ref name: {{ $sale->refer?->name ?? '' }}

Veh no: {{ $sale->veh_no ?? '' }}

Type: {{ ucfirst($sale->type ?? '') }}

{{-- ITEMS TABLE --}} @php $items = $sale->items ?? []; $grandTotal = 0; @endphp @forelse($items as $item) @php $qty = $item['quantity'] ?? 1; $rate = $item['rate'] ?? 0; $total = $qty * $rate; $grandTotal += $total; @endphp @empty @endforelse
Item Qty Rate Total
{{ $item['item']['name'] ?? '' }} {{ $qty }} {{ number_format($rate) }} {{ number_format($total) }}
No items found
{{-- SUMMARY --}} @php $oldTyreAdjustment = $sale->adjustment_amount ?? 0; $paidAmount = $sale->received ?? 0; $totalBillAmount = $grandTotal + $sale->installment_charges - $oldTyreAdjustment - $sale->received; $remainingAmount = $totalBillAmount - $paidAmount; $monthsTotal = (int) ($sale->installment_no ?? 0); $monthlyInstallment = $monthsTotal > 0 ? ($totalBillAmount / $monthsTotal) : 0; $monthsPaid = $monthlyInstallment > 0 ? floor($paidAmount / $monthlyInstallment) : 0; $monthsRemaining = max(0, $monthsTotal - $monthsPaid); @endphp
Old tyres adjustment: {{ number_format($oldTyreAdjustment) }}
Total Bill Amount: {{ number_format($sale->total) }}
Paid Amount: {{ number_format($sale->received) }}
Remaining Amount: {{ number_format($sale->total - $sale->received) }}
@if($sale->type == 'installment')
Total Installment Amount: {{ number_format($totalBillAmount) }}
Monthly Installment: {{ number_format($monthlyInstallment) }}
Total Months Remaining: {{ $monthsRemaining }}
@endif
@if($sale->type == 'direct') @if($ledgers->isNotEmpty()) @forelse($ledgers as $ledger) @empty @endforelse
Payment Date Payment Method Paid Amount
{{ $ledger->date }} {{ $ledger->mop }} {{ $ledger->amount }}
No Records
@endif @endif {{-- REMARKS --}}
Remarks (note):
{{ $sale->note ?? '' }}
@endsection