WHT Amount @foreach($departmentList as $dept) @if($dept->subdepts_count > 0) @foreach($dept->subdepts as $sub_dept) @isset($whtLogExpense['subdepts'][$sub_dept->id]) @php $tempAmount['sub_dept'][$sub_dept->id] = (isset($whtLogExpense['subdepts'][$sub_dept->id]) ? $whtLogExpense['subdepts'][$sub_dept->id] : 0); @endphp @if($tempAmount['sub_dept'][$sub_dept->id] > 0) @php if(isset($totalWhtAmount)) $totalWhtAmount += $tempAmount['sub_dept'][$sub_dept->id]; else $totalWhtAmount = $tempAmount['sub_dept'][$sub_dept->id]; @endphp {{ number_format($tempAmount['sub_dept'][$sub_dept->id], 2) }} @endif @endisset @endforeach @else @isset($whtLogExpense['depts'][$dept->id]) @php $tempAmount['dept'][$dept->id] = $whtLogExpense['depts'][$dept->id]; @endphp @if(isset($tempAmount['dept'][$dept->id]) && $tempAmount['dept'][$dept->id] > 0) @php if(isset($totalWhtAmount)) $totalWhtAmount += $tempAmount['dept'][$dept->id]; else $totalWhtAmount = $tempAmount['dept'][$dept->id]; @endphp {{ number_format($tempAmount['dept'][$dept->id], 2) }} @endif @endisset @endif @endforeach @isset($totalWhtAmount) @if($totalWhtAmount > 0) {{ number_format($totalWhtAmount, 2) }} @endif @endisset Allocation @foreach($departmentList as $dept) @if($dept->subdepts_count > 0) @foreach($dept->subdepts as $sub_dept) @if(isset($whtLogExpense['subdepts'][$sub_dept->id]) && isset($tempAmount['sub_dept'][$sub_dept->id]) && isset($totalWhtAmount)) @php $tempPercentage = ($tempAmount['sub_dept'][$sub_dept->id] * 100) / $totalWhtAmount; @endphp @if($totalWhtAmount > 0 && $tempPercentage > 0) @php if(isset($totalPercentage)) $totalPercentage += $tempPercentage; else $totalPercentage = $tempPercentage; @endphp {{ number_format($tempPercentage, 2) }}% @endif @endif @endforeach @else @if(isset($whtLogExpense['depts'][$dept->id]) && isset($tempAmount['dept'][$dept->id]) && isset($totalWhtAmount)) @php $tempPercentage = ($tempAmount['dept'][$dept->id] * 100) / $totalWhtAmount; @endphp @if($totalWhtAmount > 0 && $tempPercentage > 0) @php if(isset($totalPercentage)) $totalPercentage += $tempPercentage; else $totalPercentage = $tempPercentage; @endphp {{ number_format($tempPercentage, 2) }}% @endif @endif @endif @endforeach @if(isset($totalPercentage)) {{ number_format(($totalPercentage > 100) ? '100.00' : $totalPercentage, 2) }}% @endif