@extends('layout.app') @section('content')
{{-- Left: Input Form --}}
Security Amount Entry
@csrf

Manager: {{ $reseller->name }}

Current Security Amount: {{ number_format($reseller->security_amount ?? 0, 2) }}

@if ($hasMismatch) @php $correctionAmount = number_format(abs(($reseller->security_amount ?? 0) - $logCalculatedAmount), 2); $correctionType = ($reseller->security_amount ?? 0) >= $logCalculatedAmount ? 'Collect' : 'Refund'; $actualFormatted = number_format($reseller->security_amount ?? 0, 2); $fixMsg = "A corrective {$correctionType} entry of {$correctionAmount} will be added to sync the log. History is preserved. Continue?"; $resetMsg = "WARNING: This will DELETE all log history and create a fresh entry for the current amount ({$actualFormatted}). This cannot be undone. Continue?"; @endphp
Log mismatch! Log net: {{ number_format($logCalculatedAmount, 2) }}  →  Actual: {{ $actualFormatted }}
@csrf
@csrf
@endif
@error('type')
{{ $message }}
@enderror
@error('amount')
{{ $message }}
@enderror
@error('remarks')
{{ $message }}
@enderror
Back
{{-- Right: History --}}
Security Amount History (Last 20)
@forelse ($logs as $i => $log) @empty @endforelse @if ($logs->isNotEmpty()) @endif
# Date Type Amount Balance After Remarks By
{{ $i + 1 }} {{ date('d-M-Y h:i A', strtotime($log->created_at)) }} @if ($log->type === 'collect') Collect @else Refund @endif {{ number_format($log->amount, 2) }} {{ number_format($log->current_security_amount, 2) }} {{ $log->remarks }} {{ $log->user->name ?? '—' }}
No transactions found.
Total Collected: {{ number_format($logs->where('type', 'collect')->sum('amount'), 2) }}
Total Refunded: {{ number_format($logs->where('type', 'refund')->sum('amount'), 2) }}
Current Security Amount: {{ number_format($reseller->security_amount ?? 0, 2) }}
@endsection