Wire sales/purchase posting, settlements, compliance, payroll employees, and ops edit flows; document the integration report. Co-authored-by: Cursor <cursoragent@cursor.com>
319 lines
17 KiB
Markdown
319 lines
17 KiB
Markdown
# Progress
|
||
|
||
> Completed work only. Future → [roadmap.md](roadmap.md). Next milestone → [next-steps.md](next-steps.md).
|
||
|
||
## Phase 1 — Core Platform ✅
|
||
|
||
### Infrastructure & structure
|
||
- [x] Full project structure with mandatory `backend/` / `frontend/` separation
|
||
- [x] Shared library `backend/shared-lib`
|
||
- [x] Architecture section: Frontend & Backend Separation
|
||
|
||
### Core service
|
||
- [x] Config, database, cache, logging, base security
|
||
- [x] Models, APIs, Entitlement, Celery, Outbox
|
||
- [x] Tests and documentation
|
||
|
||
### Frontend
|
||
- [x] Independent Next.js, API client, white-label theme baseline
|
||
|
||
---
|
||
|
||
## Phase 2 — Identity & Access + SSO ✅
|
||
|
||
- [x] `shared/auth/jwt.py`, `shared/auth/roles.py`, Identity events in `shared/events.py`
|
||
- [x] Identity service + `identity_access_db`
|
||
- [x] Keycloak realm/clients/theme import
|
||
- [x] Core API protection (`AUTH_REQUIRED`, role deps)
|
||
- [x] Frontend SSO flow (`/login`, `/auth/callback`, `/dashboard`)
|
||
- [x] Compose services Identity + Frontend; Postgres init for identity DB
|
||
|
||
---
|
||
|
||
## Phase 3 — OTP Login + Tenant Management ✅
|
||
|
||
- [x] Core `users` + OTP request/verify + Payamak
|
||
- [x] Local JWT (HS256) for OTP users
|
||
- [x] Admin tenant CRUD + owner filtering
|
||
- [x] Frontend admin OTP/tenant UI (later aligned to central SSO)
|
||
- [x] `test_otp_auth.py`
|
||
|
||
---
|
||
|
||
## Phase 4 — Tenant Onboarding & Workspace Activation ✅
|
||
|
||
> Brief alias: sometimes called “Phase 3” externally — see [phase-numbering decision](decisions/technical/phase-numbering.md).
|
||
|
||
- [x] Core `tenant_memberships`, tenant lifecycle, branding columns, domain primary/verification fields
|
||
- [x] `users.current_tenant_id`, FREE/STARTER plan seed, onboarding APIs
|
||
- [x] `UserService` / `MembershipService` / `OnboardingService` / `TenantContextService`
|
||
- [x] Frontend onboarding wizard, tenant dashboard, tenant switcher
|
||
- [x] `test_onboarding.py` + regression suite
|
||
- [x] JIT Core user from Keycloak JWT (`UserService.resolve_current`)
|
||
- [x] Automatic tenant subdomain SSL (Celery → SSH → `provision_ssl.py`)
|
||
- [x] Reverse proxy (Nginx) + base TLS + tenant SSL automation
|
||
|
||
### Intentionally incomplete after Phase 4 (tracked in roadmap, not claimed done)
|
||
Payment gateway · real DNS/TXT custom-domain verify · legacy `POST /admin/tenants` auto membership/plan · first business module
|
||
|
||
---
|
||
|
||
## Phase D — Documentation Architecture Consolidation ✅
|
||
|
||
- [x] Target `docs/` tree (architecture, adr, development, reference, deployment, templates, phases, decisions)
|
||
- [x] Moved canonical docs with git history where possible
|
||
- [x] Deprecated stubs for old paths
|
||
- [x] ADR system initialized (ADR-001 … ADR-010)
|
||
- [x] Project principles, coding standards, testing/branching/release strategies
|
||
- [x] Module registry + provider registry + glossary
|
||
- [x] Deployment runbooks (production, SSL, monitoring, backup, restore, DR)
|
||
- [x] Roadmap / next-steps separation from progress
|
||
- [x] Phase area docs for Accounting, CRM, Restaurant, Marketplace, Automation, AI, Future
|
||
- [x] Cross-links updated in root and package READMEs
|
||
|
||
---
|
||
|
||
## Phase 5.1–5.11 — Accounting Module ✅
|
||
|
||
- [x] Phases 5.1–5.6: Foundation through Sales Integration (see prior entry)
|
||
- [x] Phase 5.7: Purchase & Inventory accounting, InventoryValuationEngine
|
||
- [x] Phase 5.8: Fixed Assets, DepreciationEngine, asset lifecycle
|
||
- [x] Phase 5.9: HCM/Payroll, PayrollEngine, payroll accounting
|
||
- [x] Phase 5.10: Financial Reporting Engine, dashboards, export framework
|
||
- [x] Phase 5.11: Compliance, Audit Framework, Governance, SoD
|
||
- [x] Alembic migration `0002_phases_57_511`
|
||
- [x] 21 tests passing
|
||
|
||
---
|
||
|
||
## Accounting Enterprise Frontend (in SuperApp) ✅ baseline
|
||
|
||
- [x] Design system tokens (light/dark) + DS components (`components/ds`)
|
||
- [x] TanStack Query providers, Sonner toasts, ColorMode
|
||
- [x] Typed `accounting-api` client (JWT + `X-Tenant-ID`, no mocks)
|
||
- [x] Accounting shell + routes: dashboard, COA, fiscal, currencies, cost centers, projects, ledger, setup, suppliers
|
||
- [x] Vouchers list/create/detail with validate/post/reverse/cancel + draft edit (ADR-010)
|
||
- [x] Foundation masters: edit/archive drawers, fiscal year/period actions, COA template import wizard
|
||
- [x] Setup checklist + completion scoreboard on dashboard
|
||
- [x] Treasury, customers, assets, payroll, reports, audit, settings pages (real APIs)
|
||
- [x] Catalog tile available → `/accounting`
|
||
- [x] Frontend docs under `docs/frontend/`
|
||
|
||
Remaining: Phase 5.12 AI UI blocked on AI provider; optional richer PDF export file delivery.
|
||
|
||
---
|
||
|
||
## Accounting Frontend Integration (FE ↔ BE 5.1–5.11) ✅
|
||
|
||
- [x] Full route/menu scan vs `/api/v1` routers; gap matrix executed
|
||
- [x] Domain rewires: payroll employees, compliance policies/risks, settlements, sales-accounting post, purchase GR + valuation, asset schedule, monitoring health
|
||
- [x] FE client: settlements, salesAccounting, purchaseInventory, compliance approvals/risks, ops PATCH
|
||
- [x] Ops documents: detail + edit; treasury receipt/payment cash/bank binding; voucher list pagination
|
||
- [x] BE list endpoints for settlements, risks, purchase posting-profiles (integration completeness)
|
||
- [x] Report: [accounting-frontend-integration-report.md](accounting-frontend-integration-report.md)
|
||
- [x] Scoreboard honesty for partial/ops-backed modules; AI remains blocked
|
||
|
||
---
|
||
|
||
## Phase 6.0 — CRM Service Foundation ✅
|
||
|
||
- [x] `backend/services/crm` service scaffold (API / services / repositories / models)
|
||
- [x] Base aggregates: Lead, Contact, Organization, Opportunity, Pipeline, PipelineStage, SalesActivity, Quote
|
||
- [x] Publish-only event contracts (`crm.lead.*`, `crm.opportunity.*`, …)
|
||
- [x] CRM APIs only (`/api/v1/leads|contacts|organizations|pipelines|opportunities|activities|quotes`)
|
||
- [x] Platform provider contracts only (Automation, Customer360, Notification, Analytics, AI, Communication, Helpdesk)
|
||
- [x] Permissions `crm.*` trees; tenant isolation via `X-Tenant-ID`
|
||
- [x] Alembic `0001_initial` + `crm_db` wiring (compose port 8003)
|
||
- [x] Architecture / dependency / repository / migration / API / permission / tenant / docs tests
|
||
- [x] Docs: [crm-phase-6-0.md](crm-phase-6-0.md), module registry, phase area README
|
||
|
||
---
|
||
|
||
## Phase 6.1 — Enterprise CRM Core Business Entities ✅
|
||
|
||
- [x] Expanded Lead / Contact / Organization (numbers, multi-contact, soft delete, audit actors)
|
||
- [x] Lookups: lead_sources, lead_statuses, contact_types, organization_types, organization_industries
|
||
- [x] Lead assignments, tag engine, reusable addresses, custom fields + values
|
||
- [x] Versioned notes, attachment file-storage references (no binary), CRM audit log
|
||
- [x] Services / repositories / validators / permissions / events for Phase 6.1
|
||
- [x] Alembic `0002_phase_61_entities`
|
||
- [x] API coverage under `/api/v1` for entities + lookups
|
||
- [x] Tests: model, repository, service, API, permission, migration, validation, audit, tenant, docs
|
||
- [x] Docs: [crm-phase-6-1.md](crm-phase-6-1.md)
|
||
|
||
---
|
||
|
||
## Phase 6.2 — Enterprise Sales Process Engine ✅
|
||
|
||
- [x] Opportunity engine (number, title, revenue, probability, priority, close dates, soft delete, actors)
|
||
- [x] Unlimited pipelines + pipeline stages (start/won/lost/closed flags, required fields, exit validation)
|
||
- [x] Stage history, opportunity products (product_ref only), contact roles, competitors
|
||
- [x] Sales playbooks (versioned) + steps + assignments + completion tracking
|
||
- [x] Win/loss categories, reasons, immutable opportunity_win_loss snapshot
|
||
- [x] Rule-based forecasts (pipeline / weighted / committed; monthly/quarterly/annual)
|
||
- [x] Sales goals + targets with achievement %
|
||
- [x] Sales process definitions + sales_audit trail
|
||
- [x] Services / validators / events / permissions (`crm.pipelines|playbooks|forecasts|goals|targets.*`)
|
||
- [x] Alembic `0003_phase_62_sales_engine`; version `0.6.2.0`
|
||
- [x] API coverage for sales engine under `/api/v1`
|
||
- [x] Tests: pipeline, stage, playbook, forecast, win/loss, business rules, migration, permission, tenant, docs
|
||
- [x] Docs: [crm-phase-6-2.md](crm-phase-6-2.md)
|
||
|
||
---
|
||
|
||
## Phase 6.3 — Enterprise Sales Collaboration Platform ✅
|
||
|
||
- [x] Expanded sales activities (types, priority, CRM entity links, participants, reminders)
|
||
- [x] Tasks + checklists + completion tracking
|
||
- [x] Meetings + attendees + finish/outcome
|
||
- [x] Call logs (opportunity-linked) + call outcomes
|
||
- [x] Email threads/messages metadata only (no delivery)
|
||
- [x] Immutable sales timeline + timeline event links
|
||
- [x] Threaded/versioned comments, mentions, bookmarks, favorites
|
||
- [x] Sales team roles/members/assignments + notification preferences
|
||
- [x] Collaboration audit; events `crm.task|meeting|call|timeline|comment|mention.*`
|
||
- [x] Permissions `crm.tasks|meetings|calls|timeline|comments|mentions|team.*`
|
||
- [x] Alembic `0004_phase_63_collaboration`; version `0.6.3.0`
|
||
- [x] Tests + docs: [crm-phase-6-3.md](crm-phase-6-3.md)
|
||
|
||
### CRM Core Platform
|
||
|
||
- [x] Phases 6.0–6.3 complete (Foundation, Master Data, Sales Engine, Collaboration)
|
||
|
||
---
|
||
|
||
## Phase 7.0 — Loyalty Service Foundation ✅
|
||
|
||
- [x] `backend/services/loyalty` service scaffold (API / services / repositories / models)
|
||
- [x] Foundation aggregates: LoyaltyProgram, MembershipTier, Member, PointAccount, Reward, Campaign, LoyaltyAuditLog, OutboxEvent
|
||
- [x] No mutable balance on PointAccount — direct balance mutation forbidden (`extra=forbid`)
|
||
- [x] Optimistic locking on Program / Member / PointAccount; campaign `rule_version`
|
||
- [x] Publish-only events via transactional outbox (`loyalty.program|tier|member|point_account|reward|campaign.*`)
|
||
- [x] Loyalty APIs only (`/api/v1/programs|tiers|members|point-accounts|rewards|campaigns|audit`)
|
||
- [x] Platform provider contracts only (Notification, Analytics, Customer360, AI, ModuleIntegration, CRM, Communication, FileStorage)
|
||
- [x] Permissions `loyalty.*` trees with manage/view inheritance; tenant isolation via `X-Tenant-ID`
|
||
- [x] Alembic `0001_initial` + `loyalty_db` wiring (compose port 8004)
|
||
- [x] Soft-delete unique reclaim; IntegrityError → 409; null required-field → 422; production config guards
|
||
- [x] Enterprise validation & self-heal (incl. removal of incomplete 7.1 residue) — **52 tests passed**
|
||
- [x] Docs: [loyalty-phase-7-0.md](loyalty-phase-7-0.md), [loyalty-phase-7-0-audit.md](loyalty-phase-7-0-audit.md), ADR-011, module registry, phase area README
|
||
|
||
---
|
||
|
||
## Phase 8.0–8.10 — Enterprise Communication Platform ✅
|
||
|
||
- [x] Independent `communication-service` / `communication_db` (port 8005) — not owned by CRM/Loyalty/Restaurant
|
||
- [x] Provider framework + registry (mock, payamak; stubs for email/push/whatsapp/telegram/rubika/voice)
|
||
- [x] Communication router with priority, automatic failover, retry, circuit breaker
|
||
- [x] SMS platform: sender numbers, balance, rate limits, provider logs
|
||
- [x] Template engine: variables, locale, versioning, approval, preview, rendering
|
||
- [x] Dynamic contact sources (manual, CSV, CRM/Loyalty/Restaurant/Marketplace/Accounting/Website/External REST) — resolve only, no duplication
|
||
- [x] Queue engine: async queue, scheduling, priority, backoff retry, DLQ, batch
|
||
- [x] Delivery tracking: queued/sent/delivered/failed/expired/cancelled + timeline
|
||
- [x] OTP platform: generate/verify/expire, rate limit, brute-force lock, multi-channel path
|
||
- [x] Incoming provider webhooks with signature verification
|
||
- [x] Health `/health`, Capability `/capabilities`, providers status, monitoring stats
|
||
- [x] Permissions `communication.*`; events `communication.*`; audit on every send
|
||
- [x] Alembic `0001_initial`; version `0.8.10.0`
|
||
- [x] Tests: architecture, health/security, providers/SMS/failover/queue, templates/contacts/OTP/webhooks, validators
|
||
- [x] Docs: [communication-phase-8.md](communication-phase-8.md), ADR-012, module/provider registry, progress
|
||
|
||
---
|
||
|
||
## Phase AF — AI Development Framework ✅
|
||
|
||
> Documentation-only. No business functionality. No modifications to existing services, schemas, or APIs.
|
||
|
||
- [x] Permanent area [`docs/ai-framework/`](ai-framework/README.md)
|
||
- [x] Master prompt, development loop, phase handover, quality gates
|
||
- [x] Templates: phase, service, module, entity, repository, service-layer, API, event, testing, documentation
|
||
- [x] Manifests: [phase-manifest.yaml](ai-framework/phase-manifest.yaml), [service-manifest.yaml](ai-framework/service-manifest.yaml)
|
||
- [x] Prompt rules + Cursor guidelines
|
||
- [x] Docs index / module registry / progress integration
|
||
- [x] ADR-013 Accepted
|
||
- [x] Architecture, documentation, cross-reference, link, template, and manifest validation
|
||
|
||
---
|
||
|
||
## Phase SC-Reg — Sports Center Platform Registration ✅
|
||
|
||
> Documentation-only registration. No business code, models, APIs, migrations, or repositories.
|
||
|
||
- [x] Phase roadmap 9.0–9.10 registered in [phase-manifest.yaml](ai-framework/phase-manifest.yaml)
|
||
- [x] Service registered in [service-manifest.yaml](ai-framework/service-manifest.yaml)
|
||
- [x] Planned modules registered in [module-registry.md](module-registry.md#sports_center)
|
||
- [x] Sports terminology added to [glossary.md](glossary.md#sports-center)
|
||
- [x] Roadmap doc: [sports-center-roadmap.md](sports-center-roadmap.md)
|
||
- [x] ADR-014 Accepted — Independent Sports Center Platform
|
||
- [x] Module boundaries + phase area README updated
|
||
- [x] Manifest / cross-reference / documentation / module validation passed
|
||
|
||
---
|
||
|
||
## Phase 9.0 — Sports Center Platform Foundation ✅
|
||
|
||
- [x] `backend/services/sports_center` service scaffold (API / services / repositories / models)
|
||
- [x] Foundation aggregates: SportsCenter, Branch, Sport, MembershipType, Membership, Coach, SportsRole, SportsPermission, Facility, Court, Room, LockerRoom, Locker, DeviceProvider, Device, AttendanceGateway, SportsConfiguration, SportsEvent, SportsSetting, SportsAuditLog
|
||
- [x] Adapter-based connector framework (QR/RFID/Barcode/Fingerprint/Face/Turnstile/Door/Payment/Attendance) — interfaces only
|
||
- [x] Platform provider contracts only (Accounting, CRM, Loyalty, Communication, Notification, Storage, AI, Identity, Customer360)
|
||
- [x] Publish-only events (`sports_center.member|membership|coach|facility|device|attendance|locker.*`)
|
||
- [x] Sports APIs under `/api/v1` + device connect/disconnect + locker assign/release
|
||
- [x] Permissions `sports_center.*` trees; tenant isolation via `X-Tenant-ID`
|
||
- [x] Alembic `0001_initial` + `sports_center_db` wiring (compose port 8006)
|
||
- [x] Architecture / API / permissions / migration / dependency / connectors / docs tests
|
||
- [x] Docs: [sports-center-phase-9-0.md](sports-center-phase-9-0.md), [phase-handover/phase-9-0.md](phase-handover/phase-9-0.md), ADR-014, module registry
|
||
- [x] No business workflow engines (booking/attendance lifecycle deferred)
|
||
|
||
---
|
||
|
||
## Phase 9.1 — Sports Center Membership Catalog ✅
|
||
|
||
- [x] Catalog aggregates: SportCategory, AgeGroup, PricingModel, MembershipPackage, MembershipPlan, MembershipRule, RenewalPolicy, FreezingRule, ExpirationPolicy
|
||
- [x] MembershipType extended with catalog refs (package/plan/pricing/age/category/policies), transferability, sort order
|
||
- [x] Validators for age range, pricing/billing/rule kinds, money amounts, catalog ref integrity
|
||
- [x] Publish-only catalog events; permissions trees for catalog modules
|
||
- [x] APIs under `/api/v1/sport-categories|age-groups|pricing-models|membership-packages|membership-plans|membership-rules|renewal-policies|freezing-rules|expiration-policies`
|
||
- [x] `/capabilities` endpoint; version `0.9.1.0`
|
||
- [x] Alembic `0002_phase_91_membership_catalog`
|
||
- [x] Tests: catalog API, tenant isolation, age validation, architecture, docs
|
||
- [x] Docs: [sports-center-phase-9-1.md](sports-center-phase-9-1.md), [phase-handover/phase-9-1.md](phase-handover/phase-9-1.md)
|
||
- [x] No member enrollment / coach / attendance / booking engines
|
||
|
||
---
|
||
|
||
## Phase 9.2 — Sports Center Member Management ✅
|
||
|
||
- [x] Members aggregate + family members, emergency contacts, medical information shells
|
||
- [x] Membership assignment (`member_id`) consuming Phase 9.1 catalog types
|
||
- [x] Status management: activate / suspend / cancel / freeze / unfreeze
|
||
- [x] Membership cards (QR/physical/digital), digital membership passes, waivers (sign), member documents (Storage refs)
|
||
- [x] Validators, permissions (`sports_center.members.*` trees), publish-only events
|
||
- [x] Alembic `0003_phase_92_member_management`; version `0.9.2.0`
|
||
- [x] Tests: members API, tenant isolation, transitions, architecture, migration, docs
|
||
- [x] Docs: [sports-center-phase-9-2.md](sports-center-phase-9-2.md), [phase-handover/phase-9-2.md](phase-handover/phase-9-2.md)
|
||
- [x] No coach / attendance / booking engines
|
||
|
||
---
|
||
|
||
## Related Documents
|
||
|
||
- [Next Steps](next-steps.md)
|
||
- [Roadmap](roadmap.md)
|
||
- [Frontend docs](frontend/README.md)
|
||
- [docs/README.md](README.md)
|
||
- [CRM Phase 6.0](crm-phase-6-0.md)
|
||
- [CRM Phase 6.1](crm-phase-6-1.md)
|
||
- [CRM Phase 6.2](crm-phase-6-2.md)
|
||
- [CRM Phase 6.3](crm-phase-6-3.md)
|
||
- [Loyalty Phase 7.0](loyalty-phase-7-0.md)
|
||
- [Communication Phase 8](communication-phase-8.md)
|
||
- [Sports Center Phase 9.0](sports-center-phase-9-0.md)
|
||
- [Sports Center Phase 9.1](sports-center-phase-9-1.md)
|
||
- [Sports Center Phase 9.2](sports-center-phase-9-2.md)
|
||
- [Phase Handover 9.0](phase-handover/phase-9-0.md)
|
||
- [Phase Handover 9.1](phase-handover/phase-9-1.md)
|
||
- [Phase Handover 9.2](phase-handover/phase-9-2.md)
|
||
- [Sports Center Roadmap](sports-center-roadmap.md)
|
||
- [AI Development Framework](ai-framework/README.md)
|
||
- [ADR-013](architecture/adr/ADR-013.md)
|
||
- [ADR-014](architecture/adr/ADR-014.md)
|