@use('App\Services\Date') @extends('reports::layouts.master_pdf') @section('koolreport') @php $subdomain = request()->route()->parameter('subdomain'); $is_student = app(\Hyn\Tenancy\Repositories\HostnameRepository::class)->findByHostname($subdomain)->website->company->is_student; $currency = $data['currency'] ?? 'SAR'; $sections = $data['cash_flow_direct'] ?? []; $renderAmount = static function ($value) { $amount = (float) $value; return $amount < 0 ? '(' . number_format(abs($amount), 2) . ')' : number_format($amount, 2); }; $renderAccounts = static function (array $accounts, int $depth = 1) use (&$renderAccounts, $renderAmount) { foreach ($accounts as $account) { $code = trim((string) ($account['code'] ?? '')); $name = trim((string) ($account['name'] ?? '')); $label = trim(($code !== '' ? $code . ' - ' : '') . $name); echo ''; echo '' . e($label) . ''; echo '' . e($renderAmount($account['current_balance'] ?? 0)) . ''; echo ''; $children = $account['directChildren'] ?? []; if (is_array($children) && $children !== []) { $renderAccounts($children, $depth + 1); } $current = (float) ($account['current_balance'] ?? 0); $total = (float) ($account['total'] ?? $current); if (abs($total - $current) > 0.000001) { echo ''; echo '' . e(__('reports::reports.total') . ' ' . $name) . ''; echo '' . e($renderAmount($total)) . ''; echo ''; } } }; @endphp
@if($is_student) @include('draft_report') @endif

@lang('reports::reports.Cash Flow Direct')

{{ $data['companyName'] ?? '' }}

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

@foreach($sections as $section) @foreach(($section['subsections'] ?? []) as $subsection) @if(!empty($subsection['accounts']) && is_array($subsection['accounts'])) {!! $renderAccounts($subsection['accounts'], 2) !!} @if(!empty($subsection['total_label'])) @endif @else @endif @endforeach @if(!empty($section['accounts']) && is_array($section['accounts'])) {!! $renderAccounts($section['accounts'], 1) !!} @endif @endforeach
@lang('reports::reports.account') @lang('reports::reports.total') ({{ $currency }})
{{ $section['name'] ?? '' }}
{{ $subsection['name'] ?? '' }}
{{ $subsection['total_label'] }} {{ $renderAmount($subsection['total'] ?? 0) }}
{{ $subsection['name'] ?? '' }} {{ $renderAmount($subsection['total'] ?? 0) }}
{{ $section['total_label'] ?? '' }} {{ $renderAmount($section['total'] ?? 0) }}
{{ __('reports::reports.cash_flow_direct.net_change_in_cash') }} {{ $renderAmount($data['net_change_in_cash'] ?? 0) }}
{{ __('reports::reports.cash_flow_direct.total_cash_equivalents') }} {{ $renderAmount($data['total_cash_equivalents'] ?? 0) }}
{{ __('reports::reports.cash_flow_direct.available_cash_duration') }} {{ $renderAmount($data['available_cash_duration'] ?? 0) }}
@lang('reports::reports.accrual_basis') {{ Date::format(now(), 'datetime') }}
@endsection