@php $party = $party ?? $purchaseBill->vendor; $docOpts = $docSettings['options'] ?? []; $docLbl = $docSettings['labels'] ?? []; $statusKey = $purchaseBill->status; $primarySig = $settings['primary_signature_label'] ?? 'Provider Signature'; $secondarySig = $settings['secondary_signature_label'] ?? 'Receiver Signature'; $showTaxable = $settings['show_total_taxable_value'] ?? true; $roundOff = $settings['round_off_amount'] ?? false; $fmtTotal = function ($n) use ($roundOff) { return $roundOff ? number_format(round($n), 0) : number_format($n, 2); }; $billLines = $party ? $party->billingAddressLines() : []; $shipLines = $shipToLines ?? ($company->fullAddressLines() ?? $billLines); $totalAmount = (float) $purchaseBill->grand_total; $purchaseBillTitle = $purchaseBillTitle ?? \App\Helpers\PurchaseBillDocumentSettings::title($company->id ?? null); $documentCopyLabel = $documentCopyLabel ?? ($documentCopies['original'] ?? 'Original Copy'); $docId = $docId ?? 'purchase-bill-doc'; $hasDiscountCol = $purchaseBill->items->contains(fn ($li) => (float) $li->discount_percent > 0); $forPdf = $forPdf ?? false; if ($forPdf) { $logoImage = $logoPath ?? \App\Helpers\CompanyMedia::pdfImagePath($company->logo_path ?? null); $signatureImage = $signaturePath ?? \App\Helpers\CompanyMedia::pdfImagePath($company->signature_image_path ?? null); } else { $logoImage = $logoPath ?? $logoSrc ?? \App\Helpers\CompanyMedia::imageSource($company->logo_path ?? null); $signatureImage = $signaturePath ?? $signatureSrc ?? \App\Helpers\CompanyMedia::imageSource($company->signature_image_path ?? null); } @endphp
@if(! $forPdf && ! ($forPublic ?? false)) @if($statusKey === 'open')
Open
@elseif($statusKey === 'paid')
Paid
@elseif($statusKey === 'partial')
Partial
@elseif($statusKey === 'void')
Void
@elseif($statusKey === 'draft')
Draft
@endif @endif
@if($logoImage) @endif

{{ $company->name ?? 'Company' }}

@php $companyLines = $company->fullAddressLines(); @endphp @if(! empty($companyLines)) @foreach($companyLines as $line)

{{ $line }}

@endforeach @elseif($company->address ?? $company->city)

{{ collect([$company->address, $company->city, $company->state, $company->pincode, $company->country])->filter()->implode(', ') }}

@endif @if($company->phone)

Phone: {{ $company->phone }}

@endif @if($company->email)

Email: {{ $company->email }}

@endif @if($company->gstin ?? null)

GSTIN: {{ $company->gstin }}

@endif

{{ $purchaseBillTitle }}

#{{ $purchaseBill->bill_number }}

{{ $documentCopyLabel }}

@if($docOpts['show_amount_due'] ?? true)
Amount Due: ₹ {{ number_format((float) $purchaseBill->amount_due, 2) }}
@endif @if($purchaseBill->due_date) @endif @if($purchaseBill->po_number) @endif @if($purchaseBill->po_date) @endif @if($purchaseBill->vendor_invoice_number) @endif @if(($gstMode ?? false) && ($placeOfSupplyLabel ?? null)) @endif
{{ $docLbl['issue_date'] ?? 'Issue Date' }} {{ $purchaseBill->bill_date->format('d - M - Y') }}
{{ $docLbl['due_date'] ?? 'Due Date' }} {{ $purchaseBill->due_date->format('d - M - Y') }}
{{ $docLbl['po_number'] ?? 'PO no' }} {{ $purchaseBill->po_number }}
{{ $docLbl['po_date'] ?? 'PO date' }} {{ $purchaseBill->po_date->format('d - M - Y') }}
{{ $docLbl['vendor_invoice_number'] ?? 'Invoice number' }} {{ $purchaseBill->vendor_invoice_number }}
Place of Supply {{ $placeOfSupplyLabel }}
@if($docOpts['show_shipping_address'] ?? false) @endif
@if($party)

