# Seeded roles & logins (all modules)

Built from the full permission catalog in `erp-core-backend/app/Services/PermissionService.php`
and the complete routes in `erp-core-backend/routes/api.php`. Seeded by
`erp-core-backend/database/seeders/RolesAndLoginsSeeder.php` (runs with every
`php artisan db:seed` — see `DatabaseSeeder.php`; `CompanyBootstrapSeeder`
creates the original five accounts with the same emails/passwords, so the
seeder is idempotent).

**One password for every seeded account: `Abcd@1234`**
(`RolesAndLoginsSeeder::DEFAULT_PASSWORD`, shared with `CompanyBootstrapSeeder`).

All roles work in both of your frontends:

- **Admin panel / ERP frontend** (`erp-frontend`, Next.js) — log in with the
  email + password; the nav filters itself from each role's granted
  permissions (`usePermittedNav` reads `user.permissions` from the login
  response; `*` means everything).
- **API** — `POST /api/login` returns `{ access_token, user.permissions }`;
  send `Authorization: Bearer <access_token>` afterwards.

## Logins

| Role | Key | Email | Password | Permissions |
|---|---|---|---|---|
| System Admin (superuser, bypasses checks) | admin | admin@company.test | Abcd@1234 | * (all) |
| HR Manager | hr | hr@company.test | Abcd@1234 | 57 |
| Branch Manager | branch_manager | manager@company.test | Abcd@1234 | 68 |
| Accountant | accountant | accounts@company.test | Abcd@1234 | 40 |
| Sales Executive | sales | sales@company.test | Abcd@1234 | 50 |
| Employee (self-service) | employee | staff@company.test | Abcd@1234 | 8 |
| Pharmacist | pharmacist | pharmacist@company.test | Abcd@1234 | 11 |
| Pharmacy Cashier | pharmacy_cashier | cashdesk@company.test | Abcd@1234 | 5 |
| Investments & Funds Admin | investor_funds_admin | funds@company.test | Abcd@1234 | 14 |
| Support Agent | support_agent | support@company.test | Abcd@1234 | 8 |
| Support Lead | support_lead | supportlead@company.test | Abcd@1234 | 10 |
| Social Media Manager | social_media_manager | social@company.test | Abcd@1234 | 20 |
| SEO Specialist | seo_specialist | seo@company.test | Abcd@1234 | 18 |

Custom roles created in the UI get a `slug@company.test` login automatically
when the seeder re-runs (same default password), with permissions created via
the Roles & Permissions page.

## What each non-obvious role can do

- **Investments & Funds Admin** — investor records and investments
  (`investments.*`), company-fund payments + withdrawal approvals
  (`funds.view/manage/approve`), wallets & the master payments page. Mirrors
  the wallet-ledger integration: sees the investor cash-movement pages the
  `wallet_id` legs feed.
- **Support Agent** — ticket work + live chat + helpdesk knowledge base;
  cannot close tickets, change SLA, or touch settings (`support.approve`,
  `support.settings` held back).
- **Support Lead** — everything an agent has **plus** resolution/closing
  authority, cancellations, escalations and the helpdesk setup
  (departments, teams, SLA, business hours).
- **Social Media Manager** — whole social module: accounts/tokens, posts &
  campaigns (with approve + publish), inbox with assignment, library,
  automations, monitoring, analytics, plus CRM (social leads convert into
  CRM leads).
- **SEO Specialist** — sites/projects, keywords, content briefs, competitors,
  analytics, reports, provider sync plus the marketing module; provider API
  keys and cost tracking (`seo.api`, `seo.settings`) stay with admins.
- **Branch Manager** — branch ops (sales, stock, transfers, deliveries,
  vendors, customers, CRM, support basics) with **read-only** SEO; can also
  review property/parking/fleet/farm/rent modules.

## Notes

- Grants match the actual route middleware (`perm:<key>`) discovered across
  all 97 distinct route permissions; no role is granted a key its routes never
  check, and route-checked sections never left without an owner.
- `sales.view` + the sales `.manage` umbrella plus `sales.approve` (credit
  notes, cancellations) and the wallet/income-payment keys the accountant
  needs for the debtors-page collection flow.
- The settings **read** endpoint is intentionally public (login screen
  needs it); settings changes (`PUT /settings`, integrations, admin content)
  require `settings.manage` — verified 403 for a non-admin role.
- Users list (`GET /users`) is available to every authenticated user (used by
  pickers); creating users requires `users.manage` — verified 403 for others.
