# WP0 — Expand the E2E test-company seed (foundation for all request scenarios)

## Goal
The E2E test company (id 8) has only one investigation. To test insurance/B2B/package/outsourced request flows, extend `e2e/setup/seed-e2e-company.php` with the needed entities — additive, idempotent, company 8 ONLY. Run the seed on dev and export the created ids so the specs reference them by env or a JSON.

## Repo & branch
FE repo `/home/moonui/public_html/moon-erp`, branch `hazemdev`. Commit `test(e2e):`.

## Current seed
`e2e/setup/seed-e2e-company.php` (idempotent tinker script, run via `php artisan tinker --execute="require '.../seed-e2e-company.php';"` from the BE repo). Creates: company 8 (prefix e2etest), branch, users e2e@moonerp.test + e2e-reviewer@moonerp.test (owner role), section, specimen, investigation E2E-CBC (id 3941). It echoes `E2E_*` vars at the end.

## Add (all `firstOrCreate`/idempotent, scoped `company_id => $company->id`)
Verified schema (only use real columns):
- **2-3 more investigations**: e.g. `E2E-GLU` (glucose, numeric), `E2E-K` (potassium). Mirror how E2E-CBC is created (section, specimen, code, name/name_ar, price, is_active).
- **A panel investigation** `E2E-PANEL` with `is_panel=true` + 2 panel members (so R8 panel test works). Check how panels + members are stored (lab_investigation_panel_members or a pivot — inspect an existing panel in company 4 for the shape) and mirror it.
- **An insurance contract** (`lab_insurance_contracts`): columns incl. `partner_id` (create/reuse a partner), `name/name_ar`, `code`, `patient_share_percentage` (e.g. 30), `coverage_type` + `default_coverage_value`, `price_list_id` (the one below), `is_active=1`, `start_date`/`end_date`. Needs a partner — create a minimal partner for the insurer if the schema requires it.
- **A price list** (`lab_price_lists`): `name/name_ar`, `code`, `currency_code`, `is_active=1`, `is_default=0`. Optionally a couple of price-list items for the test investigations if that table drives insurance pricing (inspect `lab_price_list_items`).
- **An external lab** (`lab_external_labs`): `name/name_ar`, `code`, `partner_id` (create/reuse), `price_list_id`, `is_active=1` — for R3 B2B.
- **A package** (`lab_packages`): `name/name_ar`, `code`, `total_price`, `package_price` (discounted < total), `price_deductible`, `billing_mode`, `is_active=1`, with 2 member investigations (inspect `lab_package_investigations` pivot for the shape).
- **An outsourced investigation** `E2E-OUT` with `is_outsourced=1` + `default_external_lab_id` = the external lab above — for R9.

## Output (critical for the specs)
At the end of the seed, echo the new ids the same way it echoes E2E_* today, e.g.:
`E2E_INSURANCE_CONTRACT_ID=..`, `E2E_EXTERNAL_LAB_ID=..`, `E2E_PACKAGE_ID=..`, `E2E_PANEL_ID=..`, `E2E_OUTSOURCED_INV_ID=..`, `E2E_INV_GLU_ID=..`, `E2E_INV_K_ID=..`, `E2E_PRICE_LIST_ID=..`. Record these in a comment block at the top of the file AND report them, so WP1-WP4 specs can hardcode/env them.

## Run
Run the seed on dev: `cd /home/moonui/moon-erp-be && php artisan tinker --execute="require '/home/moonui/public_html/moon-erp/e2e/setup/seed-e2e-company.php';"`. Idempotent — re-runnable. ⛔ Never migrate:fresh, never touch companies other than 8.

## Acceptance
- [ ] Seed runs clean on dev (idempotent, re-run twice = same ids, no dup).
- [ ] Company 8 now has: ≥3 investigations, 1 panel (2 members), 1 insurance contract (with partner + shares), 1 external lab, 1 price list, 1 package (2 members, discounted), 1 outsourced investigation.
- [ ] All entities `company_id=8`; a spot-check query confirms zero rows leaked to other companies.
- [ ] The new ids are echoed + documented at the top of the seed file.

## Out of scope
The spec files (WP1-4). Do NOT create requests here — just master data.

## Flags
No [FIN] (master data, no money movement). No migration (additive inserts via tinker). Company-8-only isolation is the safety rule.