{{ $party->name }}

@if(($docOpts['show_contact_person'] ?? true) && ($party->contact_person ?? null))

{{ $party->contact_person }}

@endif @if($party->phone ?? null)

Phone: {{ $party->phone }}

@endif @if($party->email ?? null)

Email: {{ $party->email }}

@endif @foreach($billLines as $line)

{{ $line }}

@endforeach @if($party->gstin ?? null)

GSTIN: {{ $party->gstin }}

@endif @endif
@foreach($shipLines as $line)

{{ $line }}

@endforeach @if(empty(array_filter($shipLines)))

Same as billing address

@endif
@if($gstMode ?? false) @include('partials.admin.document-gst-items', [ 'documentItems' => $purchaseBill->items, 'gstIsIgst' => $gstIsIgst ?? false, 'docLbl' => $docLbl, ]) @else @if($hasDiscountCol) @endif @foreach($purchaseBill->items as $i => $line) @php $qtyDisplay = number_format($line->quantity, 0) == $line->quantity ? (string) (int) $line->quantity : number_format($line->quantity, 3); $qtyUom = trim($qtyDisplay . ($line->unit ? ' ' . $line->unit : '')); @endphp @if($hasDiscountCol) @endif @endforeach
# {{ $docLbl['col_item'] ?? 'Item' }} & {{ $docLbl['col_description'] ?? 'Description' }} Qty / UoM Price (₹){{ $docLbl['col_discount'] ?? 'Discount' }}{{ $docLbl['col_tax'] ?? 'Tax' }} {{ $docLbl['col_total'] ?? 'Amount' }}
{{ $i + 1 }} {{ $line->item_name }} @if($line->description) {{ $line->description }} @endif {{ $qtyUom ?: '—' }} {{ number_format($line->rate, 2) }} @if((float) $line->discount_percent > 0) {{ rtrim(rtrim(number_format($line->discount_percent, 2), '0'), '.') }}% @else — @endif @if($line->tax_amount > 0) ₹ {{ number_format($line->tax_amount, 2) }} @if($line->tax_rate > 0) {{ rtrim(rtrim(number_format($line->tax_rate, 2), '0'), '.') }}% @endif @else — @endif ₹ {{ number_format($line->amount, 2) }}
@endif
@include('partials.admin.document-bank-details', [ 'company' => $company, 'settings' => $settings, 'showBank' => false, ]) @if($purchaseBill->has_total_quantity && $purchaseBill->total_quantity)

Total quantity: {{ $purchaseBill->total_quantity }} {{ $purchaseBill->total_quantity_unit }}

@endif @if($purchaseBill->terms)

{{ $docLbl['terms'] ?? 'Terms & Conditions' }}

{{ $purchaseBill->terms }}

@endif
@include('partials.admin.document-totals', [ 'document' => $purchaseBill, 'gstMode' => $gstMode ?? false, 'gstSummaryRows' => $gstSummaryRows ?? [], 'taxBreakdown' => $taxBreakdown ?? [], 'showTaxable' => $showTaxable, 'fmtTotal' => $fmtTotal, 'docOpts' => $docOpts, 'docLbl' => $docLbl, ]) @if((float) $purchaseBill->discount_amount > 0)
Discount (-) ₹ {{ number_format($purchaseBill->discount_amount, 2) }}
@endif @if(abs((float) $purchaseBill->round_off) >= 0.01)
Rounded Off ₹ {{ number_format($purchaseBill->round_off, 2) }}
@endif @if($docOpts['show_total_in_words'] ?? true)

Amount in Words: {{ $amountInWords }}

@endif @if($docOpts['show_primary_signature'] ?? true) @endif @if($docOpts['show_secondary_signature'] ?? false) @endif
@if($signatureImage) @else
@endif

{{ $primarySig }}

{{ $secondarySig }}