@if(in_array($subcategories['id'], array_keys($final_debit)) ) @for ($i = 1; $i <= $level; $i++)    @endfor @if(setUserLang() == "ar") {{$subcategories->code}} - {{$subcategories->arabic_name}} @else {{$subcategories->code}} - {{$subcategories->name}} @endif @if(count($subcategories['subcategory']) < 1) {{ format_balance($final_open_debit[$subcategories['id']]) }} @php $opening_debit = 0; $opening_debit = $final_open_debit[$subcategories['id']]; @endphp {{ format_balance($final_open_credit[$subcategories['id']]) }} @php $opening_credit = 0; $opening_credit = $final_open_credit[$subcategories['id']]; @endphp @php format_balance($final_debit[$subcategories['id']]); $total_debit = $final_debit[$subcategories['id']]; $mov_total_debit += $total_debit; @endphp @php format_balance($final_credit[$subcategories['id']]); $total_credit = $final_credit[$subcategories['id']]; $mov_total_credit += $total_credit; @endphp {{ format_balance($final_net_movement_debit[$subcategories['id']]) }} @php $net_movement_debit = 0; $net_movement_debit = $final_net_movement_debit[$subcategories['id']]; @endphp {{ format_balance($final_net_movement_credit[$subcategories['id']]) }} @php $net_movement_credit = 0; $net_movement_credit = $final_net_movement_credit[$subcategories['id']]; @endphp @php $closing_debit = 0; $closing_credit = 0; if ( $opening_debit != 0){ if ( $net_movement_debit != 0){ $closing_debit = $opening_debit + $net_movement_debit; }else{ if ($opening_debit > $net_movement_credit){ $closing_debit = $opening_debit - $net_movement_credit; }else{ $closing_credit = $net_movement_credit - $opening_debit; } } }elseif ($opening_debit == 0 && $opening_credit == 0){ if ( $net_movement_debit != 0){ $closing_debit = $net_movement_debit; }else{ $closing_credit = $net_movement_credit; } } else{ if ( $net_movement_credit != 0){ $closing_credit = $opening_credit + $net_movement_credit; }else{ if ($opening_credit > $net_movement_debit){ $closing_credit = $opening_credit - $net_movement_debit; }else{ $closing_debit = $net_movement_debit - $opening_credit; } } } @endphp {{$closing_debit}} {{$closing_credit}} @else @endif @endif @if(count($subcategories['subcategory']) > 0) @foreach($subcategories['subcategory'] as $key => $subcategory) @include('accounting.reports.sub_trial_balance', ['subcategories'=>$subcategory, 'level' => ($level + 2)]) @endforeach @if(in_array($subcategories['id'], array_keys($final_debit)) ) @if( $subcategories->parent_id != 0) @for ($i = 1; $i <= $level; $i++)    @endfor @if(setUserLang() == "ar") {{__('messages.Total')}} {{$subcategories->code}} - {{$subcategories->arabic_name}} @else {{__('messages.Total')}} {{$subcategories->code}} - {{$subcategories->name}} @endif {{ format_balance($final_open_debit[$subcategories['id']]) }} @php $opening_debit = 0; $opening_debit = $final_open_debit[$subcategories['id']]; @endphp {{ format_balance($final_open_credit[$subcategories['id']]) }} @php $opening_credit = 0; $opening_credit = $final_open_credit[$subcategories['id']]; @endphp @php format_balance($final_debit[$subcategories['id']]); @endphp @php format_balance($final_credit[$subcategories['id']]); @endphp {{ format_balance($final_net_movement_debit[$subcategories['id']]) }} @php $net_movement_debit = 0; $net_movement_debit = $final_net_movement_debit[$subcategories['id']]; @endphp {{ format_balance($final_net_movement_credit[$subcategories['id']]) }} @php $net_movement_credit = 0; $net_movement_credit = $final_net_movement_credit[$subcategories['id']]; @endphp @php $closing_debit = 0; $closing_credit = 0; if ( $opening_debit != 0){ if ( $net_movement_debit != 0){ $closing_debit = $opening_debit + $net_movement_debit; }else{ if ($opening_debit > $net_movement_credit){ $closing_debit = $opening_debit - $net_movement_credit; }else{ $closing_credit = $net_movement_credit - $opening_debit; } } }elseif ($opening_debit == 0 && $opening_credit == 0){ if ( $net_movement_debit != 0){ $closing_debit = $net_movement_debit; }else{ $closing_credit = $net_movement_credit; } } else{ if ( $net_movement_credit != 0){ $closing_credit = $opening_credit + $net_movement_credit; }else{ if ($opening_credit > $net_movement_debit){ $closing_credit = $opening_credit - $net_movement_debit; }else{ $closing_debit = $net_movement_debit - $opening_credit; } } } @endphp {{$closing_debit}} {{$closing_credit}} @endif @endif @endif