# Famosity ERP — Installation Guide

## Server Requirements
- PHP 8.2+ (check via `php -v`)
- MySQL 5.7+ / MariaDB 10.3+
- Composer 2.x
- mod_rewrite enabled
- Required PHP extensions: pdo_mysql, mbstring, openssl, tokenizer, xml, ctype, json, bcmath, fileinfo, gd

---

## Step 1: Upload Files

Upload the entire project zip to your server and extract into:
```
/home/wqftutpg/test-erp.famosity.krenx.in/
```

---

## Step 2: SSH Into Server

```bash
ssh wqftutpg@your-server-ip
cd /home/wqftutpg/test-erp.famosity.krenx.in
```

---

## Step 3: Install Dependencies

```bash
# Check PHP version first
php -v

# If Composer is not installed globally:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

# Install Laravel dependencies
composer install --no-dev --optimize-autoloader
```

---

## Step 4: Configure Environment

The `.env` file is already pre-configured with your database details.
Just generate the application key:

```bash
php artisan key:generate
```

---

## Step 5: Run Migrations & Seed

```bash
# Run all database migrations
php artisan migrate --force

# Seed demo data (creates demo@famosity.in account)
php artisan db:seed --force
```

---

## Step 6: Set Permissions

```bash
chmod -R 755 storage/
chmod -R 755 bootstrap/cache/
chmod -R 755 public/uploads/
mkdir -p storage/fonts
chmod -R 755 storage/fonts/
```

---

## Step 7: Create Storage Symlink

```bash
php artisan storage:link
```

---

## Step 8: Optimize for Production

```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

---

## Step 9: Quick Deploy Script

Or simply run the included script:
```bash
bash deploy.sh
```

---

## Step 10: Access the Application

| Item | Value |
|------|-------|
| URL | https://test-erp.famosity.krenx.in |
| Demo Email | demo@famosity.in |
| Demo Password | Demo@12345 |

⚠️ **Change the demo password immediately after first login!**

---

## Troubleshooting

### 500 Error on first load
```bash
php artisan config:clear
php artisan cache:clear
chmod -R 777 storage/
```

### PDF generation fails
- Ensure `storage/fonts/` is writable
- dompdf writes font cache there on first run

### Migration fails
```bash
# Check DB connection
php artisan tinker
>>> DB::connection()->getPdo();
```

### Class not found errors
```bash
composer dump-autoload
php artisan optimize:clear
```

### White page / blank screen
```bash
tail -f storage/logs/laravel.log
```

---

## Cron Job (for overdue invoice marking)

In cPanel → Cron Jobs, add:
```
* * * * * php /home/wqftutpg/test-erp.famosity.krenx.in/artisan schedule:run >> /dev/null 2>&1
```

---

## Default Chart of Accounts

The system auto-creates 40+ standard accounts including:
- Cash, Bank, Accounts Receivable
- Output CGST/SGST/IGST Payable
- Input CGST/SGST/IGST (ITC)
- Sales Revenue, COGS
- All standard expense accounts

---

## GST Compliance Features

- ✅ CGST + SGST (intra-state) auto-calculation
- ✅ IGST (inter-state) auto-calculation
- ✅ HSN/SAC code on all line items
- ✅ GSTR-1 summary with B2B/B2C split
- ✅ GSTR-3B with ITC calculation
- ✅ Input Tax Credit tracking
- ✅ Financial year-wise invoice numbering
- ✅ PDF invoices ready to email CA
- ✅ Trial Balance, P&L, Balance Sheet PDFs

---

## Support
Built by Famosity | test-erp.famosity.krenx.in
