@include('Partials.sidebar')
@include('Partials.header')

Transaction #{{ $txn->id }}

{{ $txn->paid_at ? $txn->paid_at->format('d M Y, h:i A') : ($txn->created_at->format('d M Y, h:i A')) }}  ·  {{ ucfirst($txn->gateway ?? 'manual') }} @if($txn->mode)  ·  {{ $txn->mode }} @endif

  1. Payments
  2. #{{ $txn->id }}
{{-- Action buttons --}} @foreach(['success','error'] as $t) @if(session($t))
{{ session($t) }}
@endif @endforeach
{{-- ── LEFT: Transaction + Invoice breakdown ── --}}
{{-- Status + Amount card --}} @php $statusColors = [ 'success' => ['border'=>'#22c55e','badge'=>'success', 'label'=>'Success' ], 'pending' => ['border'=>'#f59e0b','badge'=>'warning', 'label'=>'Pending' ], 'failed' => ['border'=>'#ef4444','badge'=>'danger', 'label'=>'Failed' ], 'refunded' => ['border'=>'#64748b','badge'=>'secondary','label'=>'Refunded'], ]; $sc = $statusColors[$txn->status] ?? $statusColors['pending']; $gwIcons = ['razorpay'=>'💳','stripe'=>'💎','phonepe'=>'📱','cash'=>'💵','manual'=>'🏦']; $gwIcon = $gwIcons[strtolower($txn->gateway ?? '')] ?? '🏦'; @endphp
Amount
{{ $currency }} {{ number_format($txn->amount, 2) }}
{{ $sc['label'] }}
{{ $gwIcon }} {{ ucfirst($txn->gateway ?? '—') }} @if($txn->mode) · {{ $txn->mode }} @endif @if($txn->currency) · {{ $txn->currency }} @endif
{{-- Invoice / Charges Breakdown --}} @if(!empty($invoice)) @php $sym = $invoice->currency_symbol ?? '₹'; $dec = (int)($invoice->currency_decimals ?? 2); $pos = $invoice->currency_symbol_position ?? 'before'; $fmt = fn($n) => $pos === 'after' ? number_format((float)$n, $dec, '.', ',') . ' ' . $sym : $sym . number_format((float)$n, $dec, '.', ','); $labels = $invoice->fee_labels ?? []; $labels = is_array($labels) ? $labels : (json_decode($labels, true) ?: []); @endphp
Charges Breakdown
{{ $invoice->typeLabel() }} · #{{ $invoice->invoice_number }}
{{-- Unit Price --}} {{-- Additional fees (only shown if > 0) --}} @if(($invoice->processing_fee ?? 0) > 0) @endif @if(($invoice->stamp_duty ?? 0) > 0) @endif @if(($invoice->registration_fee ?? 0) > 0) @endif @if(($invoice->maintenance_charge ?? 0) > 0) @endif @if(($invoice->custom_fee1 ?? 0) > 0) @endif @if(($invoice->custom_fee2 ?? 0) > 0) @endif {{-- Subtotal --}} {{-- Tax --}} @if(($invoice->tax_amount ?? 0) > 0) @else @endif {{-- Grand Total --}} {{-- Paid --}} {{-- Balance --}} @if(($invoice->balance_due ?? 0) > 0) @else @endif
Unit Price {{ $fmt($invoice->unit_price) }}
{{ $labels['processing'] ?? 'Processing Fee' }} {{ $fmt($invoice->processing_fee) }}
{{ $labels['stamp_duty'] ?? 'Stamp Duty' }} {{ $fmt($invoice->stamp_duty) }}
{{ $labels['registration'] ?? 'Registration Fee' }} {{ $fmt($invoice->registration_fee) }}
{{ $labels['maintenance'] ?? 'Maintenance' }} {{ $fmt($invoice->maintenance_charge) }}
{{ $labels['custom1'] ?? 'Custom Fee 1' }} {{ $fmt($invoice->custom_fee1) }}
{{ $labels['custom2'] ?? 'Custom Fee 2' }} {{ $fmt($invoice->custom_fee2) }}
Subtotal {{ $fmt($invoice->subtotal) }}
{{ $labels['tax'] ?? ($invoice->tax_label ?? 'Tax') }} @if(($invoice->tax_rate ?? 0) > 0) {{ $invoice->tax_rate }}% @endif @if($invoice->tax_system) {{ strtoupper($invoice->tax_system) }} @if($invoice->tax_inclusive) · Tax Inclusive @endif @endif {{ $fmt($invoice->tax_amount) }}
No tax applied
Grand Total {{ $fmt($invoice->total_amount) }}
{{ $invoice->type === 'milestone' ? 'This Payment' : 'Amount Paid' }} {{ $fmt($invoice->amount_paid) }}
Balance Due {{ $fmt($invoice->balance_due) }}
✓ Fully Paid
@else {{-- No invoice --}}
No invoice generated yet.
Invoice is created automatically when a booking is confirmed or a milestone is paid.
@endif {{-- Transaction details --}}
Transaction Details
@foreach([ ['Gateway', ucfirst($txn->gateway ?? '—')], ['Payment ID', $txn->gateway_payment_id ?? '—'], ['Order ID', $txn->gateway_order_id ?? '—'], ['Mode', ucfirst(str_replace('_',' ', $txn->mode ?? '—'))], ['Currency', $txn->currency ?? '—'], ['Paid At', $txn->paid_at ? $txn->paid_at->format('d M Y, h:i A') : '—'], ] as [$lbl, $val])
{{ $lbl }} {{ $val }}
@endforeach @if($txn->notes)
{{ $txn->notes }}
@endif
{{-- Customer --}} @if($txn->user)
Customer
{{ $txn->user->name }}
{{ $txn->user->email }}
@if($txn->user->phone)
{{ $txn->user->phone }}
@endif
@endif {{-- Booking --}} @if($txn->booking)
Booking
Unit {{ $txn->booking->plot_number }}
@if($txn->booking->plot_type)
{{ $txn->booking->plot_type }}
@endif
@php $bs = $txn->booking->booking_status ?? 'pending'; $bc = ['confirmed'=>'success','pending'=>'warning','cancelled'=>'danger'][$bs] ?? 'secondary'; @endphp {{ ucfirst($bs) }} Booking #{{ $txn->booking->id }}
@endif
{{-- ── RIGHT: Milestone schedule + Invoice preview ── --}}
{{-- Milestone schedule --}} @if(!empty($milestones) && $milestones->isNotEmpty()) @php $totalAmt = $milestones->sum('total_with_tax'); $paidAmt = $milestones->where('status','paid')->sum('total_with_tax'); $balance = $totalAmt - $paidAmt; $pct = $totalAmt > 0 ? round($paidAmt / $totalAmt * 100) : 0; @endphp
Payment Schedule
{{-- Progress bar --}}
Payment Progress {{ $pct }}% paid
Paid: {{ $currency }}{{ $paidAmt }} Balance: {{ $currency }}{{ $balance }}
{{-- Rows --}} @foreach($milestones as $i => $m) @php $isThisTxn = (int)($m->transaction_id ?? 0) === (int)$txn->id; $isOverdue = $m->status === 'pending' && $m->due_date && \Carbon\Carbon::parse($m->due_date)->isPast(); $mStatus = match(true) { $m->status === 'paid' => 'paid', $m->status === 'waived' => 'waived', $isOverdue => 'overdue', default => 'pending', }; $rowBorder = $isThisTxn ? 'border:2px solid #c9a96e;background:rgba(201,169,110,0.07)' : 'border:1px solid #e9ecef;background:#f8f9fa'; $dotColor = match($mStatus) { 'paid' => '#22c55e', 'overdue' => '#ef4444', 'waived' => '#64748b', default => '#f59e0b', }; @endphp
{{-- Circle step --}}
{{ $mStatus === 'paid' ? '✓' : ($m->sort_order ?? $i+1) }}
{{-- Content --}}
{{ $m->label }} @if($isThisTxn) ← This Payment @endif
@if($m->percentage) {{ $m->percentage }}%   @endif @if($mStatus === 'paid' && $m->paid_at) ✓ Paid {{ \Carbon\Carbon::parse($m->paid_at)->format('d M Y') }} @elseif($mStatus === 'overdue') ⚠ Overdue · Due {{ \Carbon\Carbon::parse($m->due_date)->format('d M Y') }} @elseif($m->due_date) Due {{ \Carbon\Carbon::parse($m->due_date)->format('d M Y') }} @endif
{{ $currency }}{{ $m->total_with_tax }}
{{ $mStatus }}
@endforeach
@endif {{-- Invoice iframe preview --}} @if(!empty($invoice))
Invoice Preview
@endif
@include('Partials.footer')