# Deployment Guide — Comprehensive Accounting Pages
## Haven Grazuri Investment Limited

Upload the files below to production via **cPanel File Manager** or FTP,
then run the migration and restart.

---

## Step 1 — Upload Python files

| Local path | Remote path on server |
|---|---|
| `accounting/pdf_reports.py` | `public_html/grazuri/accounting/pdf_reports.py` |
| `accounting/migrations/0005_add_comprehensive_accounts.py` | `public_html/grazuri/accounting/migrations/0005_add_comprehensive_accounts.py` |
| `reports/financial_reports_views.py` | `public_html/grazuri/reports/financial_reports_views.py` |
| `reports/urls.py` | `public_html/grazuri/reports/urls.py` |

---

## Step 2 — Upload template files

Navigate to `public_html/grazuri/templates/reports/financial/` and upload:

| File |
|---|
| `templates/reports/financial/index.html` |
| `templates/reports/financial/chart_of_accounts.html` |
| `templates/reports/financial/trial_balance.html` |
| `templates/reports/financial/income_statement.html` |
| `templates/reports/financial/balance_sheet.html` |
| `templates/reports/financial/cash_flow_statement.html` |

---

## Step 3 — Run migration (via cPanel Terminal or SSH)

```bash
cd public_html/grazuri
python manage.py migrate accounting
```

This creates **88 new accounts** covering:
- Fixed assets & accumulated depreciation
- PAYE / NHIF / NSSF / Housing Levy payables
- Corporate tax, VAT, withholding tax payables
- M-Pesa fees, bank charges, Airtel Money fees
- Rent, utilities, internet, office supplies
- IT/software subscriptions
- Legal, audit, consulting fees
- Marketing & advertising
- Depreciation expenses (5 categories)
- Bad debt expense & loan loss reserve

---

## Step 4 — Restart the app

Touch `public_html/grazuri/tmp/restart.txt` in File Manager, or use
the Python App panel in cPanel.

---

## Step 5 — Verify

Visit these URLs and confirm 200 responses:

| Page | URL |
|---|---|
| Financial Reports Hub | `/reports/financial/` |
| Chart of Accounts | `/reports/financial/chart-of-accounts/` |
| Trial Balance | `/reports/financial/trial-balance/` |
| Income Statement | `/reports/financial/income-statement/` |
| Balance Sheet | `/reports/financial/balance-sheet/` |
| Cash Flow Statement | `/reports/financial/cash-flow/` |
| Chart of Accounts PDF | `/reports/financial/chart-of-accounts/pdf/` |
| Trial Balance PDF | `/reports/financial/trial-balance/pdf/` |
| Income Statement PDF | `/reports/financial/income-statement/pdf/` |
| Balance Sheet PDF | `/reports/financial/balance-sheet/pdf/` |

---

## What's new

### 5 comprehensive report pages
Each page has:
- Date range / as-of date filter
- PDF export button (opens in browser tab)
- Excel/CSV export button
- Sortable table columns (click any column header)
- Key financial ratios and KPIs
- Explanation notes

### 4 fully functional PDF reports
Generated with ReportLab. Each PDF includes:
- Haven Grazuri branding header on every page
- Page numbers + generation timestamp
- Professional colour-coded sections
- Totals, subtotals and balance checks

### 88 new accounts added
Full microfinance chart covering all operational areas.
All new accounts are inactive-safe — they appear with KES 0 until
transactions are posted.

### Sorting on all tables
Click any column header to sort ascending/descending.
Totals rows stay pinned at the bottom.
