@use('App\Services\Date') @extends('reports::layouts.master') @section('title', __('reports::reports.Income Statement')) @section('page-link') @endsection @section('section_title') @lang('reports::reports.Income Statement') @endsection @section('action_buttons')
@if(LaravelLocalization::getCurrentLocale() === 'en') @else @endif @isset($data['revenue']) @can('reports.income-statement.export') @endcan @endisset
@endsection @section('form-open-tag')
@lang('Filter')
@error('fiscal_year_id') @enderror @error('from') @enderror @error('to') @enderror
@php $selectedCostCenters = (array) request('cost_center_id', []); $allCostCentersCount = app(\Modules\Products\Repositories\CostCentersRepository::class)->count(); $costCentersCollection = is_array($data['costCenters']) ? collect($data['costCenters']) : $data['costCenters']; $hasAccessToAllCostCenters = auth()->user()->adjustRolesLikeOwnerPermissions() || $data['costCenters']->count() >= $allCostCentersCount; @endphp @error('cost_center_id') @enderror
@error('without_opening_balance') @enderror
@error('compare_option_id') @enderror
@php $selectedInterval = (int) request('intervals', 1); @endphp
@error('intervals') @enderror
@error('hide_zero_accounts') @enderror
@endsection @section('koolreport') @isset($data['revenue'])
@endisset @isset($data['revenue']) @php($isComparison = isset($data['comparedDates']) && count($data['comparedDates']))

@lang('reports::reports.Income Statement')

{{ $data['companyName'] }}

{{-- Comparison mode --}} @if($isComparison)
@foreach($data['comparedDates'] as $date) @endforeach {{-- Revenue Category Header --}} @foreach($data['comparedDates'] as $date) @endforeach {{-- Sales Subcategory Header --}} {{-- Sales Accounts --}} @foreach(($data['sales']['accounts'] ?? []) as $code => $accountPeriods) @foreach($accountPeriods as $period) @php($balance = $period['balance'] ?? 0) @endforeach @endforeach {{-- Total Sales Row --}} @foreach($data['comparedDates'] as $date) @php($val = $data['total']['sales'][$date] ?? 0) @endforeach {{-- Purchases Subcategory Header --}} {{-- Purchases Accounts --}} @foreach(($data['purchases']['accounts'] ?? []) as $code => $accountPeriods) @foreach($accountPeriods as $period) @php($balance = $period['balance'] ?? 0) @endforeach @endforeach {{-- Total Purchases Row --}} @foreach($data['comparedDates'] as $date) @php($val = $data['total']['purchases'][$date] ?? 0) @endforeach {{-- Operating Expenses Subcategory Header --}} {{-- Operating Expenses Accounts --}} @foreach(($data['operatingExpenses']['accounts'] ?? []) as $code => $accountPeriods) @foreach($accountPeriods as $period) @php($balance = $period['balance'] ?? 0) @endforeach @endforeach {{-- Total Operating Expenses Row --}} @foreach($data['comparedDates'] as $date) @php($val = $data['total']['operatingExpenses'][$date] ?? 0) @endforeach {{-- Totals: Sales Cost & Earnings --}} @foreach($data['comparedDates'] as $date) @php($val = ($data['total']['purchases'][$date] ?? 0) + ($data['total']['operatingExpenses'][$date] ?? 0)) @endforeach @foreach($data['comparedDates'] as $date) @php($val = ($data['total']['sales'][$date] ?? 0) - (($data['total']['purchases'][$date] ?? 0) + ($data['total']['operatingExpenses'][$date] ?? 0))) @endforeach {{-- Expenses Category Header --}} {{-- General Expenses Subcategory Header --}} {{-- General Expenses Accounts --}} @foreach(($data['generalExpenses']['accounts'] ?? []) as $code => $accountPeriods) @foreach($accountPeriods as $period) @php($balance = $period['balance'] ?? 0) @endforeach @endforeach {{-- Total General Expenses --}} @foreach($data['comparedDates'] as $date) @php($val = $data['total']['generalExpenses'][$date] ?? 0) @endforeach {{-- Marketing Expenses Header --}} {{-- Marketing Expenses Accounts --}} @foreach(($data['marketingExpenses']['accounts'] ?? []) as $code => $accountPeriods) @foreach($accountPeriods as $period) @php($balance = $period['balance'] ?? 0) @endforeach @endforeach {{-- Total Marketing Expenses --}} @foreach($data['comparedDates'] as $date) @php($val = $data['total']['marketingExpenses'][$date] ?? 0) @endforeach {{-- Total Expenses Category --}} @foreach($data['comparedDates'] as $date) @php($val = ($data['total']['generalExpenses'][$date] ?? 0) + ($data['total']['marketingExpenses'][$date] ?? 0)) @endforeach @foreach($data['comparedDates'] as $date) @php($net = (($data['total']['sales'][$date] ?? 0) - (($data['total']['purchases'][$date] ?? 0) + ($data['total']['operatingExpenses'][$date] ?? 0))) - (($data['total']['generalExpenses'][$date] ?? 0) + ($data['total']['marketingExpenses'][$date] ?? 0))) @endforeach

