# PMS Demo Seeder — SRS ABC Scenario

## Overview

The PMS Demo Seeder provides idempotent, realistic demonstration data implementing the full **SRS §27 and §28 ABC scenario**. It enables local development and QA environments to exercise the entire Project Management System hierarchy quickly without requiring manual setup or production secrets.

---

## How to Run

### 1. Dedicated Artisan Command (Recommended)

Seed the demo hierarchy for the active/demo company:

```bash
php artisan pms:seed-demo
```

Seed for a specific company by ID:

```bash
php artisan pms:seed-demo --company=1
```

Run only the demo scenario without re-running base seeders:

```bash
php artisan pms:seed-demo --demo-only
```

### 2. Standard Database Seeder

Run the PMS demo seeder directly via `db:seed`:

```bash
php artisan db:seed --class="Modules\Project\Database\Seeders\PmsDemoSeeder"
```

### 3. Module Database Seeder

Run the module database seeder (which hooks both `TeamDivisionAndContractRoleSeeder` and `PmsDemoSeeder`):

```bash
php artisan db:seed --class="Modules\Project\Database\Seeders\ProjectDatabaseSeeder"
```

Or using Laravel Modules:

```bash
php artisan module:seed Project
```

---

## Seeded Hierarchy & Data Structure

### 1. Client & Project
- **Client**: `ABC Corporation` (Code: `ABC-CORP`)
- **Project**: `ABC Digital Growth` (Type: `Retainer`, Status: `active`)

### 2. Services & Service Teams
- **SEO Service** (`SEO`) → **SEO Team**
- **Digital Marketing Service** (`DM`) → **Digital Marketing Team**

### 3. Permanent Employees & Team Rosters (SRS §27)
- **Employees**:
  - `EMP-DEMO-RAHIM`: Rahim Ahmed
  - `EMP-DEMO-KARIM`: Karim Chowdhury
  - `EMP-DEMO-HASAN`: Hasan Mahmud
  - `EMP-DEMO-SAKIB`: Sakib Al-Hasan
  - `EMP-DEMO-NABIL`: Nabil Ahmed
  - `EMP-DEMO-FAHIM`: Fahim Hossain
- **Permanent Memberships**:
  - **SEO Team**: Rahim (BD), Karim (BD), Hasan (PD), Sakib (PD)
  - **Digital Marketing Team**: Karim (BD), Nabil (PD), Fahim (PD)

> [!IMPORTANT]
> **Act As Rule (SRS §27)**:
> Rahim's permanent team membership is **SEO Team**. On the **Digital Marketing Contract**, Rahim is assigned as a **Sales Person** with `is_act_as = true`. His permanent team membership in `service_team_members` remains untouched.

### 4. Contracts
- **SEO Contract**:
  - Number: `CON-ABC-SEO-001`
  - Value: `$200.00`
  - Duration: 6 Months (`2026-01-01` to `2026-06-30`)
  - Team:
    - BD: Rahim (Sales Person, `is_act_as = false`), Karim (Closer, `is_act_as = false`)
    - PD: Hasan (PM, `is_act_as = false`), Sakib (PM, `is_act_as = false`)
- **Digital Marketing Contract**:
  - Number: `CON-ABC-DM-001`
  - Value: `$100.00`
  - Duration: 3 Months (`2026-01-01` to `2026-03-31`)
  - Team:
    - BD: **Rahim** (Sales Person, **`is_act_as = true`**), Karim (Closer, `is_act_as = false`)
    - PD: Nabil (PM, `is_act_as = false`), Fahim (PM, `is_act_as = false`)

### 5. Commission Shares ($100 Example — SRS §28)
For the **Digital Marketing Contract** ($100):
- **Team Share**: 30.00% → **Team Pool**: `$30.00`
- **BD Share**: 40.00% of Team Pool → **BD Pool**: `$12.00`
- **PD Share**: 60.00% of Team Pool → **PD Pool**: `$18.00`

---

## Business Rules & Idempotency

- **Idempotent**: All database operations use `firstOrCreate` / `updateOrCreate` keyed on tenant company and unique natural keys (`code`, `contract_number`, `employee_no`, etc.). Executing the seeder multiple times produces zero duplicate rows.
- **Tenant-Scoped**: Seeder operations are scoped to the specified tenant `company_id`.
- **Safe for Local/QA**: Demo names are clearly labeled and contain no production secrets.
