@php /** @var \App\Models\Account $account */ /** @var int $level */ $pad = $level * 20; $typeLabel = match($account->type) { \App\Models\Account::TYPE_ASSET => 'أصل', \App\Models\Account::TYPE_LIABILITY => 'خصم', \App\Models\Account::TYPE_EQUITY => 'حقوق ملكية', \App\Models\Account::TYPE_EXPENSE => 'مصروف', \App\Models\Account::TYPE_REVENUE => 'إيراد', default => $account->type ?? '—', }; $balance = (float) (data_get($balancesByAccount ?? [], $account->id, $account->current_balance ?? $account->opening_balance)); $debit = $balance > 0 ? $balance : 0; $credit = $balance < 0 ? abs($balance) : 0; $journalLineSet = $journalLineSet ?? []; $hasJournalLines = isset($journalLineSet[$account->id]); $hasChildren = $account->relationLoaded('childrenRecursive') ? $account->childrenRecursive->isNotEmpty() : ($account->relationLoaded('children') ? $account->children->isNotEmpty() : $account->children()->exists()); $canLedgerDeleteEmpty = \App\Support\ErpRoles::canDeleteExpenseDraft(auth()->user()); $canSuperPurge = \App\Support\ErpRoles::isSuperAdmin(auth()->user()); // حذف عادي: ورقة بلا قيود وبلا فروع — المسار الخادمي يرفض غير ذلك $showDeleteNormal = $canLedgerDeleteEmpty && ! $hasJournalLines && ! $hasChildren; // تطهير (سوبر أدمن): أي حالة لا يُقبل فيها الحذف العادي (قيود، فروع، أو أدمن ليس له حذف نهائي) $showPurgeAccount = $canSuperPurge && ! $showDeleteNormal; @endphp {{ $account->code }}

{{ $account->name_ar ?? '—' }}

@if($account->name_en)

{{ $account->name_en }}

@endif
{{ $typeLabel }} SAR {{ erp_money($debit) }} SAR {{ erp_money($credit) }} SAR {{ erp_money($balance) }}
@csrf @method('PATCH')
@foreach($account->childrenRecursive as $child) @include('finance.accounts._row', ['account' => $child, 'level' => $level + 1, 'journalLineSet' => $journalLineSet]) @endforeach