===============================================================================
EXPENSES FIX - QUICK DEPLOYMENT STEPS
===============================================================================

PROBLEM 1: DataError - Incorrect integer value for column 'id'
PROBLEM 2: Branch dropdown only showing "main branch"

===============================================================================
QUICK FIX STEPS:
===============================================================================

1. OPEN PHPMYADMIN:
   - Login to cPanel
   - Click phpMyAdmin
   - Select database: acbptxvs_branch_system (IMPORTANT!)

2. BACKUP DATABASE (Click SQL tab, run these ONE AT A TIME):
   DROP TABLE IF EXISTS expenses_backup;
   CREATE TABLE expenses_backup AS SELECT * FROM expenses;
   SELECT COUNT(*) FROM expenses_backup;

3. FIX DATABASE (Run these ONE AT A TIME):
   TRUNCATE TABLE expenses;
   ALTER TABLE expenses MODIFY COLUMN id bigint NOT NULL AUTO_INCREMENT;
   DESCRIBE expenses;

4. UPLOAD FILES (via cPanel File Manager or FTP):
   - expenses/models.py
   - expenses/forms.py
   - expenses/views.py

5. RESTART APP (in cPanel > Setup Python App):
   Click "Restart" button

6. TEST:
   - Go to Expenses > Add Expense
   - Check branch dropdown shows all branches
   - Create an expense successfully

===============================================================================
FILES TO UPLOAD:
===============================================================================
✓ expenses/models.py       (Changed: id field from UUID to BigAutoField)
✓ expenses/forms.py        (Changed: Added branch filtering logic)
✓ expenses/views.py        (Changed: Pass user to filter form)

===============================================================================
SQL TO RUN (in phpMyAdmin SQL tab, ONE QUERY AT A TIME):
===============================================================================

-- Step 1: Check current state
DESCRIBE expenses;

-- Step 2: Backup (run these separately)
DROP TABLE IF EXISTS expenses_backup;
CREATE TABLE expenses_backup AS SELECT * FROM expenses;
SELECT COUNT(*) FROM expenses_backup;

-- Step 3: Fix (run these separately)
TRUNCATE TABLE expenses;
ALTER TABLE expenses MODIFY COLUMN id bigint NOT NULL AUTO_INCREMENT;

-- Step 4: Verify
DESCRIBE expenses;

===============================================================================
IMPORTANT NOTES:
===============================================================================
- Make sure you select database "acbptxvs_branch_system" first!
- Run each SQL query ONE AT A TIME
- Check for errors after each query
- The backup table will keep your old data
- See PHPMYADMIN_STEPS.md for detailed instructions

===============================================================================
DONE!
===============================================================================
