@php $currencySymbols = [ 'USD' => '$', 'EUR' => '€', 'GBP' => '£', 'OMR' => 'ر.ع.', 'AED' => 'د.إ', 'SAR' => 'ر.س', 'PKR' => '₨', 'INR' => '₹' ]; $type = $transaction->transaction_type; $typeLabel = strtoupper(str_replace('_', ' ', $type)); // Determine badge class $badgeClass = 'transfer'; if ($type == 'income') $badgeClass = 'income'; elseif ($type == 'expense') $badgeClass = 'expense'; elseif ($type == 'credit_card_payment') $badgeClass = 'liability'; // Get logo - using data URI for base64 logo (works without GD if we text encode) $logoPath = public_path('images/logo.png'); $logoBase64 = ''; if (file_exists($logoPath)) { $logoData = file_get_contents($logoPath); $logoBase64 = 'data:image/png;base64,' . base64_encode($logoData); } // Find related transfer transaction $relatedTransaction = null; $sourceAccount = null; // Account sending money (FROM) $destinationAccount = null; // Account receiving money (TO) $sourceAmount = $transaction->amount; $destinationAmount = $transaction->amount; $sourceCurrency = $transaction->currency ?? 'USD'; $destinationCurrency = $transaction->currency ?? 'USD'; $sourceSymbol = $currencySymbols[$sourceCurrency] ?? $sourceCurrency; $destinationSymbol = $currencySymbols[$destinationCurrency] ?? $destinationCurrency; if ($type == 'transfer') { $relatedTransaction = \App\Models\Transaction::where('tenant_id', $transaction->tenant_id) ->where('user_id', $transaction->user_id) ->where('transaction_type', 'transfer') ->where('id', '!=', $transaction->id) ->where(function($q) use ($transaction) { $q->where('financial_account_id', $transaction->related_financial_account_id) ->where('related_financial_account_id', $transaction->financial_account_id); }) ->first(); // The transaction with "Transfer to" in description is the SOURCE (FROM account) // The transaction with "Transfer from" in description is the DESTINATION (TO account) if (str_contains($transaction->description ?? '', 'Transfer to')) { // This transaction is the source (money leaving) $sourceAccount = $transaction->financialAccount; $destinationAccount = $relatedTransaction ? $relatedTransaction->financialAccount : null; $sourceAmount = $transaction->amount; $destinationAmount = $relatedTransaction ? $relatedTransaction->amount : $transaction->amount; } elseif (str_contains($transaction->description ?? '', 'Transfer from')) { // This transaction is the destination (money receiving) $sourceAccount = $relatedTransaction ? $relatedTransaction->financialAccount : null; $destinationAccount = $transaction->financialAccount; $sourceAmount = $relatedTransaction ? $relatedTransaction->amount : $transaction->amount; $destinationAmount = $transaction->amount; } else { // Fallback: assume current transaction is source $sourceAccount = $transaction->financialAccount; $destinationAccount = $relatedTransaction ? $relatedTransaction->financialAccount : null; $sourceAmount = $transaction->amount; $destinationAmount = $relatedTransaction ? $relatedTransaction->amount : $transaction->amount; } if ($sourceAccount) { $sourceCurrency = $sourceAccount->currency ?? 'USD'; $sourceSymbol = $currencySymbols[$sourceCurrency] ?? $sourceCurrency; } if ($destinationAccount) { $destinationCurrency = $destinationAccount->currency ?? 'USD'; $destinationSymbol = $currencySymbols[$destinationCurrency] ?? $destinationCurrency; } } $displayAmount = $transaction->amount; $displayCurrency = $transaction->currency ?? $user->base_currency ?? 'USD'; $displaySymbol = $currencySymbols[$displayCurrency] ?? $displayCurrency; // Color based on type $amountColor = '#2d6a4f'; if ($type == 'expense') $amountColor = '#c52929'; elseif ($type == 'credit_card_payment') $amountColor = '#c97e0a'; elseif ($type == 'transfer') $amountColor = '#4a3db5'; $amountBg = '#f0fdf4'; if ($type == 'expense') $amountBg = '#fef2f2'; elseif ($type == 'credit_card_payment') $amountBg = '#fffbeb'; elseif ($type == 'transfer') $amountBg = '#f5f3ff'; @endphp
Logo

Transaction Receipt

Official Financial Document

#TX-{{ str_pad($transaction->id, 8, '0', STR_PAD_LEFT) }}
{{ $typeLabel }}
DATE
{{ $transaction->transaction_date->format('F d, Y') }}
CATEGORY
{{ $transaction->category?->name ?? ($type == 'transfer' ? 'Transfer' : '—') }}
@if($type == 'transfer')
FROM ACCOUNT
{{ $sourceAccount->account_name ?? 'N/A' }}
Amount Sent: {{ $sourceSymbol }} {{ number_format($sourceAmount, 2) }} ({{ $sourceCurrency }})
TO ACCOUNT
{{ $destinationAccount->account_name ?? 'N/A' }}
Amount Received: {{ $destinationSymbol }} {{ number_format($destinationAmount, 2) }} ({{ $destinationCurrency }})
@if($sourceCurrency != $destinationCurrency && $transaction->exchange_rate)
EXCHANGE RATE
1 {{ $sourceCurrency }} = {{ number_format($transaction->exchange_rate, 4) }} {{ $destinationCurrency }}
Converted: {{ $sourceSymbol }} {{ number_format($sourceAmount, 2) }} → {{ $destinationSymbol }} {{ number_format($destinationAmount, 2) }}
@endif @else
ACCOUNT
{{ $transaction->financialAccount->account_name ?? 'N/A' }}
@endif
PROCESSED BY
{{ $user->full_name ?? $user->name ?? 'System' }}
@if($transaction->description)
DESCRIPTION / NOTES
{{ $transaction->description }}
@endif
TRANSACTION AMOUNT
{{ $displaySymbol }} {{ number_format($displayAmount, 2) }} {{ $displayCurrency }}