@extends('layouts.app') @section('title', 'Voucher #' . $voucher->id) @section('content') @php $typeConfig = [ 'RECEIPT' => ['icon' => 'fa-arrow-down', 'color' => 'success', 'label' => 'Receipt', 'ar' => 'سند قبض'], 'PAYMENT' => ['icon' => 'fa-arrow-up', 'color' => 'danger', 'label' => 'Payment', 'ar' => 'سند صرف'], 'TRANSFER' => ['icon' => 'fa-right-left', 'color' => 'info', 'label' => 'Transfer', 'ar' => 'تحويل'], ]; $tc = $typeConfig[$voucher->voucher_type] ?? ['icon' => 'fa-file', 'color' => 'secondary', 'label' => $voucher->voucher_type, 'ar' => '']; $statusBadge = ['DRAFT' => 'warning', 'POSTED' => 'success', 'CANCELLED' => 'danger']; @endphp

Voucher #{{ $voucher->id }} {{ $tc['label'] }} — {{ $tc['ar'] }} {{ $voucher->status }}

Created: {{ $voucher->created_at?->format('d M Y H:i') }}
@if($voucher->isDraft())
@csrf
@endif
{{-- Alert --}}
{{-- Left column: Voucher Details --}}
{{-- Account Flow Card --}}
Account Flow
@php [$debitCode, $creditCode] = match ($voucher->voucher_type) { 'RECEIPT' => [$voucher->treasury_account_code ?? $voucher->bank_account_code, $voucher->account_code], 'PAYMENT' => [$voucher->account_code, $voucher->treasury_account_code ?? $voucher->bank_account_code], 'TRANSFER' => [$voucher->recipient_account_code, $voucher->account_code], default => ['?', '?'] }; @endphp
DEBIT (مدين) {{ $debitCode ?? '—' }} @if($debitCode && isset($accountNames[$debitCode]))
{{ $accountNames[$debitCode]->name_ar }} / {{ $accountNames[$debitCode]->name_en }}
@endif
CREDIT (دائن) {{ $creditCode ?? '—' }} @if($creditCode && isset($accountNames[$creditCode]))
{{ $accountNames[$creditCode]->name_ar }} / {{ $accountNames[$creditCode]->name_en }}
@endif
{{-- Amount breakdown --}}
Total ${{ number_format($voucher->amount, 2) }}
Cash ${{ number_format($voucher->cash_amount, 2) }}
Bank ${{ number_format($voucher->bank_amount, 2) }}
{{-- Journal Entries --}}
Journal Entries @if($voucher->journalEntries->count()) {{ $voucher->journalEntries->count() }} lines @endif
@if($voucher->journalEntries->count())
@foreach($voucher->journalEntries as $je) @php $isParent = isset($je->payload['is_parent_propagation']) && $je->payload['is_parent_propagation']; @endphp @endforeach
Group Debit Account Credit Account Debit Credit Level
{{ substr($je->transaction_group_id, 0, 8) }}… {{ $je->debit_account_code ?? '—' }} {{ $je->credit_account_code ?? '—' }} {{ $je->debit ? number_format($je->debit, 2) : '—' }} {{ $je->credit ? number_format($je->credit, 2) : '—' }} {{ $isParent ? 'Parent' : 'Primary' }}
Total {{ number_format($voucher->journalEntries->sum('debit'), 2) }} {{ number_format($voucher->journalEntries->sum('credit'), 2) }}
@else

No journal entries yet. Post the voucher to generate them.

@if($voucher->isDraft()) @endif
@endif
{{-- Right column: Meta --}}
Voucher Info
@if($voucher->recipient_account_code) @endif @if($voucher->treasury_account_code) @endif @if($voucher->bank_account_code) @endif @if($voucher->isPosted()) @endif @if($voucher->note) @endif
ID #{{ $voucher->id }}
Type {{ $tc['label'] }}
Status {{ $voucher->status }}
Account {{ $voucher->account_code }} @if(isset($accountNames[$voucher->account_code]))
{{ $accountNames[$voucher->account_code]->name_ar }} / {{ $accountNames[$voucher->account_code]->name_en }}
@endif
Recipient {{ $voucher->recipient_account_code }} @if(isset($accountNames[$voucher->recipient_account_code]))
{{ $accountNames[$voucher->recipient_account_code]->name_ar }} / {{ $accountNames[$voucher->recipient_account_code]->name_en }}
@endif
Treasury {{ $voucher->treasury_account_code }} @if(isset($accountNames[$voucher->treasury_account_code]))
{{ $accountNames[$voucher->treasury_account_code]->name_ar }} / {{ $accountNames[$voucher->treasury_account_code]->name_en }}
@endif
Bank {{ $voucher->bank_account_code }} @if(isset($accountNames[$voucher->bank_account_code]))
{{ $accountNames[$voucher->bank_account_code]->name_ar }} / {{ $accountNames[$voucher->bank_account_code]->name_en }}
@endif
Expense Type {{ $voucher->expense_type }}
Ref. # {{ $voucher->reference_number ?? '—' }}
Entity {{ $voucher->entity_type ?? '—' }}
Created By {{ $voucher->createdBy?->name ?? '—' }}
Posted By {{ $voucher->postedBy?->name ?? '—' }}
Posted At {{ $voucher->posted_at?->format('d M Y H:i') }}
Settlement {{ $voucher->is_sttel ? '✅ Yes' : '❌ No' }}
Note {{ $voucher->note }}
{{-- Quick Account Statement link --}}
View Account Statement

View full journal history for the account in this voucher.

@php $mainAcc = \App\Models\Account::where('code', $voucher->account_code)->first(); @endphp @if($mainAcc) Statement for {{ $voucher->account_code }} @else @endif
{{-- Modern Confirmation Modal --}} @endsection