# Expense Categories Update

## Changes Made

Updated the expense category dropdown at `/expenses/add/` to only show 4 categories:

1. **Salary**
2. **Office Rent**
3. **Bank and M-Pesa Charges**
4. **Other Expenses**

## Files Modified

### 1. `expenses/models.py`
- Changed `CATEGORY_CHOICES` from 9 options to 4 options
- Updated default category from `'operational'` to `'salary'`

**Old Categories:**
- operational
- staff
- marketing
- loan_related
- utilities
- office
- transport
- maintenance
- other

**New Categories:**
- salary
- office_rent
- bank_mpesa_charges
- other

## Migration Required

A data migration script has been created: `update_expense_categories.py`

This script will:
1. Map existing expense categories to the new simplified categories
2. Update all existing expense records

**Category Mapping:**
```
operational       → other
staff            → salary
marketing        → other
loan_related     → other
utilities        → other
office           → office_rent
transport        → other
maintenance      → other
other            → other
```

## Deployment Steps

1. **Update the model** (already done in `expenses/models.py`)

2. **Run the migration script locally first:**
   ```bash
   python update_expense_categories.py
   ```

3. **Deploy to production:**
   ```bash
   # Upload modified file
   scp expenses/models.py production:/path/to/grazuri/expenses/

   # Upload migration script
   scp update_expense_categories.py production:/path/to/grazuri/

   # SSH into production
   ssh production

   # Run migration
   cd /path/to/grazuri
   python update_expense_categories.py

   # Restart application
   sudo systemctl restart grazuri
   ```

## Testing

After deployment, verify:
1. Go to `/expenses/add/`
2. Check that the Category dropdown only shows 4 options:
   - Salary
   - Office Rent
   - Bank and M-Pesa Charges
   - Other Expenses
3. Create a test expense and confirm it saves correctly
4. Check existing expenses still display properly with their mapped categories

## Notes

- The form will automatically use the new categories since it reads from `Expense.CATEGORY_CHOICES`
- No template changes needed - all category displays use the model's `get_category_display()` method
- Existing expenses will show their mapped category after running the migration script
