Commit b28c3485 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Add payment method column to invoices list

Shows the method (cash/card/wallet/etc) from the invoice's most recent
payment, making it easy to see how each invoice was settled at a glance.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 8a39062e
...@@ -77,7 +77,7 @@ public function render() ...@@ -77,7 +77,7 @@ public function render()
{ {
$branchId = $this->getActiveBranchId(); $branchId = $this->getActiveBranchId();
$query = Invoice::with(['billable.person']) $query = Invoice::with(['billable.person', 'payments'])
->when($branchId, fn ($q) => $q->whereHasMorph('billable', [Participant::class], fn ($pq) => $pq->where('branch_id', $branchId))) ->when($branchId, fn ($q) => $q->whereHasMorph('billable', [Participant::class], fn ($pq) => $pq->where('branch_id', $branchId)))
->when($this->search, function ($q) { ->when($this->search, function ($q) {
$search = $this->search; $search = $this->search;
......
...@@ -210,6 +210,7 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin ...@@ -210,6 +210,7 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('المدفوع') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('المدفوع') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('المتبقي') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('المتبقي') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('الحالة') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('الحالة') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('طريقة الدفع') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('تاريخ الإصدار') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('تاريخ الإصدار') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('إجراءات') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('إجراءات') }}</th>
</tr> </tr>
...@@ -266,6 +267,16 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin ...@@ -266,6 +267,16 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
{{ $invoice->status->label() }} {{ $invoice->status->label() }}
</span> </span>
</td> </td>
<td class="px-4 py-3 text-center text-gray-600">
@php
$lastPayment = $invoice->payments->sortByDesc('payment_date')->first();
@endphp
@if($lastPayment)
{{ $lastPayment->method->label() }}
@else
<span class="text-gray-400"></span>
@endif
</td>
<td class="px-4 py-3 text-center text-gray-600" dir="ltr"> <td class="px-4 py-3 text-center text-gray-600" dir="ltr">
{{ $invoice->issue_date?->format('Y-m-d') }} {{ $invoice->issue_date?->format('Y-m-d') }}
</td> </td>
...@@ -278,7 +289,7 @@ class="text-blue-600 hover:text-blue-800 text-sm">{{ __('عرض') }}</a> ...@@ -278,7 +289,7 @@ class="text-blue-600 hover:text-blue-800 text-sm">{{ __('عرض') }}</a>
</tr> </tr>
@empty @empty
<tr> <tr>
<td colspan="8" class="px-4 py-12 text-center"> <td colspan="9" class="px-4 py-12 text-center">
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<svg class="w-12 h-12 text-gray-300 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-12 h-12 text-gray-300 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment