@extends('layouts.app')
@section('title',$expense->expense_number)
@section('page_title','Expense Voucher')
@section('content')
@php($s=$expense->status instanceof \App\Enums\DocumentStatus?$expense->status->value:$expense->status)
<div class="page-head"><div><h1>{{ $expense->expense_number }}</h1><p>{{ $expense->description }} · <span class="badge status-{{ $s }}">{{ ucwords(str_replace('_',' ',$s)) }}</span></p></div><div class="actions"><a class="btn btn-secondary" href="{{ route('expenses.index') }}">Back</a><a class="btn btn-secondary" target="_blank" href="{{ route('expenses.print',$expense) }}">Print</a><a class="btn btn-secondary" href="{{ route('expenses.pdf',$expense) }}">PDF</a>@if(in_array($s,['draft','rejected']))<a class="btn btn-primary" href="{{ route('expenses.edit',$expense) }}">Edit</a>@endif</div></div>
<div class="grid grid-4"><div class="card metric"><div class="metric-label">Before VAT</div><div class="metric-value">AED {{ number_format((float)$expense->amount_before_vat,2) }}</div></div><div class="card metric"><div class="metric-label">Recoverable VAT</div><div class="metric-value">AED {{ number_format((float)$expense->recoverable_vat,2) }}</div></div><div class="card metric"><div class="metric-label">Non-Recoverable VAT</div><div class="metric-value">AED {{ number_format((float)$expense->nonrecoverable_vat,2) }}</div></div><div class="card metric"><div class="metric-label">Total</div><div class="metric-value">AED {{ number_format((float)$expense->total_amount,2) }}</div></div></div>
<div class="card" style="margin-top:18px"><div class="detail-grid" style="border:0"><div class="detail"><div class="detail-label">Date</div><div class="detail-value">{{ $expense->expense_date->format('d M Y') }}</div></div><div class="detail"><div class="detail-label">Category</div><div class="detail-value">{{ $expense->category }}</div></div><div class="detail"><div class="detail-label">Payee</div><div class="detail-value">{{ $expense->party?->legal_name ?? 'Direct expense' }}</div></div><div class="detail"><div class="detail-label">Expense Account</div><div class="detail-value">{{ $expense->expenseAccount?->code }} - {{ $expense->expenseAccount?->name }}</div></div><div class="detail"><div class="detail-label">Payment Account</div><div class="detail-value">{{ $expense->paymentAccount?->code }} - {{ $expense->paymentAccount?->name }}</div></div><div class="detail"><div class="detail-label">Linked Job / Trip</div><div class="detail-value">{{ $expense->transportJob?->job_number ?? '—' }} / {{ $expense->trip?->trip_number ?? '—' }}</div></div></div></div>
@include('components.workflow-actions',['document'=>$expense,'routePrefix'=>'expenses','permissionPrefix'=>'expenses','status'=>$s,'postLabel'=>'Post Expense'])
@endsection
