@php $watermarkText = trim($quotation->company->company_name ?? ''); @endphp

Quotation

@php $brands = $quotation->quotationProducts->pluck('product.brand')->filter()->unique('id'); @endphp @php $rawNumber = $quotation->quotation_no; $number = preg_replace('/[^0-9]/', '', $rawNumber); $prefix = $quotation->company->quotation_prefix ?? ''; $suffix = $quotation->company->quotation_suffix ?? ''; @endphp @if (!empty($quotation->subject)) @endif {{-- Amount in Words --}} {{-- Terms of Instructions --}} {{-- Bank Details + Signature --}}
@php $logoPath = null; if (!empty($quotation->company?->company_logo)) { $tempPath = public_path($quotation->company->company_logo); if (file_exists($tempPath) && !is_dir($tempPath)) { $logoPath = $tempPath; } } if (!$logoPath) { $defaultLogo = public_path('assets/template/images/logo/pdf-logo.png'); if (file_exists($defaultLogo) && !is_dir($defaultLogo)) { $logoPath = $defaultLogo; } } @endphp @if ($logoPath) @endif

{{ $quotation->company->company_name }}

@if (!empty($quotation->company->subject))

({{ $quotation->company->subject }})

@endif

{{ $quotation->bill_from->address_line_1 ?? '' }} {{ $quotation->bill_from->city ?? '' }},{{ $quotation->bill_from->state ?? '-' }} {{ $quotation->bill_from->pincode ?? '' }}

Ph: +91 {{ $quotation->company->primary_contact ?? '' }},+91 {{ $quotation->company->alternate_contact_no ?? '' }}
Email: {{ $quotation->company->primary_email_address ?? '' }} @if (!empty($quotation->company->primary_email_address) && !empty($quotation->company->support_email)) / @endif {{ $quotation->company->support_email ?? '' }}

GST: {{ $quotation->company->gst_vat_number ?? '' }}

@foreach ($brands as $brand) @if (!empty($brand->logo)) @endif @endforeach
@if (!empty($quotation->kind_attention))

Kind Attention:{{ $quotation->kind_attention }}

@endif
Customer Name : {{ $quotation->client->name ?? '-' }}
Address : {{ $quotation->client->registered_address ?? 'N/A' }} @if (!empty($quotation->client->city) || !empty($quotation->client->pincode)) , {{ $quotation->client->city ?? '' }} - {{ $quotation->client->pincode ?? '' }} @endif

Quotation No

{{ $prefix ?: '-' }} | {{ $suffix ?: '-' }} | {{ $number ?: '000' }}

Quotation Date

{{ \Carbon\Carbon::parse($quotation->quote_date)->format('d-M-y') }}

Customer Reference ID

{{ $quotation->customer_reference_id ?? '-' }}

Sales Person Name

{{ $quotation->user->name ?? 'N/A' }}{{ !empty($quotation->user->mobile) ? ':' . $quotation->user->mobile : '' }}

Subject: {{ $quotation->subject }}

{!! $quotation->cover_letter !!}

