# Corporate Links Audit

Date: 2026-05-12

## Summary

The Corporate module routes mostly existed, but Admin navigation did not expose the complete workflow and the Organizations admin routes were missing. This made the module feel broken even where the underlying pages existed.

## Route And Link Matrix

| Link label | Source file | Target route | Route exists? | Permission required | Status | Notes |
|---|---|---:|---|---|---|---|
| Corporate dashboard | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-dashboard` | yes | `corporate_dashboard.view` | fixed | Added to admin sidebar. |
| B2B leads | `resources/views/components/portal/sidebar.blade.php` | `admin.b2b.leads.index` | yes | `b2b.leads.view` | fixed | Already existed, kept permission-aware. |
| Organizations | `resources/views/components/portal/sidebar.blade.php` | `admin.organizations.index` | yes | `organizations.view` | fixed | Added missing route and Livewire pages. |
| Organization detail | `resources/views/livewire/admin/organizations/index-page.blade.php` | `admin.organizations.show` | yes | `OrganizationPolicy::view` | fixed | Added protected detail page. |
| Corporate proposals | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-proposals.index` | yes | `corporate_proposals.view` | fixed | Already existed, kept permission-aware. |
| Corporate agreements | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-agreements.index` | yes | `corporate_agreements.view` | fixed | Already existed, kept permission-aware. |
| Corporate cohorts | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-cohorts.index` | yes | `corporate_cohorts.view` | fixed | Added to admin sidebar. |
| Corporate reports | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-reports.index` | yes | `corporate_reports.view` | fixed | Added to admin sidebar. |
| Corporate invoices | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-invoices.index` | yes | `corporate_invoices.view` | fixed | Added to admin sidebar. |
| Corporate payments | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-payments.index` | yes | `corporate_payments.view` | fixed | Added to admin sidebar. |
| Corporate credit notes | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-credit-notes.index` | yes | `corporate_credit_notes.view` | fixed | Added to admin sidebar. |
| Corporate receivables | `resources/views/components/portal/sidebar.blade.php` | `admin.corporate-finance.receivables` | yes | `corporate_receivables.view` | fixed | Added to admin sidebar. |
| Organization programs | `routes/org.php` | `org.programs` | yes | org tenancy + org membership | verified | Covered by org portal smoke test. |
| Organization reports | `routes/org.php` | `org.reports` | yes | org tenancy + `org.reports.view` | verified | Demo user receives permission in seeder. |
| Organization invoices | `routes/org.php` | `org.invoices` | yes | org tenancy + `org.invoices.view` | verified | Tested for org scoping. |

## Findings Fixed

- Missing `/admin/organizations` and `/admin/organizations/{organization}` routes were added.
- Admin sidebar now exposes all Corporate workflow modules behind explicit permissions.
- `resources/views/components/layouts/admin.blade.php` no longer throws `Undefined variable $title` when Livewire pages do not provide a title.
- Organization admin pages were added as a safe hub for proposals, agreements, cohorts, reports, invoices, and payments.

## Route Naming Note

This project uses the `admin.` route namespace for admin pages. The normalized route names are therefore `admin.corporate-proposals.index`, `admin.corporate-invoices.show`, etc. Public/org route names keep their existing names such as `public.corporate`, `org.programs`, `org.reports`, and `org.invoices`.

## Verification

Covered by:

- `tests/Feature/Corporate/CorporateLinksSmokeTest.php`
- `tests/Feature/Corporate/CorporateDashboardWithSeedDataTest.php`
- `tests/Feature/Corporate/OrgPortalSeedDataTest.php`
