# Rollover Interest Change - Quick Summary

## What Changed?
The rollover request form's "Custom Interest Rate (%)" field now accepts **actual amounts in KES** instead of percentages.

### Before
- Field: "Custom Interest Rate (%)"
- Input: `8.5` (meaning 8.5%)
- Calculation: For KES 100,000 over 2 months = `100,000 × 8.5 / 100 × 2 = KES 17,000`

### After  
- Field: "Custom Interest Amount (KES)"
- Input: `17000` (meaning KES 17,000)
- Calculation: Direct amount = KES 17,000

## Files Modified

### 1. Database
- **Migration**: `loans/migrations/0031_change_interest_to_amount.py`
- **Field change**: `requested_interest_rate` from DECIMAL(5,2) to DECIMAL(12,2)

### 2. Python Files
- `loans/models.py` - Updated RolloverRequest model and approve() method
- `loans/views.py` - Updated request_rollover() validation

### 3. Templates
- `templates/loans/loan_detail.html` - Updated form field
- `templates/loans/loans.html` - Updated form field  
- `templates/loans/rollovers.html` - Updated display format

## Deployment

### Option 1: Automated Script (Recommended)
```bash
# On production server
cd ~/public_html
python deploy_to_production.py
```

### Option 2: Manual Steps
```bash
# 1. Backup database
mysqldump -u xygbfpsg_graz -p'j.ez-xy6##y.rllB' xygbfpsg_loans loans_rolloverrequest > backup.sql

# 2. Run migration
python manage.py migrate loans 0031

# 3. Restart Django
touch tmp/restart.txt
```

## Testing After Deployment

1. **Create rollover request**:
   - Go to any active loan → "Request Rollover"
   - Enter custom interest as amount (e.g., `5000` for KES 5,000)
   - Submit

2. **View rollover list**:
   - Go to Loans → Rollovers
   - Verify custom interest shows as "KES 5,000.00" (not "5000%")

3. **Approve rollover**:
   - Approve a rollover with custom interest
   - Verify new loan has correct interest amount

## Important Notes

⚠️ **Breaking Change**: Old pending rollovers with percentage values will be interpreted as amounts!
- Example: `10` (meant 10%) will become KES 10
- **Action**: Review/reject old pending rollovers before deployment

✅ **No impact on**:
- Existing approved/rejected rollovers
- Loans without custom interest (using product defaults)
- Processing fees (still work the same way)

## Support

If issues arise after deployment:

1. **Check logs**: Django error logs for stack traces
2. **Verify schema**: `DESCRIBE loans_rolloverrequest;` - should show DECIMAL(12,2)
3. **Rollback**: Restore from backup and revert migration to 0030

## File Checklist for Upload

Upload these files to production:
- [ ] `loans/models.py`
- [ ] `loans/views.py`
- [ ] `loans/migrations/0031_change_interest_to_amount.py`
- [ ] `templates/loans/loan_detail.html`
- [ ] `templates/loans/loans.html`
- [ ] `templates/loans/rollovers.html`
- [ ] `deploy_to_production.py` (deployment script)
