@extends(niche_shell_layout()) @section('title', 'إضافة قيد - '.config('app.name')) @section('breadcrumb') الرئيسية › المحاسبة › القيود اليومية › قيد جديد @endsection @section('content') @php $journalAccountSelectOptions = collect($accounts ?? [])->map(fn ($account) => [ 'v' => (string) $account->id, 'l' => trim((string) ($account->code ?? '').' - '.(string) ($account->name_ar ?? '')), ])->values()->all(); $journalAccountSelectOptions = array_merge([['v' => '', 'l' => 'اختر الحساب']], $journalAccountSelectOptions); $journalCreateConfig = [ 'headerDefaults' => [ 'date' => old('date', now()->toDateString()), 'reference' => old('reference', ''), 'description' => old('description', ''), ], 'accountOptions' => $journalAccountSelectOptions, 'initial' => null, ]; $oldLines = old('lines'); if (is_array($oldLines) && count($oldLines) >= 2) { $mapLines = []; foreach ($oldLines as $line) { $line = is_array($line) ? $line : []; $mapLines[] = [ 'account_id' => (string) ($line['account_id'] ?? ''), 'description' => $line['description'] ?? '', 'cost_center' => $line['cost_center'] ?? '', 'debit' => isset($line['debit']) && $line['debit'] !== '' ? (float) $line['debit'] : 0, 'credit' => isset($line['credit']) && $line['credit'] !== '' ? (float) $line['credit'] : 0, ]; } $journalCreateConfig['initial'] = [ 'date' => old('date', now()->toDateString()), 'reference' => old('reference', ''), 'description' => old('description', ''), 'lines' => $mapLines, ]; } @endphp
@endsection