@php // ── Tax type ── $fromState = strtolower(trim(optional($quotation->bill_from)->state ?? '')); $toState = strtolower(trim(optional($quotation->bill_to)->state ?? '')); $isIntraState = $fromState !== '' && $fromState === $toState; $hasCGST_SGST = $isIntraState; $hasIGST = !$isIntraState; $discountType = (int) ($quotation->discount_type ?? 2); $hasDiscount = in_array($discountType, [3, 4]); $discountLabel = $discountType === 4 ? 'Disc ₹' : 'Disc %'; $showDiscount = $discountType != 2; $showHsnCol = (bool) ($quotation->show_hsn ?? true); $showCatCol = (bool) ($quotation->show_cat_no ?? true); $showBrandCol = (bool) ($quotation->show_brand ?? true); $showDescriptionCol = (bool) ($quotation->show_desc ?? true); // ── GST rate per line ── // Prefer the product master rate. Stored line tax can already carry the // overall discount (depends on which save path wrote the row), which would // print an odd rate like 16.94% instead of 18%. $lineGstRate = function ($prod) { $rate = floatval(optional($prod->product)->gst ?? 0); if ($rate > 0) { return $rate; } $taxable = floatval($prod->amount ?? 0); $storedTax = floatval($prod->cgst ?? 0) + floatval($prod->sgst ?? 0) + floatval($prod->igst ?? 0); return $taxable > 0 ? round(($storedTax / $taxable) * 100, 2) : 0; }; // ── Compute GST rate labels ── $taxRates = []; foreach ($quotation->quotationProducts as $prod) { $rate = $lineGstRate($prod); if ($rate > 0) { $taxRates[(string) $rate] = $rate; } } $taxRateLabel = implode(', ', array_map(fn($r) => $r . '%', $taxRates)); $cgstRateLabel = implode(', ', array_map(fn($r) => $r / 2 . '%', $taxRates)); // ── Column count (used for colspans) ── // Columns: S.No | Product | [Desc] | [Brand] | [Cat] | [HSN] | Unit | Price | Qty | [Disc] | Taxable | [CGST] | [SGST] | [IGST] | Amount $colCount = 1 + // S.No 1 + // Product // ($showDescriptionCol ? 1 : 0) + ($showBrandCol ? 1 : 0) + ($showCatCol ? 1 : 0) + ($showHsnCol ? 1 : 0) + 1 + // Unit 1 + // Price 1 + // Qty ($hasDiscount ? 1 : 0) + 1 + // Taxable ($hasCGST_SGST ? 2 : 0) + ($hasIGST ? 1 : 0) + 1; // Amount // Cols before Taxable (used in sub-total label colspan) $subTotalColspan = 1 + // S.No 1 + // Product // ($showDescriptionCol ? 1 : 0) + ($showBrandCol ? 1 : 0) + ($showCatCol ? 1 : 0) + ($showHsnCol ? 1 : 0) + 1 + // Unit 1; // Price // Cols from Taxable to last col (for grand-total label colspan) // = Taxable + [CGST] + [SGST] + [IGST] + Amount => we keep Amount separate $taxColCount = ($hasCGST_SGST ? 2 : 0) + ($hasIGST ? 1 : 0); // colspan for "Grand Total label" cell // covers: S.No … Disc … Taxable … CGST/SGST/IGST (everything except Amount) $grandTotalColspan = $colCount - 1; // all cols except Amount @endphp {{-- S.No --}} {{-- Product --}} @if ($showDescriptionCol) {{-- Desc --}} @endif @if ($showBrandCol) {{-- Brand --}} @endif @if ($showCatCol) {{-- Cat No --}} @endif @if ($showHsnCol) {{-- HSN --}} @endif {{-- Unit --}} {{-- Price --}} {{-- Qty --}} @if ($hasDiscount) {{-- Disc --}} @endif {{-- Taxable --}} @if ($hasCGST_SGST) {{-- CGST --}} {{-- SGST --}} @endif @if ($hasIGST) {{-- IGST --}} @endif {{-- Amount --}} {{-- @if ($showDescriptionCol) @endif --}} @if ($showBrandCol) @endif @if ($showCatCol) @endif @if ($showHsnCol) @endif @if ($hasDiscount) @endif @if ($hasCGST_SGST) @endif @if ($hasIGST) @endif @if ($hasCGST_SGST) @endif @php $totalTaxableValue = 0; $totalCGST = 0; $totalSGST = 0; $totalIGST = 0; $grandTotal = 0; @endphp @foreach ($quotation->quotationProducts as $index => $product) @php // Line rows print gross values; the overall discount is applied // once in the summary block below. $taxableValue = floatval($product->amount ?? 0); $lineTax = ($taxableValue * $lineGstRate($product)) / 100; $cgst = $hasCGST_SGST ? $lineTax / 2 : 0; $sgst = $hasCGST_SGST ? $lineTax / 2 : 0; $igst = $hasIGST ? $lineTax : 0; $lineTotal = $taxableValue + $cgst + $sgst + $igst; $totalTaxableValue += $taxableValue; $totalCGST += $cgst; $totalSGST += $sgst; $totalIGST += $igst; $grandTotal += $lineTotal; @endphp {{-- @if ($showDescriptionCol) @endif --}} @if ($showBrandCol) @endif @if ($showCatCol) @endif @if ($showHsnCol) @endif @if ($hasDiscount) @endif @if ($hasCGST_SGST) @endif @if ($hasIGST) @endif @endforeach @php $totalQty = $quotation->quotationProducts->sum('quantity'); $otherChargesTotal = 0; $otherChargesCGST = 0; $otherChargesSGST = 0; $otherChargesIGST = 0; @endphp {{-- ── OTHER CHARGES ── --}} @foreach ($quotation->charges as $charge) @php $chargeAmt = floatval($charge->amount ?? 0); $chargeTax = floatval($charge->gst ?? 0); $otherChargesTotal += $chargeAmt; if ($hasCGST_SGST) { $otherChargesCGST += $chargeTax / 2; $otherChargesSGST += $chargeTax / 2; } else { $otherChargesIGST += $chargeTax; } @endphp @endforeach @if ($otherChargesTotal > 0) @php // Label colspan = everything before Taxable column + Disc col $otherChargeLabelColspan = $subTotalColspan + ($hasDiscount ? 1 : 0); $otherChargeLineTotal = $otherChargesTotal + $otherChargesCGST + $otherChargesSGST + $otherChargesIGST; @endphp @foreach ($quotation->charges as $charge) @php $singleChargeAmt = floatval($charge->amount ?? 0); $singleChargeTax = floatval($charge->gst ?? 0); $singleCGST = $hasCGST_SGST ? $singleChargeTax / 2 : 0; $singleSGST = $hasCGST_SGST ? $singleChargeTax / 2 : 0; $singleIGST = $hasIGST ? $singleChargeTax : 0; $singleLineTotal = $singleChargeAmt + $singleCGST + $singleSGST + $singleIGST; @endphp {{-- Qty cell (shows dash for charges) --}} {{-- Taxable --}} @if ($hasCGST_SGST) @endif @if ($hasIGST) @endif @endforeach @endif {{-- ── SUB TOTAL ── --}} @php // Gross summary (before the overall discount) = products + other charges $summaryTaxable = $totalTaxableValue + $otherChargesTotal; $summaryCGST = $totalCGST + $otherChargesCGST; $summarySGST = $totalSGST + $otherChargesSGST; $summaryIGST = $totalIGST + $otherChargesIGST; $summaryTax = $summaryCGST + $summarySGST + $summaryIGST; $summarySubTotal = $summaryTaxable + $summaryTax; // The overall discount reduces the taxable value, so the tax must follow it. // It applies to the product lines only — other charges are never discounted. $overallDiscount = $showDiscount && $discountType == 1 ? floatval($quotation->discount_amount ?? 0) : 0; $discountRatio = $totalTaxableValue > 0 ? max($totalTaxableValue - $overallDiscount, 0) / $totalTaxableValue : 1; $netTaxable = $totalTaxableValue * $discountRatio + $otherChargesTotal; $netCGST = $totalCGST * $discountRatio + $otherChargesCGST; $netSGST = $totalSGST * $discountRatio + $otherChargesSGST; $netIGST = $totalIGST * $discountRatio + $otherChargesIGST; $netTax = $netCGST + $netSGST + $netIGST; $finalRoundOff = floatval($quotation->roundoff ?? 0); $summaryTotal = floatval( $quotation->total_amount ?? $netTaxable + $netTax + $finalRoundOff, ); @endphp @if ($hasDiscount) @endif {{-- Taxable = products + charges --}} @if ($hasCGST_SGST) @endif @if ($hasIGST) @endif {{-- Amount = this row's own taxable + tax, so the row adds up --}} {{-- ── OVERALL DISCOUNT (discount_type = 1 only) ── --}} @if ($showDiscount && $discountType == 1 && ($quotation->discount_amount ?? 0) > 0) @php $discountLabelColspan = $grandTotalColspan; // all cols except Amount @endphp @endif {{-- ── TAXABLE AMOUNT SUMMARY ── --}} {{-- ── TAX SUMMARY (on the discounted taxable value) ── --}} @if ($hasCGST_SGST) @else @endif {{-- ── ROUND OFF ── --}} @if ($finalRoundOff != 0) @endif {{-- ── TOTAL AMOUNT AFTER TAX SUMMARY ── --}}
S.No Item DescriptionDescBrandCat NoHSNUnit Price Qty{{ $discountLabel }}TaxableGST{{ $taxRateLabel ? ' ' . $taxRateLabel : '' }}IGST{{ $taxRateLabel ? ' ' . $taxRateLabel : '' }}Amount
CGST{{ $cgstRateLabel ? ' ' . $cgstRateLabel : '' }} SGST{{ $cgstRateLabel ? ' ' . $cgstRateLabel : '' }}
{{ $index + 1 }} {{ $product->product_name ?? '-' }} @if ($showDescriptionCol && !empty($product->description)) - {{ $product->description }} @endif {{ $product->description ?? '-' }} {{ $product->product->brand->value ?? '-' }}{{ $product->product->cat ?? '-' }}{{ $product->product->hsn_code ?? '-' }} {{ $product->master->value ?? 'NOS' }} ₹{{ number_format($product->rate, 2) }} {{ $product->quantity ?? 0 }} @if ($product->discount != 0) @if ($discountType === 4) ₹{{ number_format($product->discount, 2) }} @else {{ $product->discount }}% @endif @endif ₹{{ number_format($taxableValue, 2) }} ₹{{ number_format($cgst, 2) }} ₹{{ number_format($sgst, 2) }} ₹{{ number_format($igst, 2) }} ₹{{ number_format($lineTotal, 2) }}
{{ $charge->otherCharge->name ?? 'Other Charge' }} : - ₹{{ number_format($singleChargeAmt, 2) }} ₹{{ number_format($singleCGST, 2) }} ₹{{ number_format($singleSGST, 2) }} ₹{{ number_format($singleIGST, 2) }} ₹{{ number_format($singleLineTotal, 2) }}
Sub Total : {{ $totalQty }} ₹{{ number_format($summaryTaxable, 2) }} ₹{{ number_format($summaryCGST, 2) }} ₹{{ number_format($summarySGST, 2) }} ₹{{ number_format($summaryIGST, 2) }} ₹{{ number_format($summarySubTotal, 2) }}
Overall Discount @if ($quotation->overall_product_discount == 1) ({{ $quotation->overall_discount_amount }}%) @else (-) @endif : -₹{{ number_format($quotation->discount_amount, 2) }}
Taxable Amount : ₹{{ number_format($netTaxable, 2) }}
CGST{{ $cgstRateLabel ? ' @ ' . $cgstRateLabel : '' }} : ₹{{ number_format($netCGST, 2) }}
SGST{{ $cgstRateLabel ? ' @ ' . $cgstRateLabel : '' }} : ₹{{ number_format($netSGST, 2) }}
IGST{{ $taxRateLabel ? ' @ ' . $taxRateLabel : '' }} : ₹{{ number_format($netIGST, 2) }}
Round Off : {{ $finalRoundOff >= 0 ? '+' : '-' }}₹{{ number_format(abs($finalRoundOff), 2) }}
Total Amount After Tax : ₹{{ number_format($summaryTotal, 2) }}

