SRV-21 — Field operations module — objectives, tours, visits, reports
Objectives, tour planning and lifecycle, visits with GPS check-in tolerance, checklists, photos, structured reports that create follow-ups, location pings, closing summary/KPIs, recommended visit order.
| Field | Details |
|---|---|
| Task code | SRV-21 |
| Phase | P1 — V1 build & integration |
| Product scope | V1 |
| Status | Done (Mon 19 Oct 2026) |
| Start | Mon 19 Oct 2026 |
| Due | Mon 19 Oct 2026 |
| Responsible | Anis — Full-stack developer |
| Co-responsible | — |
| Effort | 2.5 person-day(s) planned · 10 from scratch · size M |
| Area · app | Server · server |
| Depends on | SRV-14 |
| Unblocks | SRV-23, SRV-26, DSH-08, SRV-25 |
| Milestones | — |
Summary
Objectives, tour planning and lifecycle, visits with GPS check-in tolerance, checklists, photos, structured reports that create follow-ups, location pings, closing summary/KPIs, recommended visit order.
Description
Field operations are the second pillar of the cahier (§4.5, §6.1–§6.9; FLD-01…FLD-17, FLD-19): delegates follow planned tours, check in at points of sale, run checklists, take photos, write structured reports and close their day, while the back-office follows them live. This task implements objectives per delegate and period (ObjectiveMetric, ObjectivePeriod), tour planning with ordered stops, priorities, time slots and ordering mode (IMPOSED/RECOMMENDED with a nearest-neighbour recommendation), the TourStatus lifecycle (only the assigned delegate starts it; suspend/resume with reason), visits with the VisitStatus lifecycle and GPS check-in tolerance (150 m with accuracy ≤ 100 m by default), checklists per visit type, mandatory photos by type, notes, the structured VisitReport that creates follow-up CrmTasks automatically, not-done reasons, visit locking and unlock, location pings only while a tour is IN_PROGRESS (90-day retention), closing preview and definitive close with reopen, and delegate home, performance and reports. Business days are computed in Africa/Algiers. Out of scope: offline replay mechanics (SRV-23), invitations (SRV-22), field pages (DSH-08).
Subtasks
| # | Subtask | Owner |
|---|---|---|
| 1 | Objectives per delegate and period with progress computation (visits, sign-ups, installs, first orders, orders, revenue) and admin.objectives.crud | Anis |
| 2 | Tour planning: admin.tours.create/update/setStops (order, priority, time slot), TRN numbering, delegate notification | Anis |
| 3 | Recommended order (nearest-neighbour from the start point) via admin.tours.recommendOrder and delegate.tours.reorder when RECOMMENDED | Anis |
| 4 | Tour lifecycle PLANNED → TO_START → IN_PROGRESS ↔ SUSPENDED → COMPLETED / CANCELLED with TourStatusChange and TOUR_SUSPEND_REASON | Anis |
| 5 | Visit flow: arrive (distance vs field.checkInToleranceMeters, accuracy vs field.gpsMaxAccuracyMeters → 422 CHECKIN_OUT_OF_TOLERANCE unless allowed and flagged), start, checklist, note, photos, end, notDone with VISIT_NOT_DONE_REASON; VIS numbering | Anis |
| 6 | VisitType and ChecklistTemplate configuration (admin.visitTypes.crud, admin.checklists.crud) incl. mandatory photos per type | Anis |
| 7 | VisitReport (person met, interest, products and promotions presented, VISIT_ISSUE_TAG, NextAction, follow-up date) creating a CrmTask and an Interaction | Anis |
| 8 | Visit lock after end and admin.visits.unlock within field.visitUnlockHours; ad-hoc visits delegate.tours.addVisit | Anis |
| 9 | Location pings (sync.locationPings) accepted only while IN_PROGRESS; purge job after 90 days; admin.tours.track and admin.live.delegates | Anis |
| 10 | Closing preview and close (all visits DONE or NOT_DONE with reasons, pending sync = 0, comment, summary KPIs); admin.tours.reopen within field.reopenMaxDays | Anis |
| 11 | Delegate home, profile, zone, objectives, performance and reports endpoints; admin.delegates.crud and performance | Anis |
| 12 | Review of tour/visit payloads and offline-relevant fields for the delegate app | Imad |
Deliverables
- apps/server/src/modules/field/{objectives,tours,visits,checklists,reports,location,closing,delegates}.{service,router}.ts and jobs.ts
- packages/contracts/src/{delegate/day.ts,delegate/tours.ts,admin/field.ts}
- Field rules page /docs/srs/business-rules (field section) confirmed with the settings keys
Acceptance criteria
- Only the assigned delegate can start a tour; another delegate gets 403 OUT_OF_SCOPE (FLD-04)
- A check-in 220 m from the store with tolerance 150 m returns 422 CHECKIN_OUT_OF_TOLERANCE unless out-of-tolerance check-in is allowed, in which case the visit is flagged (FLD-07, FLD-08)
- Ending a visit of a type with mandatory photos and no photo returns 422 VISIT_PHOTO_REQUIRED; a not-done visit without reason is refused (FLD-08, FLD-09)
- A report with next action PHONE_FOLLOW_UP and a date creates a CrmTask for the delegate due that date (FLD-10)
- Closing a tour with visits still PLANNED returns 422 TOUR_HAS_OPEN_VISITS; a closed tour is read-only unless reopened (FLD-12)
- Location pings outside an IN_PROGRESS tour are rejected and pings older than 90 days are purged (FLD-15)
- The recommended order is the nearest-neighbour sequence from the start point (FLD-17)
Requirements covered
| Requirement | Title | Release |
|---|---|---|
| FLD-01 | Delegate accounts and profiles; assignment of wilayas, communes and points of sale | V1 |
| FLD-02 | Objectives per delegate and period: visits, sign-ups, app installs, orders, revenue | V1 |
| FLD-03 | Tour planning: daily, weekly or monthly; ordered stops (imposed or recommended); priorities and time slots | V1 |
| FLD-04 | Tour lifecycle (planned, to start, in progress, suspended, completed, cancelled); only the assigned delegate starts it | V1 |
| FLD-05 | Delegate home: today's tour, counters, objectives, conversion rate, quick access | V1 |
| FLD-06 | Tour programme: list and map show the same visits in the same order; filters, delays, priorities | V1 |
| FLD-07 | Map and navigation: position, next destination with ETA and distance, external GPS navigation, arrival confirmation within tolerance | V1 |
| FLD-08 | Visit and check-in: time and position at check-in, duration, checklist, note, photos (mandatory by visit type), call; finished visit locked | V1 |
| FLD-09 | A visit not carried out requires a reason | V1 |
| FLD-10 | Structured visit report (person met, interest, products and promotions presented, issues, next action, follow-up date, attachments) that triggers the follow-up | V1 |
| FLD-11 | Field reseller sign-up with GPS and façade photo, offline-capable, linked to the creating delegate, pending validation | V1 |
| FLD-12 | Tour closing: day summary, comment, objectives and conversion, final report; requires reasons and synced data; definitive unless reopened | V1 |
| FLD-13 | Live follow-up in the back-office: delegates on tour, positions, visit progress | V1 |
| FLD-14 | Back-office analysis of visit reports and validation of new points of sale | V1 |
| FLD-15 | Location policy: consent, frequency, tolerance and retention configurable and transparent | V1 |
| FLD-16 | Visit types and checklist templates configuration | V1 |
| FLD-17 | Recommended visit order (nearest-neighbour heuristic) | V1 |
| FLD-19 | Delegate reports history and own performance over periods | V1 |
Screens
| Screen | Name | App |
|---|---|---|
| BO-16 | Delegates list | BO |
| BO-17 | Delegate detail & performance | BO |
| BO-20 | Objectives | BO |
| BO-21 | Tour planner (calendar) | BO |
| BO-22 | Tour editor (stops, order, recommendation) | BO |
| BO-23 | Tour live detail | BO |
| BO-24 | Visits list | BO |
| BO-25 | Visit detail | BO |
| BO-26 | Visit types & checklist templates | BO |
API surface
| Endpoint group | Operations |
|---|---|
| Delegate home, profile, objectives & reports | 6 |
| Tours & visits | 19 |
| Prospects, points of sale, follow-ups & invitations | 13 |
| Field operations | 20 |
Test measures
- Unit tests for tolerance, nearest-neighbour ordering and Africa/Algiers day boundaries
- DB tests for tour and visit lifecycles including suspend/resume and reopen
- E2E with the delegate app on staging: full tour from start to close
Risks
- GPS accuracy in dense urban areas or indoors exceeds 100 m — allow-out-of-tolerance setting with a flag reviewed in the back-office instead of blocking the delegate
- Battery drain from location sampling — sampling only during IN_PROGRESS, every 5 min or 200 m, documented for Imad
KPI
- Delivered by Mon 19 Oct 2026 within 2.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.
SRV-39 — Smart notifications — contract & schema (groups, actions, flash sales, complementary products)
Additive contract and Prisma changes for document 03: NotificationGroup and AnnouncementKind enums, group and action on notifications and templates, per-group preferences, Promotion.isFlashSale, ProductComplement, Product.announceAsNew/publishedAt, announcement targets, query and response fields.
SRV-22 — Invitations & attribution module
Invitation codes, signed links and QR payloads, share texts, Play install-referrer attribution, funnel events up to the first order.