{{-- resources/views/admin/customers/show.blade.php --}} @extends('admin.layouts.master') @section('title', 'عرض عميل') @section('css') @endsection @section('content') @php $fmt = fn($n, $d=2) => number_format((float)($n ?? 0), $d); $netLabel = function ($net) { $net = (float)$net; if ($net > 0) return ['مدين', 'success']; if ($net < 0) return ['دائن', 'danger']; return ['متزن', 'info']; }; $custStart = (float)($customer->start_balance ?? 0); $custCur = (float)($customer->current_balance ?? 0); $delta = $custCur - $custStart; $kpis = $kpis ?? [ 'total_debit' => (float)($lines?->sum('debit') ?? 0), 'total_credit' => (float)($lines?->sum('credit') ?? 0), 'net_move' => (float)(($lines?->sum('debit') ?? 0) - ($lines?->sum('credit') ?? 0)), ]; [$custStartTxt, $custStartCls] = $netLabel($custStart); [$custCurTxt, $custCurCls] = $netLabel($custCur); [$netMoveTxt, $netMoveCls] = $netLabel($kpis['net_move'] ?? 0); $running = 0.0; @endphp
بطاقة عميل
{{ $customer->name }} @if($customer->account_number) — رقم الحساب: {{ $customer->account_number }} نسخ @endif
رجوع @if(Route::has('customers.edit')) تعديل @endif @if(Route::has('customers.destroy'))
@csrf @method('DELETE')
@endif
@include('admin.Alerts')
{{-- Left --}}
{{-- Profile --}}
customer
{{ $customer->name }}
{{ $customer->city ?? '—' }}
@if($customer->status) نشط @else غير نشط @endif
الهاتف
{{ $customer->phone ?? '—' }}
كود العميل
{{ $customer->code ?? '—' }}
البريد
{{ $customer->email ?? '—' }}
تاريخ فتح الحساب
{{ $customer->date ? \Carbon\Carbon::parse($customer->date)->format('Y-m-d') : '—' }}
آخر تحديث بواسطة
{{ $customer->updated_by ?? '—' }}
ملاحظات
{!! nl2br(e($customer->notes ?? '—')) !!}
{{-- Linked Account --}}
الحساب المالي المرتبط
@if($account) Linked @else Not linked @endif
@if(!$customer->account_number)
العميل غير مرتبط برقم حساب. تأكد من خدمة إنشاء العميل/الحساب.
@elseif(!$account)
رقم الحساب موجود على العميل لكن لم يتم العثور على الحساب في شجرة الحسابات.
@else
اسم الحساب
{{ $account->name }}
رقم الحساب
{{ $account->account_number }} نسخ
النوع
{{ $account->type?->name ?? '—' }}
المسار
{{ $account->parent?->name ? ($account->parent->name . ' / ' . $account->name) : $account->name }}
الحالة
@if($account->status) نشط @else غير نشط @endif
@if(Route::has('accounts.show')) فتح الحساب @endif @if(Route::has('accounts.edit')) تعديل الحساب @endif
@endif
{{-- Right --}}
{{-- Summary --}}
ملخص مالي (العميل)
Accounting
الرصيد الافتتاحي
{{ $fmt($custStart) }}
{{ $custStartTxt }}
الرصيد الحالي
{{ $fmt($custCur) }}
{{ $custCurTxt }}
التغير منذ الافتتاح
{{ $fmt($delta) }}
فرق الرصيد الحالي عن الافتتاحي
{{-- Balances --}}
أرصدة الحساب (حسب العملة/الفرع)
account_balances
@if(!$account)
سيتم عرض الأرصدة هنا بعد ربط العميل بحساب مالي.
@elseif($balances->isEmpty())
لا توجد سجلات أرصدة للحساب حتى الآن.
@else
@foreach($balances as $b) @php $bal = (float)($b->balance ?? 0); [$t, $c] = $netLabel($bal); @endphp @endforeach
العملة الفرع إجمالي مدين إجمالي دائن الرصيد الطبيعة
{{ $b->currency_code ?? 'EGP' }} {{ $b->branch_id ?? '—' }} {{ $fmt($b->debit_total) }} {{ $fmt($b->credit_total) }} {{ $fmt($bal) }} {{ $t }}
@endif
{{-- Ledger --}}
كشف حساب العميل (آخر الحركات)
journal_entry_lines
@if(!$account)
سيتم عرض الحركات هنا بعد ربط العميل بحساب مالي.
@elseif($lines->isEmpty())
لا توجد حركات محاسبية على حساب العميل حتى الآن.
@else {{-- Ledger KPIs --}}
إجمالي مدين
{{ $fmt($kpis['total_debit'] ?? 0) }}
مجموع المدين (آخر 50 حركة)
إجمالي دائن
{{ $fmt($kpis['total_credit'] ?? 0) }}
مجموع الدائن (آخر 50 حركة)
صافي الحركة
{{ $fmt($kpis['net_move'] ?? 0) }}
{{ $netMoveTxt }} (مدين - دائن)
@foreach($lines as $line) @php $d = (float)($line->debit ?? 0); $c = (float)($line->credit ?? 0); $running += ($d - $c); $je = $line->journalEntry; $entryId = $je?->id; $entryNo = $je?->entry_number ?? ($entryId ? ('JE#'.$entryId) : '-'); $entryDate = $je?->entry_date ?? $line->created_at; $memo = $line->memo ?? $je?->description ?? '—'; $ccy = $line->currency_code ?? 'EGP'; // مصدر/مرجع (للعرض المحاسبي) $src = $je?->source ?? null; $refType = $je?->reference_type ?? null; $refId = $je?->reference_id ?? null; @endphp @endforeach
التاريخ رقم القيد البيان العملة مدين دائن الرصيد التراكمي
{{ $entryDate ? \Carbon\Carbon::parse($entryDate)->format('Y-m-d') : '-' }} @if($entryId && Route::has('journal_entries.show')) {{ $entryNo }} @else {{ $entryNo }} @endif @if($src)
مصدر: {{ $src }}
@endif
{{ $memo }}
line #{{ (int)($line->line_no ?? 1) }} @if(!empty($line->branch_id)) • branch: {{ $line->branch_id }} @endif @if(!empty($line->cost_center_id)) • cc: {{ $line->cost_center_id }} @endif @if(!empty($line->project_id)) • project: {{ $line->project_id }} @endif @if(!empty($line->warehouse_id)) • wh: {{ $line->warehouse_id }} @endif @if($refType && $refId) • ref: {{ class_basename($refType) }} #{{ $refId }} @endif
{{ $ccy }} {{ $fmt($d) }} {{ $fmt($c) }} {{ $fmt($running) }}
* الرصيد التراكمي محسوب من الحركات المعروضة فقط (آخر 50 حركة).
@endif
@endsection @section('js') @endsection