@php $isDebit = $type === 'debit_note'; $navLabel = $isDebit ? trans('dashboard.nav_debit_notes') : trans('dashboard.nav_credit_notes'); $actionLabel = $isDebit ? trans('dashboard.new_debit_note_btn') : trans('dashboard.new_credit_note_btn'); $reasonPlaceholder = $isDebit ? trans('dashboard.debit_note_reason_placeholder') : trans('dashboard.credit_note_reason_placeholder'); $recentInvoicesData = $originals->map(fn ($orig) => [ 'uuid' => $orig->uuid, 'invoice_number' => $orig->invoice_number, 'buyer_name' => $orig->buyer_name, 'total' => (float) $orig->total, 'subtotal' => (float) $orig->subtotal, 'vat_amount' => (float) $orig->vat_amount, 'currency' => $orig->currency ?: 'SAR', 'has_previous_notes' => false, 'remaining_balance' => (float) $orig->subtotal, 'lines' => $orig->invoice_data['lines'] ?? [], 'buyer' => $orig->invoice_data['buyer'] ?? ['name' => $orig->buyer_name], 'device_uuid' => $orig->device?->uuid, ])->values()->all(); @endphp
{{-- Breadcrumb Navigation --}}
{{-- Main Note Card Form --}}
{{-- Form Tag --}}
@csrf {{-- Hidden Buyer Payload from Original Invoice --}} {{-- 1. Original Invoice Section (الفاتورة الأصلية) --}}
{{-- State A: Searching for Original Invoice --}}
{{-- Search Error --}} {{-- Quick Select from recent eligible invoices --}} @if($originals->isNotEmpty())
{{ trans('dashboard.quick_select_recent_invoices') }}
@foreach($originals as $index => $orig) @endforeach
@endif
{{-- State B: Original Invoice is Selected (Green Border Card) --}}
{{-- Previous credit notes warning (for credit notes only) --}}
{{-- 2. Line Items Section (البنود – عدّل الكميات أو المبالغ حسب الحاجة) --}}
{{ trans('dashboard.line_name') }} {{ trans('dashboard.qty_label') }} {{ trans('dashboard.net_price') }} {{ trans('dashboard.th_total') }}
{{-- 3. Reason Input (السبب *) --}}

{{ trans('dashboard.credit_note_reason_hint') }}

{{-- 4. Totals Summary --}}
{{ trans('dashboard.subtotal_excl_vat') }}
{{ trans('dashboard.vat_15_pct') }}
{{ trans('dashboard.credit_note_total_label') }}
{{-- 5. Submit Action Button --}}
{{ trans('dashboard.instant_sign_zatca_notice') }}