@extends('layouts.app') @section('content')

Edit General Expense

@if($general_expense->status == 'Pending') Pending @elseif($general_expense->status == 'Approved') Approved @else {{ $general_expense->status }} @endif
@if ($errors->any()) @endif
@csrf @method('PUT')
UGX
Amount with automatic comma formatting
Provide additional details about this expense
This will be saved in the audit trail
Expense Information
Created By:

{{ $general_expense->user->name ?? 'N/A' }}

Created At:

{{ $general_expense->created_at->format('d-M-Y H:i:s') }}

Last Updated:

{{ $general_expense->updated_at->format('d-M-Y H:i:s') }}

@if($general_expense->status == 'Pending') @endif
Cancel
@if(isset($audits) && $audits->count() > 0)
Audit Trail {{ $audits->count() }}
@foreach($audits as $audit) @endforeach
Date/Time User Action Changes Remarks
{{ $audit->created_at->format('d-M-Y') }}
{{ $audit->created_at->format('H:i:s') }}
{{ $audit->user->name ?? 'System' }} @php $badgeClass = 'secondary'; $icon = 'circle'; switch($audit->action) { case 'created': $badgeClass = 'success'; $icon = 'plus-circle'; break; case 'updated': $badgeClass = 'info'; $icon = 'edit'; break; case 'deleted': $badgeClass = 'danger'; $icon = 'trash-alt'; break; case 'approved': $badgeClass = 'primary'; $icon = 'check-circle'; break; } @endphp {{ ucfirst($audit->action) }} @if($audit->action == 'updated' && $audit->old_values && $audit->new_values) @php $changes = []; foreach($audit->new_values as $key => $newValue) { $oldValue = $audit->old_values[$key] ?? null; if($oldValue != $newValue) { $changes[$key] = ['old' => $oldValue, 'new' => $newValue]; } } @endphp @foreach($changes as $field => $change)
{{ ucfirst(str_replace('_', ' ', $field)) }}:
@if(in_array($field, ['amount', 'paid_amount', 'balance'])) UGX {{ number_format($change['old'], 2) }} @elseif($field == 'supplier_id') @php $oldSupplier = \App\Models\Supplier::find($change['old']); @endphp {{ $oldSupplier ? $oldSupplier->name : 'Supplier ID: ' . $change['old'] }} @elseif($field == 'expense_item_id') @php $oldItem = \App\Models\ExpenseItem::find($change['old']); @endphp {{ $oldItem ? $oldItem->name : 'Item ID: ' . $change['old'] }} @elseif($field == 'payment_method_id') @php $oldMethod = \App\Models\PaymentMethod::find($change['old']); @endphp {{ $oldMethod ? $oldMethod->name : 'Method ID: ' . $change['old'] }} @else {{ $change['old'] }} @endif @if(in_array($field, ['amount', 'paid_amount', 'balance'])) UGX {{ number_format($change['new'], 2) }} @elseif($field == 'supplier_id') @php $newSupplier = \App\Models\Supplier::find($change['new']); @endphp {{ $newSupplier ? $newSupplier->name : 'Supplier ID: ' . $change['new'] }} @elseif($field == 'expense_item_id') @php $newItem = \App\Models\ExpenseItem::find($change['new']); @endphp {{ $newItem ? $newItem->name : 'Item ID: ' . $change['new'] }} @elseif($field == 'payment_method_id') @php $newMethod = \App\Models\PaymentMethod::find($change['new']); @endphp {{ $newMethod ? $newMethod->name : 'Method ID: ' . $change['new'] }} @else {{ $change['new'] }} @endif
@endforeach
@elseif($audit->action == 'created' && $audit->new_values) Initial amount: UGX {{ number_format($audit->new_values['amount'] ?? 0, 2) }} @elseif($audit->action == 'deleted' && $audit->old_values) Deleted amount: UGX {{ number_format($audit->old_values['amount'] ?? 0, 2) }} @else No changes recorded @endif
{{ $audit->remarks ?? '-' }} @if($audit->ip_address)
{{ $audit->ip_address }} @endif
@endif
@endsection @section('customcss') @endsection @section('customjs') @endsection