@php $no_of_bills = 0; @endphp @foreach($bills as $bill) @php $no_of_bills = $no_of_bills + 1; $isNewBill = isset($bill->rounding_amount) && !is_null($bill->rounding_amount) && $bill->rounding_amount != 0; if ($isRoundingEnabled) { if ($isNewBill) { $finalGrandTotal = $bill->grandtotal; $roundValue = $bill->rounding_amount; } else { $grandAmount = $bill->grandtotal; $ceilAmount = ceil($grandAmount); $floorAmount = floor($grandAmount); $roundValue = $ceilAmount - $grandAmount; $finalGrandTotal = ($roundValue > 0 && $roundValue <= 0.50) ? $ceilAmount : $floorAmount; } } else { $finalGrandTotal = $isNewBill ? $bill->grandtotal - $bill->rounding_amount : $bill->grandtotal; $roundValue = 0; } $billAmount = $bill->amount; $serviceChAmount = ($billAmount * $bill->service_charge_percent)/100; $amountAndService = $billAmount + $serviceChAmount; $fuelAmount = ($amountAndService * $bill->fchpercent)/100; $otherChAmount = $bill->other_charge; $totAmount = $amountAndService + $fuelAmount + $otherChAmount; $billitems = DB::table('bill_item_preferences')->where(['client_id'=>$bill->client_id])->where(['branch_id'=>$branchId])->select(['bill_item'])->first(); $billitempreferences = ''; if ($billitems !="" || $billitems != NULL || $billitems != null) { $billitempreferences = json_decode($billitems->bill_item, true); } else { $billitems = DB::table('bill_item_preferences')->where(['client_id'=>'0'])->where(['branch_id'=>$branchId])->select(['bill_item'])->first(); $billitempreferences = json_decode($billitems->bill_item, true); } $totalColsValue = 12; foreach ($billitempreferences as $key => $value) { if (in_array($key, [ 'receiver', 'center', 'remark', 'package_type', 'carrier', 'weight', 'insurance', 'fov_amt', 'parcel_value' ])) { if ($value == 0) { $totalColsValue--; } } } $parcels = DB::table('bills as bl') ->leftJoin('parcels as p','p.client_id','=','bl.clientid') ->leftJoin('receivers as r','r.id','=','p.receiver_id') ->where(['bl.id'=>$bill->id, 'p.bill_id'=>$bill->id, 'p.is_international'=>0, 'bl.branch_id'=>$branchId]) ->whereBetween('p.date', array($bill->start_date, $bill->end_last)) ->select([DB::raw('SUM(p.net_amt) as total_amount')])->get(); $all_parcels = DB::table('bills as bl') ->leftJoin('parcels as p','p.client_id','=','bl.clientid') ->leftJoin('receivers as r','r.id','=','p.receiver_id') ->leftJoin('centers as c','c.id','=','p.center_id') ->leftJoin('carriers as car','car.id','=','p.carrier_id') ->leftJoin('clients as clnt','clnt.id','=','bl.clientid') ->leftJoin('default_packagetypes as dp','dp.id','=','p.package_type') ->where(['bl.id'=>$bill->id, 'p.bill_id'=>$bill->id, 'p.is_international'=>0, 'bl.branch_id'=>$branchId]) ->whereBetween('p.date', array($bill->start_date, $bill->end_last)) ->select([ 'p.amont', 'p.doc_amt', 'p.oda_amt', 'p.fov_amt', 'p.parcel_value_amt', 'p.net_amt', 'p.weight', 'p.number_of_box', 'dp.name as dp_name', 'dp.weight_type', 'p.consignment_no', 'r.name as receiver_name', 'c.name as city_name', 'p.parcel_value', 'p.date', 'p.insurance_amt', 'p.remakrs', 'clnt.weight_in_mails as clientWeight', 'clnt.charge_in_mails as clientCharge', ])->orderBy('p.date')->orderBy('p.consignment_no')->get(); $totalAmount = isset($parcels[0]) ? $parcels[0]->total_amount : 0; $grandAlount = $bill->grandtotal; $final_value = number_format((float)($totalAmount - $bill->amount), 2); if ($final_value > 0) { $value = 'Positive'; } else { $value = 'Negative'; } @endphp @else
For {{@$branch['name']}}

Authorized Signature

@endif
@if($branch['image']) logo @endif

{{@$branch['name']}}

{{@$branch['address']}}, {{@$branch['city']}} - {{@$branch['zipcode']}}

PH: {{@$branch['contact_no']}}

GST NO: {{@$branch['gstno']}} PAN NO: {{@$branch['pancard']}}

