{{-- resources/views/admin/purchase_invoices/show.blade.php --}} @extends('admin.layouts.master') @section('title', 'عرض فاتورة مشتريات') @section('css') @endsection @section('content') @php $status = $invoice->status ?? 'draft'; $paymentType = $invoice->payment_type ?? 'cash'; $statusChip = match ($status) { 'draft' => ['chip-gray', 'مسودة'], 'posted' => ['chip-blue', 'مُرحّلة'], 'paid' => ['chip-green', 'مدفوعة'], 'partial' => ['chip-yellow', 'جزئي'], 'cancelled' => ['chip-red', 'ملغاة'], default => ['chip-gray', $status], }; $payChip = $paymentType === 'cash' ? ['chip-green', 'كاش'] : ['chip-yellow', 'آجل']; $invoiceDate = $invoice->invoice_date ? \Carbon\Carbon::parse($invoice->invoice_date)->format('Y-m-d') : '-'; $dueDate = $invoice->due_date ? \Carbon\Carbon::parse($invoice->due_date)->format('Y-m-d') : '-'; $postedAt = $invoice->posted_at ? \Carbon\Carbon::parse($invoice->posted_at)->format('Y-m-d H:i') : '-'; $currency = $invoice->currency_code ?? 'EGP'; $fx = (float)($invoice->exchange_rate ?? 1); $invDiscType = $invoice->discount_type ?? 'none'; $invDiscRate = (float)($invoice->discount_rate ?? 0); $invDiscValue = (float)($invoice->discount_value ?? 0); $invDiscDisplay = '-'; if ($invDiscType === 'percent') $invDiscDisplay = number_format($invDiscRate, 2).'%'; elseif ($invDiscType === 'fixed') $invDiscDisplay = number_format($invDiscValue, 2); $canReturn = in_array($status, ['posted','paid','partial'], true) && $status !== 'cancelled'; $returnsCount = $invoice->returns?->count() ?? 0; $returnsTotal = (float)($invoice->returns?->where('status','!=','cancelled')->sum('total') ?? 0); // محاسبة $je = $invoice->journalEntry ?? null; $jeLines = $je?->lines ?? collect(); $jeDebit = (float) $jeLines->sum('debit'); $jeCredit = (float) $jeLines->sum('credit'); $jeBalanced = $je && abs($jeDebit - $jeCredit) < 0.01; // Totals $subBefore = (float)($invoice->subtotal_before_discount ?? 0); $linesDisc = (float)($invoice->items?->sum('discount_value') ?? 0); $subAfter = (float)($invoice->subtotal ?? 0); $tax = (float)($invoice->tax_value ?? 0); $ship = (float)($invoice->shipping_cost ?? 0); $other = (float)($invoice->other_charges ?? 0); $total = (float)($invoice->total ?? 0); $paid = (float)($invoice->paid_amount ?? 0); $remain = (float)($invoice->remaining_amount ?? 0); @endphp
| # | الحساب | رقم الحساب | مدين | دائن | عملة | FX | Memo / أبعاد |
|---|---|---|---|---|---|---|---|
| {{ $i + 1 }} | {{ $ln->account->name ?? ('Account #' . $ln->account_id) }} | {{ $ln->account->account_number ?? '-' }} | {{ $ln->debit > 0 ? number_format((float)$ln->debit, 2) : '-' }} | {{ $ln->credit > 0 ? number_format((float)$ln->credit, 2) : '-' }} | {{ $ln->currency_code ?? $currency }} | {{ $ln->fx_rate ? number_format((float)$ln->fx_rate, 6) : '-' }} | {{ $ln->memo ?? '-' }} @if(count($dims)) @endif |
| # | كود المرتجع | التاريخ | الحالة | الإجمالي | إجراءات |
|---|---|---|---|---|---|
| {{ $i + 1 }} | {{ $r->purchase_return_code ?? ('#'.$r->id) }} | {{ $rDate }} | {{ $rChip[1] }} | {{ number_format((float)($r->total ?? 0), 2) }} | @if(Route::has('purchase_returns.show')) عرض @else - @endif |
| # | الصنف | المخزن (نص) | الكمية | سعر الوحدة | الخصم | الضريبة | إجمالي السطر |
|---|---|---|---|---|---|---|---|
| {{ $idx + 1 }} |
{{ $it->item->name ?? ('Item #' . $it->item_id) }}
|
{{ $it->warehouse_name_snapshot ?? '-' }} | {{ number_format((float)$it->quantity, 2) }} | {{ number_format((float)$it->unit_price, 2) }} | {{ $discText }} | {{ $taxText }} | {{ number_format((float)($it->line_total ?? 0), 2) }} |
| لا يوجد بنود | |||||||