# UAE Government Services, Typing Center & PRO Operations SaaS ERP

A Laravel 12 multi-tenant ERP for UAE typing centers, document-clearing firms, government service centers, and corporate PRO teams.

## User documentation

See the [Complete User Guide](docs/USER_GUIDE.md) for role-based operating instructions, the UAE service workflow, administration, demo access, security guidance, and troubleshooting.

## Implemented application layers

- SaaS platform administration, plans, subscriptions, feature entitlements, usage, support, billing, security, and audited impersonation.
- Shared-database tenant isolation with permission-driven roles, user overrides, branch context, employees separated from login accounts, onboarding, and settings.
- Customer 360, phone-first search, identity history, private document vault, families, corporate companies, corporate employees, and duplicate merging.
- Configurable services, dynamic forms, document rules, component fees, price overrides, immutable service versions, workflow stages, SLA-ready processing, application 360, submissions, returns, and bulk corporate applications.
- Tenant billing/POS with immutable application fee snapshots, split and partial tenders, corporate-credit limits, invoices, receipts, controlled refunds, cash sessions, vendors, and double-entry journals.
- Accounting separation for government clearing liabilities, company revenue, VAT output, accounts receivable, cash, bank, card, wallet, and customer advances.
- Renewal automation across customer, corporate, employee, and company-compliance expiry sources, with idempotent scans, reminder rules/logs, pipeline history, follow-ups, and renewal-to-application conversion.
- Responsive Blade/Tailwind/Alpine workspaces with English/Arabic direction support.

## Local setup

Requirements: PHP 8.2+, Composer, Node.js, and SQLite or MySQL.

```bash
composer install
copy .env.example .env
php artisan key:generate
php artisan migrate --seed
npm install
npm run build
php artisan serve
```

Run queue workers and the scheduler in separate production-managed processes:

```bash
php artisan queue:work
php artisan schedule:work
```

The renewal scheduler runs `renewals:scan` daily at 01:00 Asia/Dubai. It can also be run for one tenant:

```bash
php artisan renewals:scan --tenant=1 --window=90
```

## Verification

```bash
php artisan test
npm run build
php artisan migrate:status
```

The automated suite covers authentication, RBAC, tenant isolation, onboarding limits, customer/corporate masters, service versioning, fee/workflow engines, application processing, financial classification, split/partial payments, refunds, renewal idempotency, reminders, and live workspace rendering.

## Production notes

- Production seeding never creates the sample tenant or predictable demo users.
- Use MySQL, Redis-backed cache/queues, private S3-compatible storage, TLS, supervised workers, the Laravel scheduler, encrypted off-site backups, and centralized monitoring.
- Keep `APP_DEBUG=false`; provide all credentials through environment variables or a secret manager.
- External WhatsApp/SMS/email providers, payment gateways, OCR/AI providers, and webhook delivery workers remain adapter integrations and must be configured per deployment.

## Delivery status

The current codebase implements the core platform through billing/accounting and renewal automation. The broader master roadmap still includes full customer/corporate portals, communication-provider adapters and campaigns, PRO/document-custody operations, queue/tokens, appointments, task/approval centers, advanced reports, public APIs/webhooks, AI adapters, backup orchestration, and system-health operations.
