{{-- ══ VARIABLES ══ --}} @php $companyName = $invoice->company_name ?: ($invoice->customer->company_name ?? null); $custName = $invoice->customer_name; $custAddress = $invoice->customer_address ?: ($invoice->customer->address ?? null); $custPincode = $invoice->pincode ?: ($invoice->customer->pincode ?? null); $custEmail = $invoice->customer_email ?: ($invoice->customer->email ?? null); $custMobile = $invoice->customer_mobile ?: ($invoice->customer->mobile_no ?? null); @endphp {{-- ══ 1) HEADER — Logo + Company Name ══ --}}
{{-- Logo: 55x55px — DomPDF साठी public_path() वापरतो --}} {{-- Company Name + Subtitle + Tagline --}}
Logo
KENT
International Pvt. Ltd.
Address Line 1, City, State – Pincode  |  Email: info@company.com  |  Phone: +91 1234567890
{{-- ══ 2) CUSTOMER | INVOICE ══ --}}
Customer Details
@if($companyName)
{{ $companyName }}
{{ $custName }}
@else
{{ $custName }}
@endif @if($custAddress)
{{ $custAddress }}
@endif @if($custPincode)
{{ $custPincode }}
@endif @if($custEmail)
Email: {{ $custEmail }}
@endif @if($custMobile)
Phone: {{ $custMobile }}
@endif
Invoice Details
Invoice #: {{ $invoice->invoice_number }}
Date: {{ \Carbon\Carbon::parse($invoice->invoice_date)->format('d M, Y') }}
Due Date: {{ \Carbon\Carbon::parse($invoice->due_date)->format('d M, Y') }}
Status: {{ strtoupper($invoice->status) }}
GST Type: {{ strtoupper($invoice->tax_type ?? 'GST') }}
GST %: {{ number_format($invoice->gst_percent ?? 0, 2) }}%
{{-- ══ 3) BILL TO ══ --}}
Bill To
@if($companyName)
{{ $companyName }}
{{ $custName }}
@else
{{ $custName }}
@endif
@if($custAddress){{ $custAddress }}
@endif @if($custPincode){{ $custPincode }}
@endif @if($custEmail)Email: {{ $custEmail }}
@endif @if($custMobile)Phone: {{ $custMobile }}@endif
{{-- ══ 4) 8 SUMMARY BOXES ══ --}} @php $allGroupItems = $invoice->chargeGroups->flatMap(fn($g) => $g->items); $invoiceItemIds = $allGroupItems->pluck('invoice_item_id')->unique()->values(); $invoiceItems = $invoice->items->whereIn('id', $invoiceItemIds); $totalMarkCount = $invoiceItems->pluck('mark_no')->filter()->unique()->count(); $totalCtn = $invoiceItems->sum('ctn'); $totalQty = $invoiceItems->sum('ttl_qty'); $totalCbm = $invoiceItems->sum('ttl_cbm'); $totalKg = $invoiceItems->sum('ttl_kg'); @endphp
Container & Shipment Summary
Container Name
{{ $invoice->container->container_name ?? '—' }}
Container Date
@if($invoice->container && $invoice->container->container_date) {{ \Carbon\Carbon::parse($invoice->container->container_date)->format('d M, Y') }} @else—@endif
Container No.
{{ $invoice->container->container_number ?? '—' }}
Total Mark No.
{{ $totalMarkCount }}
Unique marks
Total CTN
{{ number_format($totalCtn, 0) }}
Cartons
Total QTY
{{ number_format($totalQty, 0) }}
Pieces
Total CBM
{{ number_format($totalCbm, 3) }}
Cubic Meter
Total KG
{{ number_format($totalKg, 2) }}
Kilograms
{{-- ══ 5) CHARGE GROUPS ══ --}} @if($invoice->chargeGroups && $invoice->chargeGroups->count() > 0)
Charge Groups
@foreach($invoice->chargeGroups as $group) @php $groupItemIds = $group->items->pluck('invoice_item_id')->toArray(); $groupInvItems = $invoice->items->whereIn('id', $groupItemIds); @endphp
Group Name Basis Basis Value Rate Total Charge GST % Tax Type Total With GST
{{ $group->group_name ?? 'Group '.$group->id }} {{ strtoupper($group->basis_type) }} {{ number_format($group->basis_value, 3) }} {{ number_format($group->rate, 2) }} ₹{{ number_format($group->total_charge, 2) }} {{ number_format($group->gst_percent ?? 0, 2) }}% {{ strtoupper($group->tax_type ?? 'GST') }} ₹{{ number_format($group->total_with_gst, 2) }}
@if($groupInvItems->count() > 0) @foreach($groupInvItems as $idx => $item) @php $groupBasisTotal = $groupInvItems->sum(function($i) use ($group) { return match($group->basis_type) { 'ttl_qty' => $i->ttl_qty ?? 0, 'ttl_cbm' => $i->ttl_cbm ?? 0, 'ttl_kg' => $i->ttl_kg ?? 0, 'amount' => $i->ttl_amount ?? 0, default => $i->ttl_amount ?? 0, }; }); $itemBasisValue = match($group->basis_type) { 'ttl_qty' => $item->ttl_qty ?? 0, 'ttl_cbm' => $item->ttl_cbm ?? 0, 'ttl_kg' => $item->ttl_kg ?? 0, 'amount' => $item->ttl_amount ?? 0, default => $item->ttl_amount ?? 0, }; $itemCharge = $groupBasisTotal > 0 ? ($itemBasisValue / $groupBasisTotal) * $group->total_charge : 0; $gstPct = $group->gst_percent ?? 0; $itemGst = $itemCharge * $gstPct / 100; $itemTotal = $itemCharge + $itemGst; @endphp @endforeach
# Description Mark No QTY TTL QTY CBM TTL CBM KG TTL KG TTL Amt Rate Total Charge GST % Item GST Item Total
{{ $idx + 1 }} {{ $item->description }} {{ $item->mark_no ?? '—' }} {{ $item->qty ?? 0 }} {{ number_format($item->ttl_qty ?? 0, 0) }} {{ number_format($item->cbm ?? 0, 3) }} {{ number_format($item->ttl_cbm ?? 0, 3) }} {{ number_format($item->kg ?? 0, 2) }} {{ number_format($item->ttl_kg ?? 0, 2) }} ₹{{ number_format($item->ttl_amount ?? 0, 2) }} {{ number_format($group->rate, 2) }} ₹{{ number_format($itemCharge, 2) }} {{ number_format($gstPct, 2) }}% ₹{{ number_format($itemGst, 2) }} ₹{{ number_format($itemTotal, 2) }}
@endif
@endforeach
@endif {{-- ══ GRAND TOTAL ══ --}}
Charge Groups Total: ₹{{ number_format($invoice->charge_groups_total ?? 0, 2) }}
GST Amount ({{ number_format($invoice->gst_percent ?? 0, 2) }}%): ₹{{ number_format($invoice->gst_amount ?? 0, 2) }}
Grand Total: ₹{{ number_format($invoice->grand_total_with_charges ?? 0, 2) }}
{{-- ══ INSTALLMENTS ══ --}} @if($invoice->installments && $invoice->installments->count() > 0)
Payment Installments
@foreach($invoice->installments as $idx => $inst) @endforeach
# Date Payment Method Reference No Amount (₹)
{{ $idx + 1 }} {{ \Carbon\Carbon::parse($inst->installment_date)->format('d M, Y') }} {{ strtoupper($inst->payment_method) }} {{ $inst->reference_no ?? '—' }} ₹{{ number_format($inst->amount, 2) }}
@php $totalPaid = $invoice->installments->sum('amount'); $grandTotal = $invoice->grand_total_with_charges ?? 0; $remaining = max(0, $grandTotal - $totalPaid); @endphp
Total Paid: ₹{{ number_format($totalPaid, 2) }}
Remaining: ₹{{ number_format($remaining, 2) }}
@endif {{-- ══ FOOTER ══ --}}