HOCO B2B
Team tasksAnis

SRV-14 — CRM module — resellers, prospects, lifecycle, tasks

Reseller records, unique normalised phone, lifecycle automation from events, assignment, segments, interaction timeline, follow-up tasks, documents/photos, validation queue.

FieldDetails
Task codeSRV-14
PhaseP1 — V1 build & integration
Product scopeV1
StatusDone (Mon 19 Oct 2026)
StartMon 19 Oct 2026
DueMon 19 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsible—
Effort1.5 person-day(s) planned · 8 from scratch · size S
Area · appServer · server
Depends onSRV-10
UnblocksSRV-21, SRV-22, DSH-03, SRV-27
Milestones—

Summary

Reseller records, unique normalised phone, lifecycle automation from events, assignment, segments, interaction timeline, follow-up tasks, documents/photos, validation queue.

Description

HOCO's commercial follow-up runs today on calls and spreadsheets; the CRM module makes the reseller the shared record for the back-office, delegates and the reseller apps (cahier §4.2, §6.5; CRM-01…CRM-12). This task implements the reseller/prospect record with the minimum data set, creation from every source (ResellerSource) with the unique normalised phone and duplicate checks (admin.resellers.checkPhone, delegate.resellers.checkPhone), the 10-status lifecycle with manual transitions and automatic ones driven by events (invitation steps, sign-up, first order, visit reports), assignment to a delegate and zone with history, segments, the unified interaction timeline, follow-up tasks with due dates and notifications, protected documents and photos, the validation queue (approve/reject with reason, review of the declared customer type, AUTH-11), list/map/export, and the reseller's own profile and addresses. Out of scope: field visits (SRV-21), invitations (SRV-22) and the CRM pages (DSH-03).

Subtasks

#SubtaskOwner
1Reseller record CRUD (admin.resellers.create/get/update) with source, owner, store, contact, wilaya/commune, address, GPS, business type, potentialAnis
2Duplicate prevention on every path: E.164 normalisation, unique constraint, checkPhone endpoints returning the existing record summary (CRM-03)Anis
3Lifecycle service: manual transitions (admin.resellers.setStatus) and event consumers (invitation.app_installed, account.created, order.first, visit.reported) writing ResellerStatusChangeAnis
4Assignment to delegate and zone with ResellerAssignment history and notification to the new delegate (admin.resellers.assign, bulk)Anis
5Validation queue: admin.resellers.validation.list/validate, approve or reject with reason, review and optional change of customerType (audited), account status updateAnis
6Segments (rule-based on potential, business type, brands sold, activity; ResellerSegment refreshed by a job) and admin.segments.crudAnis
7Interaction timeline (admin.resellers.timeline) fed by visits, notes, orders, payments, claims and status changesAnis
8CrmTask follow-ups: admin.tasks., delegate.tasks., due-date reminders through notifications (CRM-08)Anis
9Documents and photos (ResellerDocument, ResellerPhoto) on private files; list/map queries with filters and async exportAnis
10Reseller self-service: profile.get/update (customerType read-only), documents, addresses CRUD and setDefaultAnis

Deliverables

  • apps/server/src/modules/crm/{resellers,lifecycle,assignment,validation,segments,timeline,tasks,documents,profile}.{service,router}.ts
  • packages/contracts/src/{profile.ts,admin/crm.ts}
  • Event consumers apps/server/src/modules/crm/consumers.ts

Acceptance criteria

  • Creating a reseller with an existing normalised phone from any source returns 409 RESELLER_PHONE_EXISTS with the existing reseller id (CRM-03)
  • A first order moves the reseller to FIRST_ORDER automatically with a ResellerStatusChange entry (CRM-04)
  • Approving an account sets AccountStatus ACTIVE and notifies the reseller; rejecting requires a reason (CRM-09)
  • A reseller calling profile.update with customerType gets 403 FIELD_NOT_EDITABLE; a back-office change is audited with old and new values (AUTH-11)
  • The timeline lists visits, notes, orders, payments and claims in chronological order (CRM-07)
  • A delegate sees only resellers in their zones or assigned to them (ACL-03)

Requirements covered

RequirementTitleRelease
CRM-01Reseller/prospect record with the minimum data set (store, owner, phone, WhatsApp, email, wilaya, commune, address, GPS, type, potential, delegate, photos, documents, status)V1
CRM-02Creation from the back-office, the delegate app, reseller self sign-up or import, with the source recordedV1
CRM-03Duplicate prevention: the main phone number is unique (normalised); duplicate check on every creation pathV1
CRM-04Reseller lifecycle (10 statuses) with automatic and manual transitions and full historyV1
CRM-05Assignment to a delegate and a zone; link to the creating delegate; reassignment historyV1
CRM-06Segmentation by potential, business type, brands sold, level and activityV1
CRM-07Unified interaction history: calls, visits, notes, orders, payments, claimsV1
CRM-08Follow-ups (relances), tasks and next actions with due dates and notificationsV1
CRM-09Account validation by an authorised user (approve / reject with reason)V1
CRM-10Store photos and documents (façade, interior, RC, NIF, ID) with protected accessV1
CRM-11CRM list and map views with filters (status, zone, wilaya, commune, delegate, segment, potential, activity) and exportV1
CRM-12Reseller 360° page: orders, invoices, payments, visits, reports, tasks, interactionsV1

Screens

ScreenNameApp
BO-09Resellers & prospects listBO
BO-10Resellers mapBO
BO-11Reseller 360°BO
BO-12Reseller create / editBO
BO-13Account validation queueBO
BO-14Follow-ups & tasksBO
BO-15SegmentsBO

API surface

Test measures

  • DB tests for duplicate prevention across back-office, delegate and self-sign-up paths
  • Event-driven lifecycle tests (emit events, assert transitions and history)
  • Contract tests for list filters and pagination

Risks

  • Automatic lifecycle transitions conflict with manual ones — manual statuses NOT_INTERESTED and SUSPENDED are never overridden by automation

KPI

  • Delivered by Mon 19 Oct 2026 within 1.5 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page