@php function formatDate($date) { // Check if the date is valid if (!strtotime($date)) { return ''; } return date('d-m-Y', strtotime($date)); } function printTillSpecificLength($string, $maxLength) { // Check if the length of the string is less than or equal to the maxLength if (strlen($string) <= $maxLength) { echo $string; } else { // If the length exceeds maxLength, print only up to maxLength characters echo substr($string, 0, $maxLength); } } function numberToWords($number) { $no = floor($number); $point = round($number - $no, 2) * 100; $hundred = null; $digits_1 = strlen($no); $i = 0; $str = array(); $words = array( '0' => '', '1' => 'One', '2' => 'Two', '3' => 'Three', '4' => 'Four', '5' => 'Five', '6' => 'Six', '7' => 'Seven', '8' => 'Eight', '9' => 'Nine', '10' => 'Ten', '11' => 'Eleven', '12' => 'Twelve', '13' => 'Thirteen', '14' => 'Fourteen', '15' => 'Fifteen', '16' => 'Sixteen', '17' => 'Seventeen', '18' => 'Eighteen', '19' => 'Nineteen', '20' => 'Twenty', '30' => 'Thirty', '40' => 'Forty', '50' => 'Fifty', '60' => 'Sixty', '70' => 'Seventy', '80' => 'Eighty', '90' => 'Ninety' ); $digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore'); while ($i < $digits_1) { $divider = ($i == 2) ? 10 : 100; $number = floor($no % $divider); $no = floor($no / $divider); $i += ($divider == 10) ? 1 : 2; if ($number) { $plural = (($counter = count($str)) && $number > 9) ? 's' : null; $hundred = ($counter == 1 && $str[0]) ? ' and ' : null; $str [] = ($number < 21) ? $words[$number] . " " . $digits[$counter] . $plural . " " . $hundred : $words[floor($number / 10) * 10] . " " . $words[$number % 10] . " " . $digits[$counter] . $plural . " " . $hundred; } else $str[] = null; } $str = array_reverse($str); $result = implode('', $str); $points = ($point) ? "." . $words[$point / 10] . " " . $words[$point = $point % 10] : ''; echo $result . "Rupees "; } if(isset($_GET['copies'])) $copies = $_GET['copies']; else $copies = 'Original'; // BREAK $copies INTO ARRAY $copies = explode(',', $copies); @endphp {{ $bill->bill_number }} @foreach($multi_bills as $bill) @foreach($copies as $copy) @php $grouped_data = []; // Grouping by base GR number (e.g. 2512 for 2512, 2512A, 2512B) foreach($bill->bill_desc as $bill_desc) { preg_match('/^\d+/', $bill_desc['gr_number'], $matches); $base_gr = $matches[0] ?? $bill_desc['gr_number']; $grouped_data[$base_gr][] = $bill_desc; } $grand_amount = 0; $serial = 1; @endphp @foreach($grouped_data as $base_gr => $entries) @php $combined_gr_numbers = []; $combined_invoice_numbers = []; $freight_total = 0; $gr_chg_total = 0; $load_chg_total = 0; $unload_chg_total = 0; $mp_chg_total = 0; $detention_total = 0; $other_total = 0; $gross_total = 0; $weight_total = 0; $vehicle_no = ''; $vehicle_type = ''; $from = ''; $to = ''; $date = ''; @endphp @foreach($entries as $entry) @php $combined_gr_numbers[] = $entry['gr_number']; $freight_total += $entry['freight']; $gr_chg_total += $entry['gr_chg']; $load_chg_total += $entry['pod_payment_dynamic_fields']->loading_chg ?? 0; $unload_chg_total += $entry['pod_payment_dynamic_fields']->unloading_chg ?? 0; $detention_total += $entry['load_detention'] + $entry['unload_detention']; $other_total += 0; $gross_total += $entry['total_without_gst']; $weight_total += $entry['gr_desc'][0]->material_weight ?? 0; $grand_amount += $entry['total_without_gst']; if(isset($entry['bookGr']['vehicle']['vehicle_number'])) { $vehicle_no = $entry['bookGr']['vehicle']['vehicle_number']; } if(isset($entry['bookGr']['vehicle']['vehicle_type'])) { $vehicle_type = $entry['bookGr']['vehicle']['vehicle_type']; } $from = $entry['source']['station_name'] ?? ''; $to = $entry['destination']['station_name'] ?? ''; $date = formatDate($entry['gr_date']); $toll_amt = $entry['bookGr']->toll_amt ?? ''; if(isset($entry['bookGr']['gr_desc'])) { foreach($entry['bookGr']['gr_desc'] as $invoice) { $combined_invoice_numbers[] = $invoice['invoice_number']; } } @endphp @endforeach @endforeach @if(!$bill->is_rcm) @endif
BILL NO :- {{ $bill->bill_number }} SAC CODE :- GTA 9967 FREIGHT BILL DATE :- {{ formatDate($bill->bill_date) }}
GSTIN NO :- {{ $company->gst_number }}
_img

{{ $company->company_name }}

{{ $company->address1}}

Email :- {{ $company->email }}, Phone :- {{ $company->mob1 }},{{ $company->mob2 }}

{{ $company->jurisdiction }}

Udhyam : {{ $company->cin }}

Sr No GR No Date Vehicle No From To Weight (Kg) Vehicle Type Invoice No Freight Charges {{$bill['extra_chg_label'] ?? ''}} GR Charges Loading Charges Unloading Charges Multiple Point Charges Detension Charges Other Charges Gross Total
{{ $serial++ }} {{ implode(', ', $combined_gr_numbers) }} {{ $date }} {{ $vehicle_no }} {{ $from }} {{ $to }} {{ $weight_total }} {{ $vehicle_type }} {{ implode(', ', $combined_invoice_numbers) }} {{ $freight_total }} {{$toll_amt}} {{ $gr_chg_total }} {{ $load_chg_total }} {{ $unload_chg_total }} {{ $mp_chg_total }} {{ $detention_total }} {{ $other_total }} {{ $gross_total }}
* Night Chargs. # Vehicle Return Charges TOTAL {{$grand_amount}}
SGST   {{ $bill->sgst_percent }}% {{ $bill->total_sgst_amount }}
CGST   {{ $bill->cgst_percent }}% {{ $bill->total_cgst_amount }}
IGST   {{ $bill->igst_percent }}% {{ $bill->total_igst_amount }}
@if($bill['is_rcm']) *Note:-GST is on Reverse Charge Basis @endif GRAND TOTAL {{ $bill->grand_total_amount }}
Customer Details:- Bank Details:- @if ($company->company_name == 'BHAGYALAKSHMI TRANSPORT') _img @else _img @endif
M/S {{ $bill['acc_party']['party']['party_name']}} {{$company->bank_name}}
{{ $bill['acc_party']['party']['address1']}} {{$company->bank_branch}}
{{ $bill['acc_party']['party']['state']}} A/C No-{{$company->account_number}}
GSTIN-{{ $bill['acc_party']['party']['gst_number']}} IFSC-{{$company->ifsc}} For {{ $company->company_name }}
Payment Term: {{ $bill->acc_party->party->payment_term }}
@endforeach @endforeach