@use('App\Services\Date') @extends('reports::layouts.master') @section('title', __('reports::reports.Balance Sheet')) @section('page-link') @endsection @section('action_buttons')
@if(LaravelLocalization::getCurrentLocale() === 'en') @else @endif @if(request()->all()) @can('reports.balance-sheet.export') @endcan @endif
@endsection @section('section_title') @lang('reports::reports.Balance Sheet') @endsection @section('form-open-tag')
@lang('Filter')
@error('fiscal_year_id') @enderror @error('from') @enderror @error('to') @enderror
@error('level') @enderror
@error('compare_option_id') @enderror
@php $selectedInterval = (int) request('intervals', 1); @endphp
@error('intervals') @enderror
@endsection @section('koolreport') @if(request()->all())

@lang('reports::reports.Balance Sheet')

{{ $data['companyName'] }}

{{-- Determine view type: single vs comparison --}} @if(isset($data['periods'])) {{-- === Comparison Mode (multiple periods) === --}}
@foreach($data['periods'] as $period) @endforeach {{-- repurpose markup from previous compare blade --}} @foreach ($data['categories'] as $category) @foreach($category['subCategories'] as $subCategory) @foreach($subCategory['accounts'] as $account) @foreach($account['current_balance'] as $balance) @endforeach @php $tree = $account['tree']['directChildren'] ?? null; @endphp @isset($tree) {!! generateHTMLForBalanceSheetComparisonCustomLevel($tree,1,request('level')+1) !!} @endisset {{-- totals per account (only when account has tree totals) --}} @php $treeTotals = $account['tree']['total'] ?? []; @endphp @if(isset($account['tree']) && array_sum($treeTotals) != 0) @foreach($treeTotals as $total) @endforeach @endif @endforeach {{-- totals per subcategory --}} @foreach($subCategory['total'] as $total) @endforeach {{-- separator row for credit categories --}} @if($category['category']->id != \Modules\Accounting\Enums\AccountingCategoriesEnum::ASSETS) @foreach($category['total'] as $total)@endforeach @endif @endforeach {{-- total per category (credits only) --}} @if($category['category']->id != \Modules\Accounting\Enums\AccountingCategoriesEnum::ASSETS) @foreach($category['total'] as $total) @endforeach @endif {{-- debit total (first loop iteration) --}} @if($loop->iteration == 1) @foreach($data['totalDebit'] as $debit) @endforeach @endif @endforeach {{-- net earnings row --}} @foreach($data['net'] as $net) @endforeach {{-- total credit row --}} @foreach($data['totalCredit'] as $credit) @endforeach
{{ Date::format($period) }}
{{ $category['category']->name}}
{{ $subCategory['name'] }}
{{ $account['code'] }} - {{ $account['name'] }} @if($balance >= 0) {{ number_format($balance,2) }} @else ({{ number_format(abs($balance),2) }}) @endif
@lang('reports::reports.total') {{ $account['name'] }} @if($total >= 0) {{ number_format($total,2) }} @else ({{ number_format(abs($total),2) }}) @endif
@lang('reports::reports.total') {{ $subCategory['name'] }} @if($total >= 0) {{ number_format($total,2) }} @else ({{ number_format(abs($total),2) }}) @endif
@lang('reports::reports.total') {{ $category['category']->name }} @if($total >= 0) {{ number_format($total,2) }} @else ({{ number_format(abs($total),2) }}) @endif
@lang('reports::reports.balance_sheet_total_debit')@if($debit >= 0) {{ number_format($debit,2) }} @else ({{ number_format(abs($debit),2) }}) @endif
@lang('reports::reports.net_earnings')@if($net >= 0) {{ number_format($net,2) }} @else ({{ number_format(abs($net),2) }}) @endif
@lang('reports::reports.balance_sheet_total_credit')@if($credit >= 0) {{ number_format($credit,2) }} @else ({{ number_format(abs($credit),2) }}) @endif
@lang('reports::reports.accrual_basis') @if(app()->getLocale() == 'ar') {{ Date::now('datetime') }} @else {{ Date::now('datetime') }} @endif
@else {{-- === Single Period Mode (existing layout) === --}}

@lang('reports::reports.Balance Sheet')

{{ $data['companyName'] }}

@lang('reports::reports.balance_sheet_as_of') {{$data['to']}}

@foreach ($data['categories'] as $category) @foreach($category['subCategories'] as $subCategory) @foreach($subCategory['accounts'] as $account) @if($account['current_balance']!=0||$account['total']!=0) @php if(isset($account['tree'])){ $tree=$account['tree']['directChildren']; } @endphp @isset($account['tree']) {!! generateHTMLForBalanceSheetCustomLevel($tree,1,request('level')+1) !!} @endisset @php $treeTotal = $account['tree']['total'] ?? 0; @endphp @if(isset($account['tree']) && $treeTotal != 0) @endif @endif @endforeach @if($subCategory['total'] != 0) @endif @if($category['category']->id!=\Modules\Accounting\Enums\AccountingCategoriesEnum::ASSETS) @endif @endforeach @if($category['category']->id!=\Modules\Accounting\Enums\AccountingCategoriesEnum::ASSETS) @endif @if($loop->iteration==1) {{-- I depeand here the fact that here is only one debit category which is the first one --}} {{-- I depeand here the fact that here is only one debit category which is the first one --}} @else @endif @endforeach
@lang('reports::reports.balance') / @lang('reports::reports.total')
{{ $category['category']->name}}
{{$subCategory['name']}} @if($subCategory['total'] == 0) {{ number_format($subCategory['total'],2) }} @endif
{{$account['code']}} - {{$account['name']}} @if($account['current_balance']>=0) {{ number_format($account['current_balance'],2)}} @else ({{ number_format(abs($account['current_balance']),2)}}) @endif
@lang('reports::reports.total') {{$account['name']}} @if($treeTotal >= 0) {{ number_format($treeTotal,2) }} @else ({{ number_format(abs($treeTotal),2) }}) @endif
@lang('reports::reports.total') {{$subCategory['name']}} @if($subCategory['total']>0) {{ number_format($subCategory['total'],2) }} @else ({{ number_format(abs($subCategory['total']),2)}}) @endif
@lang('reports::reports.total') {{$category['category']->name}} @if($category['total']>=0) {{ number_format($category['total'],2) }} @else ({{ number_format(abs($category['total']),2)}}) @endif
@lang('reports::reports.balance_sheet_total_debit') @if($data['totalDebit']>=0) {{ number_format($data['totalDebit'],2) }} @else ({{ number_format(abs($data['totalDebit']),2)}}) @endif
@lang('reports::reports.net_earnings') @if($data['net']>=0) {{ number_format($data['net'],2) }} @else ({{ number_format(abs($data['net']),2)}}) @endif
@lang('reports::reports.balance_sheet_total_credit') @if($data['totalCredit']>=0) {{ number_format($data['totalCredit'],2) }} @else ({{ number_format(abs($data['totalCredit']),2)}}) @endif
@lang('reports::reports.accrual_basis') {{ Date::now('datetime') }}
@endif
@endif @endsection @section('filter-by-dates') @endsection @section('custom_duration') @endsection @section('extra_scripts_filter_by_date') @endsection