{{-- resources/views/admin/sales_invoices/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); $date = fn($v) => $v ? \Carbon\Carbon::parse($v)->format('Y-m-d') : '-'; $status = $invoice->status ?? 'draft'; $statusBadge = match($status){ 'draft' => ['primary', 'Draft'], 'posted' => ['info', 'Posted'], 'paid' => ['success', 'Paid'], 'partial' => ['warn', 'Partial'], 'cancelled' => ['danger', 'Cancelled'], default => ['primary', $status], }; $payType = $invoice->payment_type ?? 'cash'; $payBadge = $payType === 'cash' ? ['success','Cash'] : ['warn','Credit']; $customer = $invoice->customer; $hasReturns = !empty($invoice->returns) && $invoice->returns->count() > 0; $payments = $invoice->payments ?? collect(); // ✅ Journal Entry relation (make sure loaded) $je = $invoice->journalEntry ?? null; $lines = $je?->lines ?? collect(); $jeStatus = $je?->status ?? null; $jeBadge = $jeStatus ? match($jeStatus){ 'posted' => ['success','Posted'], 'draft' => ['warn','Draft'], 'reversed' => ['danger','Reversed'], default => ['primary',$jeStatus], } : null; @endphp {{-- Topbar --}}
@include('admin.Alerts')| الحساب | # | مدين | دائن | Memo |
|---|---|---|---|---|
|
{{ $l->account?->name ?? ('#'.$l->account_id) }}
{{ $l->account?->account_number ? ('#'.$l->account->account_number) : '' }}
@if($l->currency_code)
— {{ $l->currency_code }}
@endif
@if($l->branch_id)
— Branch: {{ $l->branch_id }}
@endif
|
#{{ $l->line_no }} | {{ $fmt($l->debit, 2) }} | {{ $fmt($l->credit, 2) }} | {{ $l->memo ?? '-' }} |
|
لا توجد سطور للقيد.
|
||||
| الصنف | الكود/باركود | Qty | Price | Disc | VAT | Total |
|---|---|---|---|---|---|---|
|
{{ $it?->name ?? ('#'.$line->item_id) }}
{{ $it?->type ? ('نوع: '.$it->type) : '' }}
|
@if($code) #{{ $code }} @endif @if($code && $barcode) — @endif @if($barcode) {{ $barcode }} @endif @if(!$code && !$barcode) - @endif | {{ $fmt($line->quantity, 4) }} | {{ $fmt($line->price, 4) }} | {{ $fmt($line->discount, 4) }} | {{ $fmt($line->vat, 4) }} | {{ $fmt($line->total, 4) }} |
|
لا توجد أصناف داخل الفاتورة.
|
||||||
| التاريخ | الخزنة | المبلغ | مرجع | JE |
|---|---|---|---|---|
| {{ $date($p->payment_date) }} | {{ $p->treasury?->name ?? ('#'.$p->treasury_id) }} | {{ $fmt($p->amount, 2) }} | {{ $p->reference ?? '-' }} | @if($p->journal_entry_id) #{{ $p->journal_entry_id }} @else - @endif |
| # | تاريخ المرتجع | الإجمالي |
|---|---|---|
| #{{ $r->id }} | {{ $date($r->return_date) }} | {{ $fmt($r->total, 2) }} |