# cPanel Production Deployment Instructions

## 🚀 Deploying Loan System Fixes to Production (cPanel)

### Method 1: Using cPanel File Manager

1. **Access cPanel File Manager**
   - Login to your cPanel
   - Go to "File Manager"
   - Navigate to your Django project directory

2. **Upload the Fixed Files**
   Upload these files to your production server:
   - `loans/models.py` (already fixed)
   - `loans/views.py` (already fixed) 
   - `templates/loans/loan_detail.html` (already fixed)
   - `templates/loans/rollovers.html` (already fixed)

3. **Update System Settings via Django Admin**
   - Go to your Django admin panel: `https://yourdomain.com/admin/`
   - Navigate to "System Settings"
   - Update these settings:
     - `boost_plus_processing_fee`: Change from `5.0` to `2.0`
     - Verify `boost_interest_rate` is `20.0`
     - Verify `boost_processing_fee` is `2.0`

### Method 2: Using cPanel Terminal (if available)

1. **Access cPanel Terminal**
   - In cPanel, go to "Terminal" (if available)
   - Navigate to your project directory

2. **Run Django Commands**
   ```bash
   cd /home/yourusername/public_html/yourproject
   python manage.py shell
   ```

3. **Update Settings in Django Shell**
   ```python
   from utils.models import SystemSetting
   
   # Update Boost Plus processing fee to 2%
   setting, created = SystemSetting.objects.update_or_create(
       key='boost_plus_processing_fee',
       defaults={
           'value': '2.0',
           'category': 'loan',
           'description': 'Processing fee for Boost Plus loans (%) - one-time only',
           'is_public': True
       }
   )
   print('Updated boost_plus_processing_fee to 2.0%')
   
   # Verify settings
   print('boost_interest_rate:', SystemSetting.get_float('boost_interest_rate', 0))
   print('boost_processing_fee:', SystemSetting.get_float('boost_processing_fee', 0))
   print('boost_plus_interest_rate:', SystemSetting.get_float('boost_plus_interest_rate', 0))
   print('boost_plus_processing_fee:', SystemSetting.get_float('boost_plus_processing_fee', 0))
   
   exit()
   ```

4. **Run Migrations (if needed)**
   ```bash
   python manage.py migrate
   ```

### Method 3: Using cPanel Python App (if using Python app)

1. **Access Python App**
   - In cPanel, go to "Python App"
   - Select your Django app

2. **Update Settings**
   - Use the same Django shell commands as Method 2

### Method 4: Direct Database Update (Advanced)

If you have database access:

1. **Access phpMyAdmin**
   - In cPanel, go to "phpMyAdmin"
   - Select your database

2. **Update System Settings Table**
   ```sql
   UPDATE utils_systemsetting 
   SET value = '2.0' 
   WHERE key = 'boost_plus_processing_fee';
   ```

### Method 5: Using SSH (if available)

1. **SSH into your server**
   ```bash
   ssh yourusername@yourdomain.com
   ```

2. **Navigate to project and run commands**
   ```bash
   cd /home/yourusername/public_html/yourproject
   python manage.py shell -c "
   from utils.models import SystemSetting
   setting, created = SystemSetting.objects.update_or_create(
       key='boost_plus_processing_fee',
       defaults={'value': '2.0', 'category': 'loan', 'description': 'Processing fee for Boost Plus loans (%) - one-time only', 'is_public': True}
   )
   print('Updated boost_plus_processing_fee to 2.0%')
   "
   ```

## ✅ Verification Steps

After deployment, verify the fixes:

1. **Check Loan Detail Page**
   - Go to any Boost Plus loan detail page
   - Verify it shows:
     - Interest Rate: 20.0%
     - Processing Fee: 2.0%

2. **Check New Loan Application**
   - Create a new loan application
   - Verify the loan summary shows correct rates

3. **Check Settings Page**
   - Go to `/utils/settings/`
   - Verify all rates are correct

## 🔧 Files That Were Fixed

1. **`loans/models.py`**
   - Fixed processing fee calculation to be one-time only
   - Added disbursement date support for rollovers

2. **`loans/views.py`**
   - Fixed fallback data to use system settings
   - Added disbursement date handling for rollovers

3. **`templates/loans/loan_detail.html`**
   - Fixed to use `get_interest_rate()` instead of hardcoded `interest_rate`

4. **`templates/loans/rollovers.html`**
   - Added disbursement date field to rollover approval

## 🎯 What Gets Fixed

- ✅ Interest rates show 20% instead of 15%
- ✅ Processing fees show 2% instead of 5%
- ✅ Processing fees are charged once, not monthly
- ✅ Disbursement dates work correctly
- ✅ Rollover disbursement dates work correctly

## 🚨 Important Notes

- **No migrations needed** - these are code changes only
- **Settings update required** - Boost Plus processing fee needs to be changed to 2.0%
- **Test thoroughly** - Verify all loan types show correct rates
- **Backup first** - Always backup before making changes

## 📞 Support

If you encounter any issues:
1. Check Django error logs in cPanel
2. Verify file permissions
3. Clear any caches if applicable
4. Test with a new loan application first
