@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 = 11; foreach ($billitempreferences as $key => $value) { if ($key == 'package_type') { continue; } if ($key == 'receiver' || $key == 'center' || $key == 'remark' || $key == 'carrier' || $key == 'weight' || $key == 'insurance' || $key == 'fuel_charge') { 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'=>1, 'bl.branch_id'=>$branchId]) ->where(DB::raw('DATE_FORMAT(p.date,"%Y-%m")'), '=', DB::raw("'$month'")) ->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'=>1, 'bl.branch_id'=>$branchId]) ->where(DB::raw('DATE_FORMAT(p.date,"%Y-%m")'), '=', DB::raw("'$month'")) ->select([ 'p.id as parcel_id', 'p.net_amt', 'p.amont', 'p.weight', 'dp.name as dp_name', 'dp.weight_type as weight_type', 'p.consignment_no', 'p.number_of_box', 'r.name as receiver_name', 'c.name as city_name', 'car.name as carrier_name', 'p.date', 'p.insurance_amt', 'p.fuel_charge', 'p.ess_charge', 'p.remakrs', 'clnt.weight_in_mails as clientWeight', 'clnt.charge_in_mails as clientCharge', DB::raw('(SELECT SUM(parcel_charges.charge_amount) FROM parcel_charges WHERE parcel_charges.parcel_id = p.id) as total_other_charges_amount'), ])->orderBy('p.date')->orderBy('p.consignment_no')->get(); $data = array(); $total_fuel_for_main_bill = 0; foreach ($all_parcels as $parcel) { $parcel_array = array(); $parcel_array['receiver'] = $parcel->receiver_name; $parcel_array['center'] = $parcel->city_name; $parcel_array['carrier'] = $parcel->carrier_name; $parcel_array['date'] = $parcel->date; $parcel_array['cons_no'] = $parcel->consignment_no; $parcel_array['number_of_box'] = $parcel->number_of_box; $parcel_array['remakrs'] = $parcel->remakrs; $parcel_array['parcel_amount'] = $parcel->amont; $parcel_array['weight'] = $parcel->weight; $parcel_array['weight_type'] = $parcel->weight_type; $parcel_array['insurance'] = $parcel->insurance_amt; $parcel_array['ess_charge'] = $parcel->ess_charge; $parcel_array['ess_charge_amount'] = (($parcel->amont + $parcel->total_other_charges_amount) * ($parcel->ess_charge) / 100); $parcel_array['fuel_percentage'] = $parcel->fuel_charge; $parcel_array['fuel_amount'] = (($parcel->amont + $parcel->total_other_charges_amount + $parcel_array['ess_charge_amount']) * $parcel->fuel_charge) / 100; $parcel_array['amount'] = $parcel->amont + $parcel_array['ess_charge_amount'] + $parcel_array['fuel_amount'] + $parcel->insurance_amt; $parcel_array['total_other_charges_amount'] = $parcel->total_other_charges_amount; $total_fuel_for_main_bill = $total_fuel_for_main_bill + $parcel_array['fuel_amount']; // $parcel_fuel_amount = ($parcel->amont * $parcel->fuel_charge)/100; // $parcel_array['fuel'] = $parcel_fuel_amount; // $parcel_array['fuel_percentage'] = $parcel->fuel_charge; // $parcel_array['amount'] = $parcel->amont + $parcel_fuel_amount + $parcel->insurance_amt; // $total_fuel_for_main_bill = $total_fuel_for_main_bill + $parcel_fuel_amount; $data[] = $parcel_array; $all_charge_type_parcels = DB::table('parcels as par') ->leftJoin('parcel_charges as par_charge','par.id','=','par_charge.parcel_id') ->leftJoin('_lists as list','list.id','=','par_charge.charge_type') ->where(['par_charge.branch_id'=>$branchId, 'par_charge.parcel_id'=>$parcel->parcel_id]) ->select([ 'list.item_name as charge_name', 'par_charge.charge_amount', ])->get(); if (!empty($all_charge_type_parcels)) { $other_amount = 0; foreach ($all_charge_type_parcels as $charge_type_parcel) { $info = array(); $info['receiver'] = $charge_type_parcel->charge_name; $info['center'] = ''; $info['carrier'] = ''; $info['date'] = ''; $info['cons_no'] = ''; $info['remakrs'] = ''; $info['parcel_amount'] = $charge_type_parcel->charge_amount; $info['weight'] = ''; $info['weight_type'] = ''; $info['insurance'] = ''; $info['fuel_amount'] = ''; $info['fuel_percentage'] = ''; $info['amount'] = $charge_type_parcel->charge_amount; $other_amount = $other_amount + $charge_type_parcel->charge_amount; $data[] = $info; } } } $final_value = number_format((double)($parcels[0]->total_amount - $bill->amount), 2); if($final_value > 0){ $value = 'Positive'; }else{ $value = 'Negative'; } sleep(2); @endphp
@if($branch['image']) logo @endif {{@$branch['name']}}

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

PH:{{@$branch['contact_no']}} Email: {{@$branch_email}}
TAX INVOICE
Name: {{$bill->name}}

{{$bill->address1}}

{{$bill->address2}}

{{$bill->city}}

A/c GST Number : {{@$bill->gstno}}
Bill No: {{$bill->billno}} Bill Date: {{ date("d/m/Y", strtotime($bill->created_at)) }} Bill Period: {{date("d/m/Y", strtotime($bill->start_date))}}    To    {{date("d/m/Y", strtotime($bill->end_last))}} GST Number :{{@$branch['gstno']}} PAN NO :{{@$branch['pancard']}}
@php $total_weight = $total_number_of_box = $total_net = 0; @endphp @php $srno = 1; @endphp @foreach($all_parcels as $parcel) @php $net_amount = $parcel->net_amt; $fuel_ch = ($net_amount * $bill->fchpercent) / 100; $fuel_with_net_amount = $net_amount + $fuel_ch; $total_number_of_box += $parcel->number_of_box; $total_weight += $parcel->weight; $total_net += $parcel->net_amt; @endphp @php $srno++; @endphp @endforeach
Name: {{$bill->name}} Bill Period: {{date("d/m/Y", strtotime($bill->start_date))}} To {{date("d/m/Y", strtotime($bill->end_last))}}
Sr. AWB No. Date Receiver Destination Pcs Weight Amount
{{$srno}} {{@$parcel->consignment_no}} {{date("d/m/Y", strtotime(@$parcel->date))}} {{@$parcel->receiver_name}} {{@$parcel->city_name}} {{@$parcel->number_of_box}} {{@$parcel->weight}} {{strtoupper(@$parcel->weight_type)}} {{Laracore::showPrice($parcel->net_amt)}}
Total {{ $total_number_of_box }} {{ $total_weight }} {{Laracore::showPrice($total_net)}}
SAC Code: {{@$branch['sac_code']}} -- Type Of Service: Courier Services Remark : PLEASE MAKE PAYMENT IN FAVOUR OF {{@$branch['name']}} @if($value == 'Positive') @endif @if($roundValue > 0 && $roundValue <= 0.50) @endif
GROSS AMOUNT: {{Laracore::showPrice($bill->amount)}}
DISCOUNT: - {{Laracore::showPrice($parcels[0]->total_amount - $bill->amount)}}
F.Ch. : {{$bill->fchpercent}}% {{Laracore::showPrice(($bill->amount * $bill->fchpercent)/100)}}
C.GST Tax: {{$bill->cgstpercent}}% {{Laracore::showPrice(($totAmount * $bill->cgstpercent)/100)}}
S.GST Tax: {{$bill->sgstpercent}}% {{Laracore::showPrice(($totAmount * $bill->sgstpercent)/100)}}
I.GST Tax: {{$bill->igstpercent}}% {{Laracore::showPrice(($totAmount * $bill->igstpercent)/100)}}
Round.Off[+/-] {{Laracore::showPrice($roundValue)}}
Bill Amount : {{ Laracore::showPrice($finalGrandTotal) }}
Rupees :

{{ getIndianCurrency($finalGrandTotal) }}

All request for correction must be made in writing within 10 days of invoice date. No correction will be made after 10 days of invoice date.
@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
@else

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

Autho / Sign.
@endif
@if($branch['bill_terms_and_conditions'] != '') PLEASE BE NOTED: @php $termsAndConditionsArr = explode("\n", str_replace("\r", "", @$branch['bill_terms_and_conditions'])); @endphp @foreach($termsAndConditionsArr as $termsAndConditions)

{{$termsAndConditions}}

@endforeach @endif
@endforeach