# Manual Deployment Guide for Windows (Chart of Accounts)

## Problem
The Chart of Accounts button is not showing on production dashboard at https://grazuri.uzuriapps.xyz/reports/

## Root Cause
The updated template files have not been deployed to the production server yet.

## Solution: Deploy Using cPanel File Manager

### Step 1: Access cPanel File Manager
1. Login to your cPanel at https://grazuri.uzuriapps.xyz:2083
2. Click on "File Manager"
3. Navigate to `/home/xygbfpsg/public_html/grazuri/`

---

### Step 2: Upload Template Files

#### 📁 templates/reports/standalone_dashboard.html
**Local Path:** `c:\Users\BEST\Desktop\grazuri\templates\reports\standalone_dashboard.html`

1. In cPanel File Manager, navigate to: `public_html/grazuri/templates/reports/`
2. Click "Upload" button
3. Select `standalone_dashboard.html` from your local folder
4. Click "Overwrite" if prompted
5. ✓ Verify file is uploaded

#### 📁 templates/reports/dashboard.html
**Local Path:** `c:\Users\BEST\Desktop\grazuri\templates\reports\dashboard.html`

1. In same folder (`public_html/grazuri/templates/reports/`)
2. Upload `dashboard.html`
3. Overwrite existing file
4. ✓ Verify upload

#### 📁 templates/reports/financial/index.html
**Local Path:** `c:\Users\BEST\Desktop\grazuri\templates\reports\financial\index.html`

1. Navigate to: `public_html/grazuri/templates/reports/financial/`
2. Upload `index.html`
3. Overwrite existing file
4. ✓ Verify upload

#### 📁 templates/reports/financial/chart_of_accounts.html
**Local Path:** `c:\Users\BEST\Desktop\grazuri\templates\reports\financial\chart_of_accounts.html`

1. In same folder (`public_html/grazuri/templates/reports/financial/`)
2. Upload `chart_of_accounts.html`
3. Overwrite existing file
4. ✓ Verify upload

#### 📁 templates/reports/financial/account_ledger.html
**Local Path:** `c:\Users\BEST\Desktop\grazuri\templates\reports\financial\account_ledger.html`

1. In same folder (`public_html/grazuri/templates/reports/financial/`)
2. Upload `account_ledger.html`
3. Overwrite existing file
4. ✓ Verify upload

---

### Step 3: Upload Python Files

#### 📁 accounting/pdf_reports.py
**Local Path:** `c:\Users\BEST\Desktop\grazuri\accounting\pdf_reports.py`

1. Navigate to: `public_html/grazuri/accounting/`
2. Upload `pdf_reports.py`
3. Overwrite existing file
4. ✓ Verify upload

#### 📁 reports/financial_reports_views.py
**Local Path:** `c:\Users\BEST\Desktop\grazuri\reports\financial_reports_views.py`

1. Navigate to: `public_html/grazuri/reports/`
2. Upload `financial_reports_views.py`
3. Overwrite existing file
4. ✓ Verify upload

#### 📁 reports/urls.py
**Local Path:** `c:\Users\BEST\Desktop\grazuri\reports\urls.py`

1. In same folder (`public_html/grazuri/reports/`)
2. Upload `urls.py`
3. Overwrite existing file
4. ✓ Verify upload

---

### Step 4: Restart the Application

#### Option A: Touch restart file (Recommended)
1. In cPanel File Manager, navigate to: `public_html/grazuri/tmp/`
2. Right-click on `restart.txt` file
3. Select "Touch" (updates timestamp to trigger restart)
4. Click "Touch File(s)"

#### Option B: Create new restart file
1. Navigate to: `public_html/grazuri/tmp/`
2. Click "New File"
3. Name it: `restart.txt`
4. Click "Create New File"

#### Option C: Restart Python App (if available)
1. Go back to cPanel main page
2. Look for "Setup Python App" or "Python Selector"
3. Click "Restart" button next to your application

---

### Step 5: Clear Cache & Verify

1. **Clear Browser Cache:**
   - Press `Ctrl + Shift + Delete`
   - Select "Cached images and files"
   - Click "Clear data"
   - OR just press `Ctrl + F5` to hard refresh

2. **Visit Dashboard:**
   - Go to: https://grazuri.uzuriapps.xyz/reports/
   - Scroll to "📊 Consolidated Financial Reports" section
   - Look for BLUE BANNER with "📚 Chart of Accounts"

