@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->grand_total; $roundValue = $bill->rounding_amount; } else { $grandAmount = $bill->grand_total; $ceilAmount = ceil($grandAmount); $floorAmount = floor($grandAmount); $roundValue = $ceilAmount - $grandAmount; $finalGrandTotal = ($roundValue > 0 && $roundValue <= 0.50) ? $ceilAmount : $floorAmount; } } else { $finalGrandTotal = $isNewBill ? $bill->grand_total - $bill->rounding_amount : $bill->grand_total; $roundValue = 0; } $billAmount = $bill->amount; $fuelChAmount = ($billAmount * $bill->fchpercent)/100; $amountAndFuel = $billAmount + $fuelChAmount; $totAmount = $amountAndFuel; $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 = 10; foreach ($billitempreferences as $key => $value) { if ($key == 'package_type' || $key == 'insurance') { continue; } if ($key == 'receiver' || $key == 'center' || $key == 'remark' || $key == 'carrier' || $key == 'weight') { if ($value == 0) { $totalColsValue--; } } } $parcels = DB::table('cargo_bills as bl') ->leftJoin('cargos as p','p.client_id','=','bl.client_id') ->leftJoin('receivers as r','r.id','=','p.receiver_id') ->where(['bl.id'=>$bill->id, 'p.bill_id'=>$bill->id, 'bl.branch_id'=>$branchId]) ->where(DB::raw('DATE_FORMAT(p.date,"%Y-%m")'), '=', DB::raw("'$month'")) ->select([DB::raw('SUM(p.net_amount) as total_amount')])->get(); $all_parcels = DB::table('cargo_bills as bl') ->leftJoin('cargos as p','p.client_id','=','bl.client_id') ->leftJoin('receivers as r','r.id','=','p.receiver_id') ->leftJoin('centers as oc','oc.id','=','p.origin_center_id') ->leftJoin('centers as c','c.id','=','p.destination_center_id') ->leftJoin('carriers as car','car.id','=','p.carrier_id') ->leftJoin('clients as clnt','clnt.id','=','bl.client_id') ->leftJoin('default_packagetypes as dp','dp.id','=','p.package_type_id') ->where(['bl.id'=>$bill->id, 'p.bill_id'=>$bill->id, 'bl.branch_id'=>$branchId]) ->where(DB::raw('DATE_FORMAT(p.date,"%Y-%m")'), '=', DB::raw("'$month'")) ->select([ 'p.id as parcel_id', 'p.net_amount', 'p.gross_amount', 'p.weight', 'dp.name as dp_name', 'dp.weight_type as weight_type', 'p.consignment_no', 'p.reference_number', 'p.number_of_box', 'r.name as receiver_name', 'c.name as city_name', 'oc.name as origin', 'car.name as carrier_name', 'p.date', 'p.remarks', 'clnt.weight_in_mails as clientWeight', 'clnt.charge_in_mails as clientCharge', ])->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['origin'] = $parcel->origin; $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['reference_number'] = $parcel->reference_number; $parcel_array['number_of_box'] = $parcel->number_of_box; $parcel_array['remarks'] = $parcel->remarks; $parcel_array['parcel_amount'] = $parcel->gross_amount; $parcel_array['weight'] = $parcel->weight; $parcel_array['weight_type'] = $parcel->weight_type; $parcel_array['amount'] = $parcel->gross_amount; $data[] = $parcel_array; $all_charge_type_parcels = DB::table('cargos as par') ->leftJoin('cargo_other_charges as par_charge','par.id','=','par_charge.cargo_id') ->leftJoin('cargo_other_charge_types as list','list.id','=','par_charge.other_charge_type_id') ->where(['par_charge.cargo_id'=>$parcel->parcel_id]) ->select([ 'list.title', 'par_charge.amount', 'par_charge.percentage', ])->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->title; $info['origin'] = ''; $info['center'] = ''; $info['carrier'] = ''; $info['date'] = ''; $info['cons_no'] = ''; $info['remarks'] = ''; $info['parcel_amount'] = ''; $info['weight'] = ''; $info['weight_type'] = ''; $info['amount'] = $charge_type_parcel->amount; $other_amount = $other_amount + $charge_type_parcel->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
DEBIT MEMO / CASH MEMO

TAX INVOICE

ORIGINAL / DUPLICATE / TRIPLICATE

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

{{@$branch['address']}}, {{@$branch['city']}} - {{@$branch['zipcode']}}
Monthly Bill / {{date("M Y", strtotime($bill->start_date))}}

M/s.

{{$bill->name}}

Address

{{@$bill->address1.' '.@$bill->address2.' '.@$bill->city}}

Phone

{{@$bill->phone1}}

GST No.

{{@$bill->gstno}}

Bill No. {{$bill->bill_no}}

Date{{date("d/m/Y", strtotime($bill->created_at))}}

