# DEPLOY: Chart of Accounts & PDF Reports

## What Was Added

### ✅ Chart of Accounts Button
**Location:** Reports Dashboard → Consolidated Financial Reports section  
**Display:** Blue featured banner at the top (before the 4 report cards)  
**Shows:** "📚 Chart of Accounts" with 4 PDF badges

### ✅ 6 PDF Reports
1. **Chart of Accounts PDF** (RED button)
2. **Trial Balance PDF** (GREEN button)
3. **Income Statement PDF** (BLUE button) - NEW!
4. **Balance Sheet PDF** (CYAN button) - NEW!
5. **Account Ledger PDF** (per account)
6. **Journal Entry PDF** (optional)

## Files Modified

### Templates:
1. `templates/reports/standalone_dashboard.html` - Added Chart of Accounts banner
2. `templates/reports/dashboard.html` - Added Chart of Accounts banner  
3. `templates/reports/financial/index.html` - Added PDF notice
4. `templates/reports/financial/chart_of_accounts.html` - Added 4 PDF buttons

### Python Files:
1. `accounting/pdf_reports.py` - Added Income Statement & Balance Sheet generators
2. `reports/financial_reports_views.py` - Added 2 new PDF export views
3. `reports/urls.py` - Added 2 new URL routes

## Deployment Steps

### Option 1: Quick Upload (Recommended)
```bash
# Upload these files to your server:
scp templates/reports/standalone_dashboard.html user@server:/path/to/grazuri/templates/reports/
scp templates/reports/dashboard.html user@server:/path/to/grazuri/templates/reports/
scp templates/reports/financial/index.html user@server:/path/to/grazuri/templates/reports/financial/
scp templates/reports/financial/chart_of_accounts.html user@server:/path/to/grazuri/templates/reports/financial/
scp accounting/pdf_reports.py user@server:/path/to/grazuri/accounting/
scp reports/financial_reports_views.py user@server:/path/to/grazuri/reports/
scp reports/urls.py user@server:/path/to/grazuri/reports/

# Restart Django
ssh user@server
cd /path/to/grazuri
sudo systemctl restart gunicorn  # or your web server
```

### Option 2: Git Push
```bash
# Commit changes
git add .
git commit -m "Add Chart of Accounts with 6 PDF reports"
git push origin main

# On server, pull changes
ssh user@server
cd /path/to/grazuri
git pull origin main
sudo systemctl restart gunicorn
```

### Option 3: cPanel File Manager
1. Login to cPanel
2. Go to File Manager
3. Navigate to public_html/grazuri (or your path)
4. Upload the modified files to their respective folders
5. Restart Python app from cPanel

## After Deployment

### ✅ Verify It Works:
1. Go to: https://grazuri.uzuriapps.xyz/reports/
2. Scroll to "Consolidated Financial Reports" section
3. You should see a **BLUE BANNER** with "Chart of Accounts" and 4 PDF badges
4. Click "View Chart of Accounts →"
5. You'll see 4 colored PDF buttons at the top:
   - 🔴 RED: Chart of Accounts PDF
   - 🟢 GREEN: Trial Balance PDF
   - 🔵 BLUE: Income Statement PDF
   - 🔷 CYAN: Balance Sheet PDF

### ✅ Test PDF Downloads:
1. Click each PDF button
2. PDFs should download with Haven Grazuri branding
3. Check that data is populated (expenses, income, accounts)

## What Users Will See

### On Dashboard:
```
┌─────────────────────────────────────────────────────────┐
│ 📊 Consolidated Financial Reports                       │
├─────────────────────────────────────────────────────────┤
│                                                          │
│ ╔══════════════════════════════════════════════════╗   │
│ ║  📊 📚 Chart of Accounts [PDF][PDF][PDF][PDF]    ║   │
│ ║  Complete overview of all general ledger...      ║   │
│ ║  📄 4 PDF Reports: Chart • Trial • Income •...   ║   │
│ ║                                                   ║   │
│ ║            [View Chart of Accounts →]            ║   │
│ ╚══════════════════════════════════════════════════╝   │
│                                                          │
│ [SasaPay]  [P&L]  [Statements]  [Loan Aging]           │
│                                                          │
└─────────────────────────────────────────────────────────┘
```

### On Chart of Accounts Page:
```
┌─────────────────────────────────────────────────────────┐
│ 📊 Chart of Accounts                                    │
│                                                          │
│ [📄 Chart PDF] [📄 Trial PDF] [📄 Income PDF] [📄 Balance PDF] [← Back]
│     RED            GREEN           BLUE            CYAN        │
│                                                          │
├─────────────────────────────────────────────────────────┤
│ 📄 Professional PDF Reports Available (4 Types)         │
│ • Chart of Accounts PDF: Complete listing              │
│ • Trial Balance PDF: Debit/credit verification         │
│ • Income Statement PDF: Revenue & expenses              │
│ • Balance Sheet PDF: Assets, Liabilities & Equity      │
├─────────────────────────────────────────────────────────┤
│ [Account List]                                          │
└─────────────────────────────────────────────────────────┘
```

## Troubleshooting

### Button Not Showing?
1. **Clear browser cache** (Ctrl+F5)
2. **Check deployment**: Ensure standalone_dashboard.html was uploaded
3. **Restart server**: Django needs restart to reload templates
4. **Check URL**: Make sure you're on /reports/ not /reports/financial/

### PDF Shows KES 0?
1. **Check database**: Production database should have expense/income data
2. **Check date range**: Income Statement uses current month by default
3. **Check accounting setup**: Run accounting migrations if needed

### 404 Error on PDF?
1. **Check urls.py**: Ensure new routes are in place
2. **Check views.py**: Ensure PDF export functions exist
3. **Restart Django**: URL changes require restart

## Files Checklist

Before deploying, verify these files are ready:

- [ ] `templates/reports/standalone_dashboard.html` - Modified
- [ ] `templates/reports/dashboard.html` - Modified
- [ ] `templates/reports/financial/index.html` - Modified  
- [ ] `templates/reports/financial/chart_of_accounts.html` - Modified
- [ ] `accounting/pdf_reports.py` - Modified (added 2 new functions)
- [ ] `reports/financial_reports_views.py` - Modified (added 2 new views)
- [ ] `reports/urls.py` - Modified (added 2 new routes)

## Summary

- ✅ Chart of Accounts button added to dashboard
- ✅ 4 PDF export buttons on Chart of Accounts page
- ✅ 6 total PDF report types
- ✅ All PDFs have Haven Grazuri branding
- ✅ No extra contact info (clean design)
- ✅ Production data will show correctly

**Status:** Ready to Deploy  
**Priority:** Deploy to production now  
**Impact:** Users can now export professional PDF reports