3. **Expected Result:**
   ```
   ╔══════════════════════════════════════════════════════════╗
   ║ 📊 📚 Chart of Accounts [PDF][PDF][PDF][PDF]            ║
   ║                                                          ║
   ║ Complete overview of all general ledger accounts        ║
   ║ with live balances...                                   ║
   ║                                                          ║
   ║ 📄 4 PDF Reports: Chart • Trial • Income • Balance      ║
   ║                                                          ║
   ║            [View Chart of Accounts →]                   ║
   ╚══════════════════════════════════════════════════════════╝
   ```

4. **Test PDF Downloads:**
   - Click "View Chart of Accounts →"
   - You should see 4 colored PDF buttons:
     - 🔴 RED: Chart of Accounts PDF
     - 🟢 GREEN: Trial Balance PDF  
     - 🔵 BLUE: Income Statement PDF
     - 🔷 CYAN: Balance Sheet PDF
   - Click each button to download PDF
   - Verify PDFs show:
     - ✓ "Haven Grazuri Investment Limited" at top
     - ✓ "Trusted Microfinance Partner" tagline
     - ✓ Your actual data (expenses, accounts, etc.)

---

## Troubleshooting

### ❌ Button Still Not Visible?

**Check 1: File Upload Verification**
- In cPanel File Manager, navigate to the uploaded file
- Right-click → View
- Search for "Chart of Accounts" text
- If NOT found, re-upload the file

**Check 2: Application Restart**
- Touch restart.txt again
- Wait 2-3 minutes
- Try accessing site again

**Check 3: Template Caching**
- Clear browser cache completely
- Try incognito/private window
- Try different browser

**Check 4: Correct Template File**
- Make sure you uploaded `standalone_dashboard.html`
- The production site uses this template, not `dashboard.html`

### ❌ PDF Shows KES 0?

This is expected on LOCAL machine because local database is empty.

On PRODUCTION:
- You should see actual data (KES 27,019 expenses this month)
- Production database has all the transactions
- PDFs will populate correctly with real numbers

### ❌ 404 Error on PDF?

1. **Check urls.py uploaded:**
   - Navigate to `public_html/grazuri/reports/urls.py`
   - Right-click → View
   - Look for routes like `chart-of-accounts/pdf/`

2. **Check views.py uploaded:**
   - Navigate to `public_html/grazuri/reports/financial_reports_views.py`
   - Right-click → View
   - Look for functions like `chart_of_accounts_pdf`

3. **Restart application again**

---

## Files Checklist

Before verifying, ensure these files were uploaded:

- [ ] `templates/reports/standalone_dashboard.html` ← **CRITICAL**
- [ ] `templates/reports/dashboard.html`
- [ ] `templates/reports/financial/index.html`
- [ ] `templates/reports/financial/chart_of_accounts.html`
- [ ] `templates/reports/financial/account_ledger.html`
- [ ] `accounting/pdf_reports.py`
- [ ] `reports/financial_reports_views.py`
- [ ] `reports/urls.py`
- [ ] Application restarted (restart.txt touched)
- [ ] Browser cache cleared

---

## Success Criteria

✓ Dashboard shows blue "Chart of Accounts" banner  
✓ Banner is in "Consolidated Financial Reports" section  
✓ Banner shows "4 PDF Reports" text  
✓ Clicking banner opens Chart of Accounts page  
✓ Chart page shows 4 colored PDF buttons  
✓ All 4 PDFs download successfully  
✓ PDFs show company branding  
✓ PDFs show production data (not KES 0)

---

## Alternative: FTP Upload

If you prefer using FTP client (FileZilla, WinSCP):

### FileZilla Instructions:
1. Open FileZilla
2. Connect to: `grazuri.uzuriapps.xyz` (Port 21 or 22)
3. Username: `xygbfpsg`
4. Password: (your cPanel password)
5. Remote path: `/home/xygbfpsg/public_html/grazuri/`
6. Drag & drop files from left (local) to right (server)
7. Overwrite when prompted
8. Touch restart.txt via cPanel

---

## Need Help?

If deployment still fails:

1. **Check error logs:**
   - cPanel → Error Log
   - Look for recent Python/Django errors

2. **Verify permissions:**
   - Files should be readable (644)
   - Directories should be executable (755)

3. **Check Python version:**
   - Production should use Python 3.8+
   - Check via: `python --version` in terminal

4. **Contact hosting support:**
   - Provide error logs
   - Mention "Django template not loading"

---

**Deployment Status:** Ready to Deploy  
**Priority:** HIGH - Feature is complete but not visible to users  
**Impact:** Users can't access PDF reports until deployed
