# Suspense Account Cleanup

## Purpose

This document describes the safe manual cleanup flow for the suspense account in LendCore. The cleanup is intended to remove stale suspense transaction rows only and must not affect loan, repayment, or guarantee deposit records.

## Scope

The cleanup operation targets only the suspense_transactions table.

It does not:
- modify loan balances
- alter repayment records
- change guarantee deposit balances
- update transaction history outside the suspense table

## Implementation

The cleanup logic is exposed through the suspense service layer in [app/Services/SuspenseService.php](../app/Services/SuspenseService.php) via the method `clearAllSuspenseTransactions()`.

The controller action in [app/Http/Controllers/Admin/SuspenseTransactionController.php](../app/Http/Controllers/Admin/SuspenseTransactionController.php) provides the backend entry point for manual execution.

## Manual usage

Run the cleanup only through a manual script or artisan command and ensure the target is the suspense table only.

Example pattern:

```php
use App\Services\SuspenseService;

$service = new SuspenseService();
$deletedCount = $service->clearAllSuspenseTransactions();

echo "Deleted {$deletedCount} suspense transaction(s).";
```

## Safety notes

- Keep the operation limited to `suspense_transactions`.
- Review the records before running cleanup in a production environment.
- Do not trigger this from the admin UI; the UI no longer exposes a delete-all button.
- If a transaction was already reassigned or applied, it should have already been handled through the normal flow and should not be relied on for other financial updates.

## Verification

A regression test exists in [tests/Unit/SuspenseServiceTest.php](../tests/Unit/SuspenseServiceTest.php) to ensure the cleanup removes suspense rows only.
