@php $accounts_selection = request()->accounts_selection ?? 'from_accounts'; $show_way = request()->show_way ?? 'detailed'; $period_id = request()->period_id; @endphp
@php $to_date = $last_invoice_date->format(config('app.date_format')); @endphp


receivable_type && in_array('client', request()->receivable_type) ? 'checked' : '' }}>
receivable_type && in_array('supplier', request()->receivable_type) ? 'checked' : '' }}>

balance_status && in_array('debit', request()->balance_status) ? 'checked' : '' }}>
balance_status && in_array('credit', request()->balance_status) ? 'checked' : '' }}>

@lang('accounting/reports/receivables/receivable-account-aging.aging_receivables_statement')

@lang('accounting/reports/receivables/receivable-account-aging.download_pdf') @php $query = (count(request()->all()) > 0)? '?' . explode('?', request()->fullUrl())[1] : "" @endphp @lang('accounting/reports/receivables/receivable-account-aging.export_excel')
@if ($period_id) @php $period = $periods->where('id', request()->period_id)->first(); @endphp @if ($period)
@lang('accounting/reports/receivables/receivable-account-aging.period') {{ $period->title }}
@endif @endif
@forelse ($receivable_accounts as $receivable_account) @php $cols_count = 1 + ((!$period_id)? count($periods) : 0) + (($show_way == 'detailed')? 4 : 0); @endphp
@lang('accounting/reports/receivables/receivable-account-aging.receivable') {{ $receivable_account->name }}
@if (!$period_id) @foreach ($periods as $period) @endforeach @endif @if ($show_way == 'detailed') @endif @php $invoices = collect( array_merge( $receivable_account->sale_services_invoices->all(), $receivable_account->sales_invoices->all(), $receivable_account->rental_contract_invoices->all(), ), )->sortByDesc(function ($invoice) { return isset($invoice->date) ? $invoice->date : $invoice->accrued_date_starting; }); $balance = 0; @endphp @if ($show_way == 'detailed') @forelse ($invoices as $invoice) @php $date = ($invoice->date)?? $invoice->accrued_date_starting; @endphp @php $date = (is_string($date))? parse_date_to_carbon($date) : $date; @endphp @php $invoice_period = $getPeriodForInvoice($date); @endphp @php $balance+= $invoice->accrued_amount; @endphp @if (!$period_id) @foreach ($periods as $period) @if ($invoice_period == $period->id) @else @endif @endforeach @endif @empty @if (!$period_id) @foreach ($periods as $period) @endforeach @endif @if ($show_way == 'detailed') @endif @endforelse @else @if (!$period_id) @foreach ($periods as $period) @php $from_date = $period->id != '>last' ? $last_invoice_date->subDays($period->days_count) : '*'; $to_date = $last_invoice_date; $period_invoices_sum = $invoices ->filter(function ($invoice) use ($from_date, $to_date) { $date = isset($invoice->date) ? $invoice->date : $invoice->accrued_date_starting; $date = parse_date_to_carbon($date); if ($from_date == '*') { return $date < $to_date; } return $date >= $from_date && $date < $to_date; }) ->sum('accrued_amount'); $balance += $period_invoices_sum; @endphp @endforeach @else @endif @endif
#{{ $period->title }}@lang('accounting/reports/receivables/receivable-account-aging.transaction_type') @lang('accounting/reports/receivables/receivable-account-aging.deserved_amount') @lang('accounting/reports/receivables/receivable-account-aging.transaction_date') @lang('accounting/reports/receivables/receivable-account-aging.transaction_number')@lang('accounting/reports/receivables/receivable-account-aging.balance')
{{ $loop->iteration }}{{ dn($invoice->accrued_amount) }}{{ dn('0.000') }} {{ match (basename(str_replace('\\', '/', get_class($invoice)))) { 'RentalContractInvoice' => 'فاتورة عقد إيجار', 'ServiceInvoice' => 'فاتورة بيع خدمات', 'SalesInvoice' => 'فاتورة مبيعات', } }} {{ dn($invoice->accrued_amount) }} {{ $date->format('Y-m-d') }} {{ $invoice->id }} {{ $balance }}
@lang('accounting/reports/receivables/receivable-account-aging.there_are_no_deserved_invoices')
1 {{ dn($period_invoices_sum) }} {{ dn($balance) }} {{ dn($invoices->sum('accrued_amount')) }}
@empty

@lang('accounting/reports/receivables/receivable-account-aging.there_are_no_receivables')

@endforelse