@extends('layouts.app')

@section('content')
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h3 mb-0">Transaction Details</h1>
    <a class="btn btn-outline-secondary" href="{{ route('reports.transactions') }}">Back</a>
</div>

<div class="card">
    <div class="card-body">
        <table class="table table-striped align-middle mb-0">
            <tbody>
                <tr><th>ID</th><td>{{ $transaction->id }}</td></tr>
                <tr><th>Date</th><td>{{ $transaction->created_at->format('Y-m-d H:i:s') }}</td></tr>
                <tr><th>Type</th><td class="text-capitalize">{{ $transaction->type }}</td></tr>
                <tr><th>Currency</th><td>{{ $transaction->currency->code }} - {{ $transaction->currency->name }}</td></tr>
                <tr><th>Account</th><td>{{ $transaction->account->name }} ({{ $transaction->account->currency->code }}, {{ ucfirst($transaction->account->type) }})</td></tr>
                <tr><th>Quantity</th><td>{{ number_format((float) $transaction->quantity, 4) }} {{ $transaction->currency->code }}</td></tr>
                <tr><th>Rate</th><td>{{ number_format((float) $transaction->rate, 4) }}</td></tr>
                <tr><th>Payment Amount</th><td>{{ number_format((float) $transaction->payment_amount, 4) }} {{ optional($transaction->paymentCurrency)->code }}</td></tr>
                <tr><th>Payment Account</th><td>{{ optional(App\Models\Account::find($transaction->payment_account_id))->name ?? 'N/A' }}</td></tr>
                <tr><th>Handling Fee</th><td>{{ number_format((float) $transaction->handling_fee, 4) }} {{ $transaction->fee_currency }}</td></tr>
                <tr><th>Exchange Profit</th><td>{{ number_format((float) $transaction->exchange_profit, 4) }}</td></tr>
                <tr><th>Total Profit</th><td>{{ number_format((float) $transaction->total_profit, 4) }}</td></tr>
            </tbody>
        </table>
    </div>
</div>
@endsection
