Implemented KYB, compliance decisions, integration, and testing

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 21:31:42 +03:00
parent 382f6e8841
commit 1f8721e742
36 changed files with 2279 additions and 233 deletions
+16
View File
@@ -75,3 +75,19 @@ No staff registration, merchant deletion UI, merchant portal, uploads, payment p
- [x] Retained form values on failure, accessible controls and bilingual feedback
Verification: all 32 integration tests passed against the isolated PostgreSQL service, including role/stage rejection cases, filters, creation, races and injected transaction rollback. All 19 browser tests passed, covering EN/RU at mobile and desktop sizes, real API creation/filtering/history, pipeline progression and rejection, ownership isolation, stale-editor preservation and the existing compliance journeys. Build, lint, typecheck, 17 unit tests, formatting and whitespace checks passed. The additive sales migration was applied to development without a reset or reseed.
## Gated onboarding completion
- [x] Three current KYB collection records: company registration, ownership structure and authorized-representative identification; legacy requirements remain read-only history
- [x] Sales collection status/notes restricted to Head or assigned Manager in KYB, with received-history submission evidence and pending-review locks
- [x] Compliance-only approval with risk/rationale, actionable corrections stored separately from collection notes, and rejection with a reason
- [x] Numbered immutable review snapshots and outcomes; only the latest current-policy approval authorizes activation; open forms remain bound to their original cycle
- [x] Four persisted demo activation checks with stage-specific editing, approved-cycle attribution and change history; no external payment/processing calls
- [x] Compliance queue with pending/filtered counts, elapsed waiting time, URL-persisted search/manager/age filters and direct review-cycle links
- [x] Server-derived next owner, required action and specific blockers; distinct business closure and Compliance decisions; responsive EN/RU UI
- [x] Additive legacy upgrade and explicit return-to-KYB recovery; existing decisions and collection history remain unchanged
- [x] Fresh fixture approval/check evidence, preserved existing fixture edits and passwords, and repeatable seed behavior
Verification: 41 integration tests passed, including a populated legacy-schema migration, correction/resubmission, stale decisions, older approval/check evidence, concurrent writes, authorization bypasses, queue filters and transaction rollback. All 20 unit/contract/localization tests, build, lint, typecheck, formatting and whitespace checks passed. All 24 browser tests passed. Browser verification covers the complete successful journey through Live, rejection, conflict preservation, direct review links, queue filtering, EN/RU and mobile/desktop layouts. Screenshots were visually inspected.
Applied migrations `202609240005_gated_onboarding` and `202609240006_kyb_upgrade` to development without a reset or reseed. Before/after checksums confirmed original company data, review decisions/snapshots, collection notes/history, activities, stage events, tasks and password hashes were unchanged for all 45 merchants. Only new missing representative records and unfinished merchant concurrency versions were added. Local health, authentication, detail capabilities and queue authorization passed for all four demo accounts; smoke-test sessions were signed out afterward.
+10 -4
View File
@@ -12,13 +12,13 @@ NestJS authorization and database predicates apply to all reads, searches, count
New Lead → Contacted → Qualified → KYB → Compliance Review → Integration → Testing → Live. Rejected is an alternate terminal outcome; neither Live nor Rejected has outgoing stage actions. The same merchant ID persists throughout.
Assignment is required before leaving New Lead and before entering KYB. Contacted requires a persisted call or email; a note or meeting does not qualify. Qualified requires company name, website, primary contact name/email, country, industry and estimated monthly volume (zero is valid). Head or the assigned Manager may reject New Lead, Contacted or Qualified with a reason. Only Head may close KYB, Integration or Testing for a recorded business reason; this preserves any compliance decision. Only Compliance can decide rejection during Compliance Review. Sales collects the four KYB documents. All must have received-history evidence before submission creates a pending review. Reviewed company/KYB fields freeze during review. Compliance approval advances to Integration; rejection requires a reason; corrections require a reason and item-specific notes and return the merchant to KYB. Resubmission creates another review cycle. Decisions are immutable.
Assignment is required before leaving New Lead and before entering KYB. Contacted requires a persisted call or email; a note or meeting does not qualify. Qualified requires company name, website, primary contact name/email, country, industry and estimated monthly volume (zero is valid). Head or the assigned Manager may reject New Lead, Contacted or Qualified with a reason. Only Head may close KYB, Integration or Testing for a recorded business reason; this preserves any compliance decision. Only Compliance can decide rejection during Compliance Review. Head or the assigned Manager collects three KYB checklist records: company registration, ownership structure and authorized-representative identification. These are collection statuses and notes, not uploaded files. All must have received-history evidence before submission creates a pending review. Reviewed company/KYB fields freeze during review. Compliance approval requires a Low/Medium/High risk level and nonblank rationale and advances to Integration; rejection requires a reason; corrections require a reason and immutable item-specific notes separate from Sales collection notes and return the merchant to KYB. Resubmission creates another review cycle. Decisions are immutable.
Reviewed company identity, website, country, industry and KYB items remain locked after approval. Contact details, volume estimates, source and authorized ownership can change. Head or the assigned manager may advance Integration → Testing → Live only with matching approval/checklist evidence. Reassignment transfers open commercial tasks, preserving completed attribution and personal Compliance tasks.
Reviewed company identity, website, country, industry and KYB items remain locked after approval. Contact details, volume estimates, source and authorized ownership can change. Head or the assigned manager may advance Integration → Testing only with a valid latest-cycle approval and completed API-connection/webhook-setup demo checks. Testing → Live additionally requires passing test-payment and reconciliation demo checks. Check states, notes, actors and timestamps are persisted against the approved review cycle, with immutable change history. Checks can be edited only during their own stage. No real payments or external processing calls occur. An old approval or check result cannot satisfy a newer cycle. Reassignment transfers open commercial tasks, preserving completed attribution and personal Compliance tasks.
## Journeys and records
Landing → email/password login → role-scoped dashboard → merchant search/filter → detail, editing, assignment, checklist, reviews, interactions, history and tasks. The directory searches company, contact, email and website and combines stage, country, industry and authorized owner filters with eight-record pagination. Search/filter/page state is stored in the URL. Head and Compliance may filter by manager or Unassigned; Managers remain scoped to their own merchants. Desktop uses tables and pipeline columns; mobile uses directory cards and exactly one selected pipeline stage. Detail has URL-addressable Overview, Activity, Onboarding and Tasks tabs; Activity merges notes, interactions, ownership, stage events and compliance outcomes into one newest-first history. Explicit stage controls display server-derived blocking reasons. Pipeline, Tasks and Compliance Review Queue provide dedicated views. Tasks can be created, edited and completed from merchant details; reminders stay in the app.
Landing → email/password login → role-scoped dashboard → merchant search/filter → detail, editing, assignment, checklist, reviews, interactions, history and tasks. The directory searches company, contact, email and website and combines stage, country, industry and authorized owner filters with eight-record pagination. Search/filter/page state is stored in the URL. Head and Compliance may filter by manager or Unassigned; Managers remain scoped to their own merchants. Desktop uses tables and pipeline columns; mobile uses directory cards and exactly one selected pipeline stage. Detail has URL-addressable Overview, Activity, Onboarding and Tasks tabs; Activity merges notes, interactions, ownership, stage events and compliance outcomes into one newest-first history. Explicit stage controls display server-derived blocking reasons. Pipeline, Tasks and Compliance Review Queue provide dedicated views. The Compliance-only queue shows total pending and filtered counts, elapsed waiting time, manager/search/24-hour/72-hour filters stored in the URL, and links to individual review cycles. Merchant detail shows the next owner, required action and server-derived blockers; commercial closure remains visibly distinct from Compliance rejection. Tasks can be created, edited and completed from merchant details; reminders stay in the app.
Staff creation requires company name, primary-contact name and email; website, country, industry and volume may be completed later. Merchants include company and primary-contact details, website, country, industry, decimal USD volume estimates, source, nullable manager, stage, timestamps and a concurrency version. Related models retain activities, stage events, checklist changes, review snapshots and task attribution. Mutations and audit history commit atomically and reject stale versions.
@@ -26,7 +26,7 @@ Staff creation requires company name, primary-contact name and email; website, c
The public landing page introduces merchant crypto-payment onboarding in EN/RU with an inline consultation form. Company name, contact name, work email, website, country, industry and estimated monthly USD volume are required. Industries include Other; zero is a valid volume estimate. The staff-login link remains available on mobile.
`POST /api/public/leads` requires a trusted Origin and a UUID `Idempotency-Key`. Accepted submissions atomically create an unassigned New Lead with source `LANDING_PAGE`, four missing KYB items, an initial stage event and a system-attributed creation activity. Database uniqueness prevents duplicate records on retries, including concurrent requests and API restarts. A changed payload under the same key returns a conflict. Filled honeypots receive the same generic acceptance without creating records.
`POST /api/public/leads` requires a trusted Origin and a UUID `Idempotency-Key`. Accepted submissions atomically create an unassigned New Lead with source `LANDING_PAGE`, three missing KYB checklist records, an initial stage event and a system-attributed creation activity. Database uniqueness prevents duplicate records on retries, including concurrent requests and API restarts. A changed payload under the same key returns a conflict. Filled honeypots receive the same generic acceptance without creating records.
The endpoint validates on the server and uses bounded process-local IP/email limits. The form preserves inputs after errors, translates field feedback, announces submission states and respects Retry-After. Lead details remain in component memory; only language is stored in the browser. No external notifications are sent.
@@ -43,3 +43,9 @@ Seeding uses stable IDs, a stored date anchor and a version marker. It preserves
English is the default; EN/RU selection persists in browser storage. Dates use the selected locale and viewer's time zone. Names and notes remain verbatim; canonical status/role labels are translated. Retain the light neutral UI, lime accents, visible focus, touch-sized controls and reduced-motion support.
No merchant deletion UI, staff registration, merchant self-service, real payments, external KYB integration, uploads, external notifications or deployment.
## Current requirements and historical records
Review policy version 2 uses the three current KYB requirements. Legacy beneficial-owner ID and business-activity checklist records and every historical review snapshot/decision remain readable and unchanged. Additive migrations mark old cycles as version 1, leave their risk unset, and add a missing authorized-representative item to unfinished merchants. No previous identification is reinterpreted and no approval or demo result is invented.
Legacy pending cycles may receive corrections or rejection but cannot be approved under obsolete requirements. Head or the assigned Manager can explicitly return legacy Integration/Testing merchants to KYB for collection and a fresh review. This audited exception preserves prior approvals. Current-policy approvals lock reviewed fields; Live and Rejected remain terminal.