{{ Date::format($date, 'date') }}

{{ $data['revenue']['categoryName'] }}
{{ $data['sales']['subCategoryName'] }}
{{ $code }} @php($roundedBalance = round($balance, 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
{{ $data['sales']['subCategoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
{{ $data['purchases']['subCategoryName'] }}
{{ $code }} @php($roundedBalance = round($balance, 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
{{ $data['purchases']['subCategoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
{{ $data['operatingExpenses']['subCategoryName'] }}
{{ $code }} @php($roundedBalance = round($balance, 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['operatingExpenses']['subCategoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
@lang('reports::reports.total_sales_cost')@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
@lang('reports::reports.total_earning')@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
{{ $data['expenses']['categoryName'] }}
{{ $data['generalExpenses']['subCategoryName'] }}
{{ $code }} @php($roundedBalance = round($balance, 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['generalExpenses']['subCategoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
{{ $data['marketingExpenses']['subCategoryName'] }}
{{ $code }} @php($roundedBalance = round($balance, 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['marketingExpenses']['subCategoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif
@lang('reports::reports.total') {{ $data['expenses']['categoryName'] }}@if($val < 0) ({{ number_format(abs($val), 2, '.', ',') }}) @else {{ number_format(abs($val), 2, '.', ',') }} @endif

@lang('reports::reports.net_earnings')@if($net < 0) ({{ number_format(abs($net), 2, '.', ',') }}) @else {{ number_format(abs($net), 2, '.', ',') }} @endif
@else {{-- Single period mode (existing) --}}

@lang('from') {{$data['dates']['from']}} @lang('to') {{$data['dates']['to']}}

@foreach(($data['sales']['accounts'] ?? []) as $account) @if(! (request('hide_zero_accounts') && $account['balance'] == 0 && !$account['isHasTransactions'])) @if($account) @endif @endif @endforeach @foreach(($data['purchases']['accounts'] ?? []) as $account) @if(! (request('hide_zero_accounts') && $account['balance'] == 0 && !$account['isHasTransactions'])) @if($account) @endif @endif @endforeach @foreach(($data['operatingExpenses']['accounts'] ?? []) as $account) @if(! (request('hide_zero_accounts') && $account['balance'] == 0 && !$account['isHasTransactions'])) @if($account) @endif @endif @endforeach @foreach(($data['generalExpenses']['accounts'] ?? []) as $account) @if(! (request('hide_zero_accounts') && $account['balance'] == 0 && !$account['isHasTransactions'])) @if($account) @endif @endif @endforeach @foreach(($data['marketingExpenses']['accounts'] ?? []) as $account) @if(! (request('hide_zero_accounts') && $account['balance'] == 0 && !$account['isHasTransactions'])) @if($account) @endif @endif @endforeach
@lang('reports::reports.total')
{{ $data['revenue']['categoryName'] }}
{{$account['code']}} - {{$account['name']}} @php($roundedBalance = round($account['balance'], 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
{{__('reports::reports.total_other_revenue')}} @if($data['sales']['total'] < 0) ({{number_format(abs($data['sales']['total']), 2, '.', ',')}}) @else {{ number_format(abs($data['sales']['total']), 2, '.', ',') }} @endif
{{__('reports::reports.Purchases')}}
{{$account['code']}} - {{$account['name']}} @php($roundedBalance = round($account['balance'], 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{__('reports::reports.Purchases')}} @if($data['purchases']['total'] < 0) ({{number_format(abs($data['purchases']['total']), 2, '.', ',')}}) @else {{ number_format(abs($data['purchases']['total']), 2, '.', ',') }} @endif
{{ $data['operatingExpenses']['subcategoryName'] }}
{{$account['code']}} - {{$account['name']}} @php($roundedBalance = round($account['balance'], 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['operatingExpenses']['subcategoryName'] }} @if($data['operatingExpenses']['total'] < 0) ({{number_format(abs($data['operatingExpenses']['total']), 2, '.', ',')}}) @else {{ number_format(abs($data['operatingExpenses']['total']), 2, '.', ',') }} @endif
@lang('reports::reports.total_sales_cost') @if($data['totalSalesCost'] < 0) ({{number_format(abs($data['totalSalesCost']), 2, '.', ',')}}) @else {{ number_format(abs($data['totalSalesCost']), 2, '.', ',') }} @endif
@lang('reports::reports.total_earning') @if($data['TotalEarning'] < 0) ({{number_format(abs($data['TotalEarning']), 2, '.', ',')}}) @else {{ number_format(abs($data['TotalEarning']), 2, '.', ',') }} @endif
{{ $data['expenses']['categoryName'] }}
{{ $data['generalExpenses']['subcategoryName'] }}
{{$account['code']}} - {{$account['name']}} @php($roundedBalance = round($account['balance'], 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['generalExpenses']['subcategoryName'] }} @if($data['generalExpenses']['total'] < 0) ({{number_format(abs($data['generalExpenses']['total']), 2, '.', ',')}}) @else {{ number_format(abs($data['generalExpenses']['total']), 2, '.', ',') }} @endif
{{ $data['marketingExpenses']['subcategoryName'] }}
{{$account['code']}} - {{$account['name']}} @php($roundedBalance = round($account['balance'], 2)) @if($roundedBalance < 0) ({{ number_format(abs($roundedBalance), 2, '.', '') }}) @else {{ number_format(abs($roundedBalance), 2, '.', '') }} @endif
@lang('reports::reports.total') {{ $data['marketingExpenses']['subcategoryName'] }} @if($data['marketingExpenses']['total'] < 0) ({{number_format(abs($data['marketingExpenses']['total']), 2, '.', ',')}}) @else {{ number_format(abs($data['marketingExpenses']['total']), 2, '.', ',') }} @endif
@lang('reports::reports.total') {{ $data['expenses']['categoryName'] }} @if($data['expenses']['total'] < 0) ({{number_format(abs($data['expenses']['total']), 2, '.', ',')}}) @else {{number_format(abs($data['expenses']['total']), 2, '.', ',')}} @endif

@lang('reports::reports.net_earnings') @if($data['net'] < 0) ({{number_format(abs($data['net']), 2, '.', ',')}}) @else {{number_format(abs($data['net']), 2, '.', ',')}} @endif
@endif
@lang('reports::reports.accrual_basis') @if(request('without_opening_balance')) @lang('reports::reports.without_opening_balances') @endif {{ Date::format(now(), 'date') }} {{ now()->format('H:i') }}
@endisset @isset($data['revenue'])
@endisset @endsection @section('filter-by-dates') @endsection @section('opening_balance_option') @endsection @section('custom_duration') @endsection @section('extra_scripts_filter_by_date') @endsection