Files
ngqileandClaude Opus 5.5 c7989e8f2f docs(openspec): archive add-lead-listing-export
Adds the lead-records and lead-export main specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-27 17:36:11 +08:00

4.3 KiB

lead-records Specification

Purpose

Staff see every lead in the company, look up a person's history across events, and correct a lead's details without merging people.

Requirements

Requirement: Lead listing

The system SHALL let a user with BO_LEADS list every lead in their own company and no other. Each row SHALL show name, mobile, email, company, the number of events the lead was captured at, the last event (the event of its most recent capture) and the latest salesperson (from the most recent capture that has one). The list SHALL be ordered by most recent capture first and paged on the server.

Scenario: Counts and latest values

  • GIVEN lead Aisyah was captured at KL Food Fair with salesperson Ali, then at Penang Expo with no salesperson
  • WHEN a user with BO_LEADS opens Leads
  • THEN Aisyah's row shows 2 events, last event Penang Expo, and latest salesperson Ali

Scenario: Other company's leads hidden

  • GIVEN a lead belongs to another company
  • WHEN a user lists or searches leads
  • THEN that lead is never returned

Scenario: No module

  • WHEN a user without BO_LEADS opens Leads or a lead detail page, or calls a leads endpoint
  • THEN the page shows not-authorised and the endpoint responds 403

The Lead Listing SHALL be searchable by one term matching name, mobile or email. A term made of digits and phone punctuation SHALL match mobiles regardless of a leading 0, +60, spaces or dashes.

Scenario: Search by mobile in local format

  • GIVEN a lead with mobile +60123456701
  • WHEN the user searches 012-345 6701
  • THEN that lead is listed

Scenario: Search by name or email

  • WHEN the user searches aisyah
  • THEN leads whose name or email contains aisyah, ignoring case, are listed

Requirement: Lead detail

The system SHALL show a lead's details:

  • Fields: name, mobile, email, company, job title and notes.
  • Event history: every event the lead was captured at, newest capture first, with the event name and dates, lead type, salesperson, temperature, status and capture date.
  • Shared contacts: when another lead in the company has the same mobile or the same email, the page SHALL warn and name each such lead. The leads SHALL NOT be merged.
  • Width: the page SHALL work at phone width.

Scenario: Event history

  • GIVEN a lead captured at two events
  • WHEN a user with BO_LEADS opens the lead
  • THEN both events are listed, newest capture first, each with its lead type, salesperson, temperature and status

Scenario: Shared mobile warning

  • GIVEN leads Test Visitor One and Test Visitor Two both have mobile +60123456701
  • WHEN a user opens Test Visitor One
  • THEN the page warns that Test Visitor Two has the same mobile
  • AND both leads stay separate

Scenario: Unknown or other company's lead

  • WHEN a user opens a lead uuid that does not exist in their company
  • THEN the page shows not-found and the endpoint responds 404

Requirement: Lead edit

The system SHALL let a user with both BO_LEADS and BO_LEADS_EDIT change a lead's name, mobile, email, company, job title and notes, with the same normalisation, required fields, length limits and errors as capture. A save that gives the lead the same mobile or email as another lead SHALL be allowed and SHALL NOT merge them. A user without BO_LEADS_EDIT SHALL see the lead read-only.

Scenario: Correct a lead

  • WHEN a user with BO_LEADS_EDIT changes the email to Aisyah@Example.TEST and the company to Example Co, and saves
  • THEN the lead stores aisyah@example.test and Example Co

Scenario: Save that shares a contact

  • GIVEN another lead has mobile +60123456701
  • WHEN the user sets this lead's mobile to 0123456701 and saves
  • THEN the save succeeds and the shared-mobile warning names the other lead

Scenario: Invalid input refused

  • WHEN the user clears both mobile and email, or enters mobile 12, and saves
  • THEN the save is refused, nothing changes, and the error shows under the field

Scenario: Read-only without edit permission

  • WHEN a user with BO_LEADS but not BO_LEADS_EDIT opens a lead, or calls the lead update endpoint
  • THEN the page shows no edit controls and the endpoint responds 403