@extends('layout.master') @section('title', 'Expense Transaction Report') @section('content') @php // har transaction ka PKR Equivalent nikalo: // - PKR entry: amount khud hi PKR hai (rate hamesha 1) // - USD entry: amount * uska apna stored exchange_rate $transactions = $transactions->map(function ($txn) { $txn->pkr_equivalent = $txn->currency === 'USD' ? $txn->amount * ($txn->exchange_rate ?: 0) : $txn->amount; return $txn; }); $grandTotalPkr = $transactions->sum('pkr_equivalent'); $totalPkrEntries = $transactions->where('currency', 'PKR')->sum('amount'); $totalUsdEntries = $transactions->where('currency', 'USD')->sum('amount'); $selfCount = $transactions->whereNull('supplier_id')->count(); $supplierCount = $transactions->whereNotNull('supplier_id')->count(); @endphp
{{-- Print-only header --}} {{-- Page header --}}

Expense Transaction Report

@if (!empty($filters['currency'])) {{ $filters['currency'] }} @else PKR USD @endif @if (!empty($filters['expense_for'])) {{ ucfirst($filters['expense_for']) }} @endif @if (!empty($filters['from_date']) || !empty($filters['to_date']))  •  {{ !empty($filters['from_date']) ? \Carbon\Carbon::parse($filters['from_date'])->format('d M Y') : 'Start' }}  →  {{ !empty($filters['to_date']) ? \Carbon\Carbon::parse($filters['to_date'])->format('d M Y') : 'End' }} @endif

Change Filter
{{-- Summary cards --}}
Transactions
{{ $transactions->count() }}
Grand Total (PKR)
{{ number_format($grandTotalPkr, 2) }}
Self Entries
{{ $selfCount }}
Supplier Entries
{{ $supplierCount }}
{{-- Table --}}
@if ($transactions->isEmpty())

No transactions found for the selected filters.

Try Different Filters
@else
@foreach ($transactions as $i => $txn) @php $curBadge = $txn->currency === 'USD' ? 'et-badge-usd' : 'et-badge-pkr'; $isSupplier = !is_null($txn->supplier_id); @endphp @endforeach
# Date Expense Category Expense For Currency Reference No. Narration Amount PKR Equivalent
{{ $i + 1 }} {{ \Carbon\Carbon::parse($txn->date)->format('d M Y') }} {{ $txn->expense->name ?? '—' }} @if ($isSupplier) {{ $txn->supplier->name ?? 'Supplier' }} @else Self @endif {{ $txn->currency }} {{ $txn->reference_no ?: '—' }} {{ $txn->description ?: '—' }} {{ number_format($txn->amount, 2) }} {{ $txn->currency }} @if ($txn->currency === 'USD')
Rate: {{ number_format($txn->exchange_rate, 2) }}
@endif
{{ number_format($txn->pkr_equivalent, 2) }}
Grand Total (PKR Equivalent) {{ number_format($grandTotalPkr, 2) }}
@endif
@endsection