@php $unittype = []; foreach ($model[0]['unittypes'] as $key => $value) { $val = []; $val['unittype'] = $value['unittype']; $val['building'] = []; $val['unit_sold'] = 0; $val['actual'] = 0; $val['extra'] = 0; $val['total'] = 0; $val['dis'] = 0; $val['net'] = 0; $val['rcvd'] = 0; $val['net_bal'] = 0; $unittype[] = $val; } $grand_total_actual = 0; $grand_total_extra = 0; $grand_total_unit_total = 0; $grand_total_discount = 0; $grand_total_net_price = 0; $grand_total_recieved = 0; $grand_total_bal = 0; $buildings = []; @endphp @foreach($model as $building_key => $item) @php $building_units_count = 0; @endphp @php $building_total_actual = 0; $building_total_extra = 0; $building_total_unit_total = 0; $building_total_discount = 0; $building_total_net_price = 0; $building_total_recieved = 0; $building_total_bal = 0; @endphp @foreach ($item["unittypes"] as $unittype_key => $unittypes) @php $val = []; $val['count'] = count($unittypes['units']); $building_units_count += $val['count']; $unittype[$unittype_key]['building'][] = $val; $total_actual = 0; $total_extra = 0; $total_unit_total = 0; $total_discount = 0; $total_net_price = 0; $total_recieved = 0; $total_bal = 0; @endphp @if (count($unittypes['units']) > 0) @foreach ($unittypes['units'] as $key => $unit ) @php $total_actual = $total_actual+(float)$unit['price']; $total_extra = $total_extra+(float)$unit['total_extra_charges']; $unit_total = (float)$unit['price'] + (float)$unit['total_extra_charges']; $total_unit_total = $total_unit_total + $unit_total; $total_discount = $total_discount+ (float)$unit['discount']; $total_net_price = $total_net_price+(float)$unit['net_price']; $total_recieved = $total_recieved+(float)$unit['total_receipts']; $total_bal = $total_bal+(float)$unit['current_outstanding']; @endphp @endforeach @else @endif @php $building_total_actual = $building_total_actual + $total_actual; $building_total_extra = $building_total_extra + $total_extra; $building_total_unit_total = $building_total_unit_total + $total_unit_total; $building_total_discount = $building_total_discount + $total_discount; $building_total_net_price = $building_total_net_price + $total_net_price; $building_total_recieved = $building_total_recieved + $total_recieved; $building_total_bal = $building_total_bal + $total_bal; $unittype[$unittype_key]['actual'] += $total_actual; $unittype[$unittype_key]['extra'] += $total_extra; $unittype[$unittype_key]['total'] += $total_unit_total; $unittype[$unittype_key]['dis'] += $total_discount; $unittype[$unittype_key]['net'] += $total_net_price; $unittype[$unittype_key]['rcvd'] += $total_recieved; $unittype[$unittype_key]['net_bal'] += $total_bal; @endphp @endforeach @php $val= []; $val['count'] = $building_units_count; $buildings[] = $val; @endphp @php $grand_total_actual = $grand_total_actual + $building_total_actual; $grand_total_extra = $grand_total_extra + $building_total_extra; $grand_total_unit_total = $grand_total_unit_total + $building_total_unit_total; $grand_total_discount = $grand_total_discount + $building_total_discount; $grand_total_net_price = $grand_total_net_price + $building_total_net_price; $grand_total_recieved = $grand_total_recieved + $building_total_recieved; $grand_total_bal = $grand_total_bal + $building_total_bal; @endphp @endforeach
{{ $item->buildingname }}
S.No Unit Name Actual Extras Total Disc Net Val Rcvd Bal
{{ $unittypes['unittype'] }}
{{ ($key+1) }} {{ $unit['unitname'] }} {{ $unit['customername'] }} {{ number_format($unit['price'],2) }} {{ number_format($unit['total_extra_charges'],2) }} {{ number_format($unit_total,2) }} {{ number_format($unit['discount'],2) }} {{ number_format($unit['net_price'],2) }} {{ number_format($unit['total_receipts'],2) }} {{ number_format($unit['current_outstanding'],2) }}
0 0 0 0 0 0 - 0
Total {{ number_format($total_actual,2) }} {{ number_format($total_extra,2) }} {{ number_format($total_unit_total,2) }} {{ number_format($total_discount,2) }} {{ number_format($total_net_price,2) }} {{ number_format($total_recieved,2) }} {{ number_format($total_bal,2) }}
 
ACTUAL EXTRA TOTAL DIS NET RECD BAL
{{ $item->shortname }} {{ number_format($building_total_actual,2) }} {{ number_format($building_total_extra,2) }} {{ number_format($building_total_unit_total,2) }} {{ number_format($building_total_discount,2) }} {{ number_format($building_total_net_price,2) }} {{ number_format($building_total_recieved,2) }} {{ number_format($building_total_bal,2) }}
 
ACTUAL EXTRA TOTAL DIS NET RECD BAL
GRAND TOTAL {{ number_format($grand_total_actual,2) }} {{ number_format($grand_total_extra,2) }} {{ number_format($grand_total_unit_total,2) }} {{ number_format($grand_total_discount,2) }} {{ number_format($grand_total_net_price,2) }} {{ number_format($grand_total_recieved,2) }} {{ number_format($grand_total_bal,2) }}
@foreach ($model as $block) @endforeach @foreach ($unittype as $row) @php $unit_sold = 0; @endphp @foreach ($row['building'] as $item) @php $unit_sold += $item['count']; @endphp @endforeach @endforeach @php $total_units = 0; @endphp @foreach ($buildings as $row) @php $total_units += $row['count']; @endphp @endforeach
SALES SUMMARY UPTO {{ $data['date'] }}
TYPE BLOCK UNITS SOLD ACTUAL EXTRA TOTAL DIS NET RCVD NET BALANCE
{{ $block->shortname }}
{{ $row['unittype'] }}{{ $item['count']}}{{ $unit_sold }} {{ number_format($row['actual'],2) }} {{ number_format($row['extra'],2) }} {{ number_format($row['total'],2) }} {{ number_format($row['dis'],2) }} {{ number_format($row['net'],2) }} {{ number_format($row['rcvd'],2) }} {{ number_format($row['net_bal'],2) }}
Total{{ $row['count'] }}{{ $total_units }} {{ number_format($grand_total_actual,2) }} {{ number_format($grand_total_extra,2) }} {{ number_format($grand_total_unit_total,2) }} {{ number_format($grand_total_discount,2) }} {{ number_format($grand_total_net_price,2) }} {{ number_format($grand_total_recieved,2) }} {{ number_format($grand_total_bal,2) }}