@extends('layouts.app')
@section('title',$journal->journal_number)
@section('page_title','Journal Entry')
@section('content')
<div class="page-head"><div><h1>{{ $journal->journal_number }}</h1><p>{{ $journal->description }}</p></div><a class="btn btn-secondary" href="{{ route('journals.index') }}">Back</a></div>
<div class="card"><div class="card-body"><div class="detail-grid"><div class="detail"><div class="detail-label">Posting Date</div><div class="detail-value">{{ $journal->posting_date->format('d M Y') }}</div></div><div class="detail"><div class="detail-label">Source</div><div class="detail-value">{{ ucwords(str_replace('_',' ',$journal->source_module)) }}</div></div><div class="detail"><div class="detail-label">Reference</div><div class="detail-value">{{ $journal->reference_number }}</div></div><div class="detail"><div class="detail-label">Period</div><div class="detail-value">{{ $journal->period?->name }}</div></div><div class="detail"><div class="detail-label">Debit Total</div><div class="detail-value">AED {{ number_format((float)$journal->debit_total,2) }}</div></div><div class="detail"><div class="detail-label">Credit Total</div><div class="detail-value">AED {{ number_format((float)$journal->credit_total,2) }}</div></div></div></div><div class="table-wrap"><table class="table"><thead><tr><th>Account</th><th>Party / Ledger</th><th>Description</th><th>Debit</th><th>Credit</th></tr></thead><tbody>@foreach($journal->lines as $l)<tr><td>{{ $l->account?->code }} - {{ $l->account?->name }}</td><td>{{ $l->party?->legal_name }} {{ $l->party_ledger }}</td><td>{{ $l->description }}</td><td>{{ number_format((float)$l->debit,2) }}</td><td>{{ number_format((float)$l->credit,2) }}</td></tr>@endforeach</tbody></table></div></div>
@if(!$journal->reversal_of_id && !$reversal && auth()->user()->hasPermission('journals.reverse'))<div class="card" style="margin-top:18px"><div class="card-head"><strong>Reverse Journal</strong></div><div class="card-body"><form class="form-grid" method="post" action="{{ route('journals.reverse',$journal) }}">@csrf<div class="field"><label>Reversal Date</label><input class="control" type="date" name="reversal_date" value="{{ date('Y-m-d') }}" required></div><div class="field"><label>Reason</label><input class="control" name="reason" required></div><button class="btn btn-danger" data-confirm="Create a complete reversing journal?">Post Reversal</button></form></div></div>@elseif($reversal)<div class="alert alert-warning" style="margin-top:18px">Reversed by <a href="{{ route('journals.show',$reversal) }}">{{ $reversal->journal_number }}</a>.</div>@elseif($journal->reversalOf)<div class="alert alert-warning" style="margin-top:18px">This is a reversal of <a href="{{ route('journals.show',$journal->reversalOf) }}">{{ $journal->reversalOf->journal_number }}</a>.</div>@endif
@endsection
