@extends('layouts.app')
@section('title',$voucher->voucher_number)
@section('page_title','Manual Journal Voucher')
@section('content')
@php($s=$voucher->status instanceof \App\Enums\DocumentStatus?$voucher->status->value:$voucher->status)
<div class="page-head"><div><h1>{{ $voucher->voucher_number }}</h1><p>{{ $voucher->description }} · <span class="badge status-{{ $s }}">{{ ucwords(str_replace('_',' ',$s)) }}</span></p></div><div class="actions"><a class="btn btn-secondary" href="{{ route('journals.index') }}">Back</a>@if(in_array($s,['draft','rejected']))<a class="btn btn-primary" href="{{ route('journals.vouchers.edit',$voucher) }}">Edit</a>@endif</div></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">{{ $voucher->posting_date->format('d M Y') }}</div></div><div class="detail"><div class="detail-label">Reference</div><div class="detail-value">{{ $voucher->reference_number ?: '—' }}</div></div><div class="detail"><div class="detail-label">Branch</div><div class="detail-value">{{ $voucher->branch?->name }}</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($voucher->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<tr><th colspan="3">Total</th><th>{{ number_format((float)$voucher->debit_total,2) }}</th><th>{{ number_format((float)$voucher->credit_total,2) }}</th></tr></tbody></table></div></div>
@include('components.workflow-actions',['document'=>$voucher,'routePrefix'=>'journals.vouchers','permissionPrefix'=>'journals','status'=>$s,'postLabel'=>'Post Journal'])
@endsection