DOMESTIC AND INTERNATIONAL SERVICES BY ROAD, TRAIN,SEA & AIR
Bill No: {{$bill->billno}} Bill Date: {{date("d/m/Y", strtotime($bill->created_at))}} Bill From: {{date("d/m/Y", strtotime($bill->start_date))}} Bill To: {{date("d/m/Y", strtotime($bill->end_last))}} Service: Courier Courier
Bill To: {{$bill->name}} {{@$bill->address1.' '.@$bill->address2.' '.@$bill->city.', '.@$bill->state}} GST:- {{@$bill->gstno}} State Code:- {{ (@$bill->gstno) ? substr(@$bill->gstno,0,2) : '' }}
{{-- --}} @php $total_doc = $total_oda = $total_freight = $total_fov = $total_invoice_value = $total_invoice_value_charge = $total_s_total = $total_net = 0; @endphp @php $srno = 1; @endphp @foreach($all_parcels as $parcel) @php $freight_amount = $parcel->amont + $parcel->insurance_amt; // $s_total = $freight_amount + $parcel->fov_amt; $total_doc += $parcel->doc_amt; $total_oda += $parcel->oda_amt; $total_freight += $freight_amount; $total_fov += $parcel->fov_amt; $total_invoice_value += $parcel->parcel_value; $total_invoice_value_charge += $parcel->parcel_value_amt; // $total_s_total += $s_total; $total_net += $parcel->net_amt; @endphp {{-- --}} @php $srno++; @endphp @endforeach {{-- --}}
S.N. DOCKET NO. DATE TO RECEIVER TYPE REMARK WEIGHT FREIGHT DOC ODA INV. VAL. FOVINV. CH.NET AMT.
{{$srno}} {{@$parcel->consignment_no}} {{date("d/m/Y", strtotime(@$parcel->date))}} {{@$parcel->city_name}} {{@$parcel->receiver_name}} {{@$parcel->dp_name}} {{@$parcel->remakrs}} {{@$parcel->weight}} {{strtoupper(@$parcel->weight_type)}} @if($parcel->number_of_box != null)
({{$parcel->number_of_box}} Box)
@endif
{{ $freight_amount }} {{ $parcel->doc_amt ?? 0 }} {{ $parcel->oda_amt ?? 0 }} {{ $parcel->parcel_value ?? 0 }} {{ $parcel->fov_amt }}{{$parcel->parcel_value_amt}}{{ $parcel->net_amt }}
TOTAL {{ $total_freight }} {{ $total_doc }} {{ $total_oda }} {{ $total_invoice_value }} {{ $total_fov }}{{ $total_invoice_value_charge }}{{ $total_net }}
Payment QR Code
@if($branch['payment_qr_code']) Stamp @endif

Branch: {{$branch->bank_address}}

A/c Number: {{$branch->bank_acno}}

IFSC Code: {{$branch->ifsc_code}}

HSN/SAC CODE: {{$branch->sac_code}}

MSME No: {{$branch->msme_no}}

@if($serviceChAmount > 0) @endif @if($bill->other_charge > 0) @endif @if($value == 'Positive') @endif @if($bill->igstpercent > 0) @endif @if($roundValue > 0 && $roundValue <= 0.50) @endif
Total {{Laracore::showPrice($billAmount)}}
Service .Ch. ({{$bill->service_charge_percent}}%) {{Laracore::showPrice($serviceChAmount)}}
Other Charge {{Laracore::showPrice($bill->other_charge)}}
Discount - {{Laracore::showPrice($parcels[0]->total_amount - $bill->amount)}}
Fuel Charge ({{$bill->fchpercent}}%) {{Laracore::showPrice($fuelAmount)}}
Taxable Amount : {{Laracore::showPrice(@$totAmount)}}
CGST ({{$bill->cgstpercent}}%) : {{Laracore::showPrice(($totAmount * $bill->cgstpercent)/100)}}
SGST ({{$bill->sgstpercent}}%) : {{Laracore::showPrice(($totAmount * $bill->sgstpercent)/100)}}
IGST ({{$bill->igstpercent}}%) : {{Laracore::showPrice(($totAmount * $bill->igstpercent)/100)}}
Rounding Amount : {{Laracore::showPrice($roundValue)}}
Net Amount : {{ Laracore::showPrice($finalGrandTotal) }}
@if($digital_signature == 1)

Digitally signed by {{strtoupper(@$branch['name'])}}

Date: {{date("d/m/Y", strtotime($bill->created_at))}}
Location: {{@$branch['city']}}
@elseif($digital_signature == 2 && $branch['stamp'] != '')
For, {{@$branch['name']}} Stamp
@endforeach