# Corporate Phase 1 Execution Plan

Date: 2026-05-08

## Audit Evidence Used

- `docs/corporate_module_audit.md` confirms the corporate module is partial.
- `Organization` is the current B2B foundation through `organizations`, `organization_members`, `org_employees`, `org_enrollments`, and `org_audit_logs`.
- `B2bLead` already exists and is created from the public `/b2b` form.
- `/b2b` exists and `/institutions` redirects to it; `/corporate` is missing.
- `TenancyMiddleware` only checks the presence of `selected_organization_id` and does not validate active membership or active organization status.
- `OrgSelectOrganizationPage::selectOrganization($id, $role)` trusts role data passed from the UI.
- Dedicated policies for organization entities and B2B leads are missing.
- `Admin\Corporate\CorporateDashboard` imports `App\Models\Company`, but `Company.php` does not exist.

## Phase 1 Scope

This phase stabilizes the foundation only:

- Use `Organization` as the canonical model.
- Keep `companies` as legacy data only.
- Add `/corporate` alias.
- Harden organization tenancy.
- Add B2B lead admin queue and activity timeline.
- Improve `/b2b` lead submission with Algerian phone normalization, rate limiting, duplicate detection, and non-blocking notification records.
- Add MVP conversion from lead to organization.

Out of scope:

- Corporate proposals.
- Agreements.
- Corporate invoices.
- Excel trainee upload.
- Full corporate cohort billing.

## Implementation Order

1. Document canonical data decision.
2. Add lead lifecycle migration and model relations.
3. Add RBAC permissions and policies.
4. Harden organization selection and tenancy middleware.
5. Add `/corporate` route and improve public B2B form.
6. Add admin B2B lead list/detail.
7. Add MVP conversion to `Organization`.
8. Add messaging/outbox records for lead submission.
9. Localize hardcoded organization portal strings.
10. Add tests and final documentation.