Amount Chargeable (in words)

{{ \App\Helpers\Helper::numberToWords($quotation->total_amount) }} Only

{{-- Terms & Conditions --}}

Terms & Conditions

@if ($quotation->time_period_type)

Delivery terms: @if ((string) $quotation->time_period_type === '3') Immediate @else {{ $quotation->time_period }} {{ $quotation->time_period_type == 1 ? 'WEEK' : 'DAY(S)' }} @endif from the date of your Purchase order along with PAYMENT IMMEDIATE 100%.

@endif @php $rawInstruction = $quotation->standing_instruction ?? ''; $cleanInstruction = trim( strip_tags( html_entity_decode( preg_replace('/(| )/i', ' ', $rawInstruction), ), ), ); @endphp @if (!empty($cleanInstruction))

{!! $rawInstruction !!}

@endif {{-- Other Terms and Special Instructions --}} @php $rawThankingNotes = $quotation->thanking_notes ?? ''; $cleanThankingNotes = trim( strip_tags( html_entity_decode(preg_replace('/( @if (!empty($cleanThankingNotes))

Other Terms and Special Instructions

{!! $rawThankingNotes !!}
@endif

Bank Account Details

Account Holder Name : {{ $quotation->bank->account_holder_name ?? 'N/A' }}
Bank Name : {{ $quotation->bank->bank_name ?? 'N/A' }}
Branch Name : {{ $quotation->bank->branch_name ?? 'N/A' }}
Account Number : {{ $quotation->bank->account_no ?? 'N/A' }}
IFSC Code : {{ $quotation->bank->ifsc ?? 'N/A' }}

For {{ $quotation->company->company_name ?? 'N/A' }}



@php $esignPath = null; if (!empty($quotation->company?->esign)) { $tempSignPath = public_path($quotation->company->esign); if (file_exists($tempSignPath) && !is_dir($tempSignPath)) { $esignPath = $tempSignPath; } } @endphp @if ($esignPath) Authorized Signature @endif

(Authorized Signature)