@php use App\Helpers\CommonHelper; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; $companyId = $companyId ?? Session::get('run_company'); $printDate = strtoupper(date('d-M-y h:i A')); $orderDate = strtoupper(date('d-M-y', strtotime($sale_quotations->quotation_date))); $validityDate = !empty($sale_quotations->q_valid_up_to) ? strtoupper(date('d-M-y', strtotime($sale_quotations->q_valid_up_to))) : ''; $saleOrderNo = DB::connection('mysql2')->table('sales_order') ->where('purchase_order_contract', $sale_quotations->id) ->where('status', 1) ->value('so_no'); if (empty($saleOrderNo)) { $numericSo = ltrim(preg_replace('/\D/', '', (string) ($sale_quotations->quotation_no ?? '')), '0'); $saleOrderNo = $numericSo !== '' ? $numericSo : ($sale_quotations->quotation_no ?? ''); } $paymentTerm = trim($sale_quotations->delivery_term ?? ''); $preparedBy = strtoupper(trim($sale_quotations->created_by ?? '')); $printBy = strtoupper(trim(Auth::user()->name ?? '')); $customerPhone = ''; $customerEmail = ''; if (($sale_quotations->customer_type ?? '') === 'customer') { $customerRow = DB::connection('mysql2')->table('customers') ->where('id', $sale_quotations->customer_id) ->select('name', 'address', 'contact', 'email') ->first(); $customerName = strtoupper($customerRow->name ?? ''); $customerAddress = strtoupper(trim($customerRow->address ?? '')); $customerPhone = trim($customerRow->contact ?? ''); $customerEmail = trim($customerRow->email ?? ''); $kindAtt = strtoupper(trim($sale_quotations->attention ?: ($customerRow->name ?? ''))); } else { $prospect = CommonHelper::get_prospect($sale_quotations->prospect_id); $customerName = strtoupper($prospect->company_name ?? ''); $customerAddress = strtoupper(trim($prospect->company_address ?? '')); $kindAtt = strtoupper(trim($sale_quotations->attention ?? '')); if (!empty($prospect->contact_id)) { $contact = CommonHelper::get_contacts($prospect->contact_id); $customerPhone = trim($contact->phone ?? ''); $customerEmail = trim($contact->email ?? ''); } } $productCount = count($sale_quotation_data); $grossTotal = 0; $taxTotal = 0; $netTotal = 0; @endphp
Kind Att. : {{ $kindAtt }}
Messers. : {{ $customerName }}
Address : {{ $customerAddress }}
Phone : {{ $customerPhone }}
E-Mail. : {{ $customerEmail }}
Enquiry No. : {{ $sale_quotations->enquiry_no ?? '' }}
Sale Order No. : {{ $saleOrderNo }}
Order Date : {{ $orderDate }}
Validity Date : {{ $validityDate }}
Payment Term : {{ strtoupper($paymentTerm) }}
Prepared By : {{ $preparedBy }}
Print Date : {{ $printDate }}
Print By : {{ $printBy }}
@foreach ($sale_quotation_data as $value) @php $item = DB::connection('mysql2')->table('subitem as s') ->leftJoin(env('DB_DATABASE') . '.uom as u', 's.uom', '=', 'u.id') ->where('s.id', $value->item_id) ->select('s.sub_ic', 'u.uom_name') ->first(); $itemName = strtoupper(trim($item->sub_ic ?? '')); if (!empty($value->item_description)) { $itemName = strtoupper(trim(strip_tags($value->item_description))); } $uomName = strtoupper(CommonHelper::get_uom_name($value->uom_id) ?: ($item->uom_name ?? '')); $qty = (float) ($value->qty ?? 0); $rate = (float) ($value->unit_price ?? 0); $grossAmt = (float) ($value->total_amount ?? 0); $lineTaxRate = (float) ($value->sales_tax_rate ?? $gstRate ?? 0); $lineTaxAmt = ($grossAmt / 100) * $lineTaxRate; $lineNetAmt = (float) ($value->amount_after_sale_tax ?? ($grossAmt + $lineTaxAmt)); $remarksText = trim(number_format($qty, 4, '.', '') . ' ' . $uomName); $grossTotal += $grossAmt; $taxTotal += $lineTaxAmt; $netTotal += $lineNetAmt; @endphp @endforeach
Particulars Unit Quantity Rate Gross Amt. Tax Tax Amt. Net Amt. Remarks
{{ $itemName }} {{ $uomName }} {{ number_format($qty, 4, '.', '') }} {{ number_format($rate, 4, '.', '') }} {{ number_format($grossAmt, 2) }} {{ $lineTaxRate > 0 ? rtrim(rtrim(number_format($lineTaxRate, 2), '0'), '.') . '%' : '' }} {{ $lineTaxAmt > 0 ? number_format($lineTaxAmt, 2) : '' }} {{ number_format($lineNetAmt, 2) }} {{ $remarksText }}
@php $cartageAmount = (float) ($sale_quotations->cartage_amount ?? 0); $finalNetTotal = $netTotal + $cartageAmount; if ($finalNetTotal <= 0 && !empty($sale_quotations->total_amount_after_sale_tax)) { $finalNetTotal = (float) $sale_quotations->total_amount_after_sale_tax; } $amountWords = strtoupper(saleQuotationAmountInWords($finalNetTotal)); @endphp
Total No of Products : {{ $productCount }}

Amount In Words : {{ $amountWords }} Rupees Only.
Gross Amount : {{ number_format($grossTotal, 2) }}
Tax Amount : {{ $taxTotal > 0 ? number_format($taxTotal, 2) : '' }}
Cartage Charges : {{ number_format($cartageAmount, 2) }}
Net Amount : {{ number_format($finalNetTotal, 2) }}