@if($value == 'Positive') @else @endif @if($value == 'Positive') {{-- @else --}} @endif @if($roundValue > 0 && $roundValue <= 0.50) @endif
PARTICULAR AMOUNT
FREIGHT CHARGES FOR THE MONTH OF {{date("M Y", strtotime($bill->start_date))}} {{Laracore::showPrice($parcels[0]->total_amount)}}
FREIGHT CHARGES FOR THE MONTH OF {{date("M Y", strtotime($bill->start_date))}} {{Laracore::showPrice($parcels[0]->total_amount + abs($parcels[0]->total_amount - $bill->amount))}}
DISCOUNT - {{Laracore::showPrice($parcels[0]->total_amount - $bill->amount)}}
DISCOUNT --
Fuel Ch. % ({{$bill->fchpercent}}) {{Laracore::showPrice(($billAmount * $bill->fchpercent)/100)}}
CGST % ({{$bill->cgstpercent}}) {{Laracore::showPrice(($totAmount * $bill->cgstpercent)/100)}}
SGST / UTGST % ({{$bill->sgstpercent}}) {{Laracore::showPrice(($totAmount * $bill->sgstpercent)/100)}}
IGST % ({{$bill->igstpercent}}) {{Laracore::showPrice(($totAmount * $bill->igstpercent)/100)}}
Round Of {{Laracore::showPrice($roundValue)}}
GRAND TOTAL {{ Laracore::showPrice($finalGrandTotal) }}

(Rupees in words){{ getIndianCurrency($finalGrandTotal) }}

GST No.- {{@$branch['gstno']}}
{{@$branch['bank_address']}}
A/C. No. - {{@$branch['bank_acno']}}
IFSC CODE - {{@$branch['ifsc_code']}}
MICR CODE - {{@$branch['micr_code']}}
HSN/SAC CODE - {{@$branch['sac_code']}}
Pan Card No.- {{@$branch['pancard']}}
Mo. {{@$branch['contact_no']}}

@if($branch['bill_terms_and_conditions'] != '')

@php $termsAndConditionsArr = explode("\n", str_replace("\r", "", @$branch['bill_terms_and_conditions'])); @endphp @foreach($termsAndConditionsArr as $termsAndConditions) {{$termsAndConditions}}
@endforeach

@else

PLEASE MAKE PAYMENT BY A/c. PAYEE CHEQUE IN FAVOR OF {{strtoupper(@$branch['name'])}}

PLEASE MAKE PAYMENT BY AMOUNT DUE ON 1 TO 5 DAYS

@endif
@if($branch['payment_qr_code'])

Payment QR Code

Stamp
@endif
@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(count($all_parcels) > 0)
Bill Detail / {{date("M Y", strtotime($bill->start_date))}}
@php $srno = 1; $amountColsValue = 0; $total_parcel_amount = $total_ins = $total_fuel = 0; @endphp @foreach($data as $parcels) @endforeach @if($bill->service_charge_percent) @endif @if($bill->other_charge) @endif @if($roundValue > 0 && $roundValue <= 0.50) @endif
Sr Receiver Origin Destination Date Cons_No Remark Carrier Weight Amount Charges
{{(@$parcels['center'] != '') ? $srno :''}} {{@$parcels['receiver']}} {{@$parcels['origin']}} {{@$parcels['center']}} {{(@$parcels['date'] != '') ? date("d/m/Y", strtotime(@$parcels['date'])) :''}} {{@$parcels['cons_no']}} @if(@$parcels['reference_number'] != null)
(Ref: {{$parcels['reference_number']}})
@endif
{{@$parcels['remarks']}} {{@$parcels['carrier']}} {{@$parcels['weight']}} {{strtoupper(@$parcels['weight_type'])}} @if(@$parcels['number_of_box'] != null)
({{$parcels['number_of_box']}} Box)
@endif
{{@$parcels['parcel_amount']}} {{Laracore::showPrice(@$parcels['amount'])}}
Amount {{Laracore::showPrice($total_parcel_amount)}} {{Laracore::showPrice($bill->amount)}}
Service .Ch. % ({{$bill->service_charge_percent}}) {{Laracore::showPrice($serviceChAmount)}}
Other Ch. {{Laracore::showPrice($bill->other_charge)}}
Fuel Ch. % ({{$bill->fchpercent}}) {{Laracore::showPrice(($billAmount * $bill->fchpercent)/100)}}
CGST % ({{$bill->cgstpercent}}) {{Laracore::showPrice(($totAmount * $bill->cgstpercent)/100)}}
SGST / UTGST % ({{$bill->sgstpercent}}) {{Laracore::showPrice(($totAmount * $bill->sgstpercent)/100)}}
IGST % ({{$bill->igstpercent}}) {{Laracore::showPrice(($totAmount * $bill->igstpercent)/100)}}
Round Of {{Laracore::showPrice($roundValue)}}
GRAND TOTAL {{ Laracore::showPrice($finalGrandTotal) }}

(Rupees in words){{ getIndianCurrency($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
@else

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

Autho / Sign.
@endif
@endif
   
@endforeach