| {{ ++$sl }} |
{{ date('d-m-Y', strtotime($p)) }} |
@php
$new_room_qty = $room_details->where('is_new_room', 1)->where('start_date_time', date('Y-m-d 00:00:00',strtotime($p)))->count();
$occupied_room_qty_checkin = $room_details->where('check_out_time', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->count();
$occupied_room_qty_checkout = $room_details->where('check_out_time', '!=', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->where('start_date_time', '>=', date('Y-m-d 00:00:00',strtotime($p)))->count();
$occupied_room_qty = $occupied_room_qty_checkin + $occupied_room_qty_checkout;
$new_room_bill_amount = $room_details->where('is_new_room', 1)->where('start_date_time', date('Y-m-d 00:00:00',strtotime($p)))->sum('rent');
$new_room_bill_vat = $room_details->where('is_new_room', 1)->where('start_date_time', date('Y-m-d 00:00:00',strtotime($p)))->sum('vat');
$new_room_bill = $new_room_bill_amount + $new_room_bill_vat;
$occupied_room_bill_checkin_amount = $room_details->where('check_out_time', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->sum('rent');
$occupied_room_bill_checkin_vat = $room_details->where('check_out_time', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->sum('vat');
$occupied_room_bill_checkout_amount = $room_details->where('check_out_time', '!=', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->where('start_date_time', '>=', date('Y-m-d 00:00:00',strtotime($p)))->sum('rent');
$occupied_room_bill_checkout_vat = $room_details->where('check_out_time', '!=', null)->where('start_date_time', '<=', date('Y-m-d 00:00:00',strtotime($p)))->where('start_date_time', '>=', date('Y-m-d 00:00:00',strtotime($p)))->sum('vat');
$occupied_room_bill = $occupied_room_bill_checkin_amount + $occupied_room_bill_checkin_vat + $occupied_room_bill_checkout_amount + $occupied_room_bill_checkout_vat;
$calculation_arr = [
'1_1' => $new_room_qty,
'1_2' => $occupied_room_qty,
'2_1' => $new_room_bill,
'2_2' => $occupied_room_bill
];
$commission = $setups->where('target_value', '<=', $calculation_arr[$combination])->sortByDesc('target_value')->first()->commission_percent ?? 0;
if(in_array($combination, ['2_1','2_2'])){
$target_value = $setups->where('target_value', '<=', $calculation_arr[$combination])->sortByDesc('target_value')->first()->target_value ?? 0;
$commission = $target_value > 0 ? ($commission*($calculation_arr[$combination]/$target_value)) : 0;
} else{ // Room qty
$commission = $commission*$calculation_arr[$combination];
}
$commission = round($commission, 2);
$total_commission += $commission;
@endphp
{{ $new_room_qty }} |
{{ $occupied_room_qty }} |
{{ $new_room_bill }} |
{{ $occupied_room_bill }} |
{{ $commission }} |
@endforeach