# Corporate Links And Demo Seeder

Date: 2026-05-12

## What Was Added

- Complete Corporate navigation links in the admin sidebar.
- Protected Admin Organizations index/detail pages.
- `CorporateWorkflowDemoSeeder` for realistic B2B/Corporate workflow testing.
- Smoke/regression tests for route existence, sidebar links, seeded workflow data, dashboard visibility, and org portal scoping.

## How To Run The Demo Seeder

```bash
php artisan db:seed --class=CorporateWorkflowDemoSeeder
```

The seeder is idempotent and can be run multiple times. Demo references use clear prefixes:

- `DEMO-CORP-*` for corporate cohorts.
- `DEMO-PROP-*` for corporate proposals.
- `DEMO-AGR-*` for corporate agreements.
- `DEMO-REP-*` for corporate reports.
- `DEMO-INV-*` for corporate invoices.
- `DEMO-PAY-*` for corporate payments.
- `DEMO-CN-*` for credit notes.

## Demo Accounts

All demo users are created with the local password `password`.

| Account | Role | Purpose |
|---|---|---|
| `admin.demo@ecoin.test` | admin | Full Corporate admin testing. |
| `support.demo@ecoin.test` | support | View-only/support workflow checks. |
| `teacher.demo@ecoin.test` | teacher | Assigned corporate cohort and attendance testing. |
| `org.member.demo@ecoin.test` | student + org member | Organization portal programs/reports/invoices testing. |

## Demo Scenarios

| Scenario | Organization / institution | Main objects |
|---|---|---|
| 1 | مؤسسة النور للخدمات التعليمية | New `B2bLead` only. |
| 2 | شركة الجزائر الرقمية | Converted lead + active `Organization` + org member. |
| 3 | مؤسسة النجاح للتكوين المهني | Sent proposal with PDF path and items. |
| 4 | مدرسة المستقبل الخاصة | Converted proposal + draft agreement. |
| 5 | مؤسسة الريادة الاقتصادية | Active agreement + corporate cohort + trainees + attendance. |
| 6 | شركة أوران للتقنيات | Completed cohort + generated final report. |
| 7 | مؤسسة المتوسط للاستشارات | Invoice + confirmed payment + allocation + financial transaction. |
| 8 | المجمع الإداري للجنوب | Overdue invoice for aging/receivables testing. |
| 9 | شركة التعليم الذكي | Applied credit note with recalculated invoice balance. |
| 10 | مؤسسة الأفق للتدريب | Allocation reversal + negative financial transaction. |

An additional organization named `مؤسسة بيانات لوحة التحكم` is included to make dashboard organization counts easier to validate.

## Official Admin Route Names

The project uses the `admin.` namespace for admin routes:

- `admin.corporate-dashboard`
- `admin.b2b.leads.index`
- `admin.organizations.index`
- `admin.organizations.show`
- `admin.corporate-proposals.index`
- `admin.corporate-agreements.index`
- `admin.corporate-cohorts.index`
- `admin.corporate-reports.index`
- `admin.corporate-invoices.index`
- `admin.corporate-payments.index`
- `admin.corporate-credit-notes.index`
- `admin.corporate-finance.receivables`

Org portal routes:

- `org.programs`
- `org.reports`
- `org.invoices`

## Validation Commands

```bash
php artisan test tests/Feature/Corporate/CorporateLinksSmokeTest.php tests/Feature/Corporate/CorporateWorkflowDemoSeederTest.php tests/Feature/Corporate/CorporateDashboardWithSeedDataTest.php tests/Feature/Corporate/OrgPortalSeedDataTest.php
```

Expected result in this implementation:

- 5 tests passing.
- 75 assertions passing.

## Safety Notes

- The seeder uses `Organization` as the canonical customer account.
- It does not use `Company`, `users.company_id`, or `agreement_path`.
- Demo private files are written to the `private` disk as dummy content paths for proposals, agreements, reports, invoices, receipts, and credit notes.
- It does not touch individual student payment flows.
