@extends('layouts.master') @section('page_title', 'Journal Entry Details') @section('content')

Journal Entry Details

Back to List @if($journalEntry->status === 'draft') Edit Entry @endif
Entry Information
{{ ucfirst($journalEntry->status) }}

{{ $journalEntry->entry_number }}

{{ $journalEntry->entry_date?->format('M d, Y') ?? 'N/A' }}

{{ $journalEntry->reference ?? 'N/A' }}

{{ number_format($journalEntry->total_amount ?? 0, 2) }}

{{ $journalEntry->user->name ?? 'System' }}

{{ $journalEntry->created_at?->format('M d, Y H:i') ?? 'N/A' }}

@if($journalEntry->description)

{{ $journalEntry->description }}

@endif
Summary
Total Debits

{{ number_format($journalEntry->journalEntryLines->sum('debit_amount') ?? 0, 2) }}

Total Credits

{{ number_format($journalEntry->journalEntryLines->sum('credit_amount') ?? 0, 2) }}

Number of Lines

{{ $journalEntry->journalEntryLines->count() ?? 0 }}

Balance Check @php $totalDebits = $journalEntry->journalEntryLines->sum('debit_amount') ?? 0; $totalCredits = $journalEntry->journalEntryLines->sum('credit_amount') ?? 0; $isBalanced = abs($totalDebits - $totalCredits) < 0.01; @endphp

@if($isBalanced) Balanced @else Unbalanced @endif

Journal Entry Lines
@if($journalEntry->journalEntryLines && $journalEntry->journalEntryLines->count() > 0)
@foreach($journalEntry->journalEntryLines as $line) @endforeach
Account Description Debit Credit
{{ $line->account->name ?? 'N/A' }}
{{ $line->account->code ?? $line->account->account_code ?? 'N/A' }}
{{ $line->description ?? '-' }} @if($line->debit_amount > 0) {{ number_format($line->debit_amount, 2) }} @else - @endif @if($line->credit_amount > 0) {{ number_format($line->credit_amount, 2) }} @else - @endif
Totals: {{ number_format($journalEntry->journalEntryLines->sum('debit_amount') ?? 0, 2) }} {{ number_format($journalEntry->journalEntryLines->sum('credit_amount') ?? 0, 2) }}
@if(!$isBalanced)
Warning: This journal entry is not balanced. The difference is {{ number_format(abs($totalDebits - $totalCredits), 2) }}. Please review and correct the entry before posting.
@endif @else

No journal entry lines found.

@endif
@if($journalEntry->status === 'draft')
Available Actions
This entry is in draft status and can be modified.
@if($isBalanced)
@csrf @method('PATCH')
@else @endif Edit Entry
@csrf @method('DELETE')
@elseif($journalEntry->status === 'posted')
Posted Entry: This journal entry has been posted and cannot be modified. @if($journalEntry->posted_at) Posted on {{ $journalEntry->posted_at->format('M d, Y H:i') }}. @endif
@endif
@endsection @push('styles') @endpush