# Manual Payment Matching - Updated to Match Specific Loans

## Changes Made

The manual payment matching feature has been updated to allow admins to match payments to specific loans instead of just borrowers.

### What Changed

1. **Template Updates** (`templates/payments/callbacks.html`):
   - Changed modal title from "Match Payment to Borrower" to "Match Payment to Loan"
   - Updated button text from "Match Payer" to "Match to Loan"
   - Replaced borrower dropdown with loan dropdown showing:
     - Loan number
     - Borrower name and ID
     - Outstanding amount
     - Due date
   - Updated search functionality to filter loans instead of borrowers
   - Updated help text to reflect loan selection

2. **View Updates** (`payments/views.py`):
   - **callbacks view**: Now passes `active_loans` instead of `borrowers` to template
     - Fetches all active loans ordered by due date
     - Includes borrower and loan product details via select_related
   
   - **manual_match_payment view**: Now accepts `loan_id` instead of `borrower_id`
     - Validates the selected loan exists and is active
     - Sets both `transaction.loan` and `transaction.borrower` from the selected loan
     - Updates success messages to reference loan number

### Benefits

- **More Precise**: Admins can now match payments to the exact loan they're intended for
- **Better Context**: The dropdown shows outstanding amounts and due dates to help admins make informed decisions
- **Prevents Errors**: When a borrower has multiple active loans, the admin can choose the correct one
- **Improved UX**: Search functionality allows filtering by loan number, borrower name, or ID number

### User Experience

When an admin clicks "Match to Loan":
1. A modal appears showing the payment details (amount, phone, bill ref, time)
2. A searchable dropdown lists all active loans with:
   - Loan number
   - Borrower name and ID
   - Outstanding amount
   - Due date
3. Admin selects the specific loan to match
4. System links the payment to that loan and attempts to process it automatically
5. Success message shows the loan number and receipt number if successful
