# event-lead-capture Specification ## Purpose Staff capture leads at an event, learn whether each person is new or already known, and work through the event's leads. ## Requirements ### Requirement: Choose an event The system SHALL let a user with `BO_EVENT_LEADS` choose among the company's enabled events to capture and list leads. Capturing a lead for a disabled event SHALL be refused. #### Scenario: Only enabled events offered - **GIVEN** an enabled event `KL Food Fair 2027` and a disabled event `Penang Expo` - **WHEN** a user with `BO_EVENT_LEADS` opens Event leads - **THEN** `KL Food Fair 2027` is offered and `Penang Expo` is not #### Scenario: Disabled event refuses capture - **WHEN** a lead is submitted for a disabled event - **THEN** the capture is refused and nothing is saved #### Scenario: No module - **WHEN** a user without `BO_EVENT_LEADS` opens Event leads or calls an event-leads endpoint - **THEN** the page shows not-authorised and the endpoint responds 403 ### Requirement: Contact normalisation The system SHALL require a mobile number, an email, or both, for every captured lead, and a name. The system SHALL normalise a mobile number to E.164, treating a number without a country code as Malaysian (+60), and SHALL refuse a number that is not valid. The system SHALL trim and lowercase an email and refuse one that is not an email address. #### Scenario: Malaysian formats are one number - **WHEN** staff enter `012-345 6789`, `0123456789`, `+60 12-345 6789` or `60123456789` - **THEN** each is stored and matched as `+60123456789` #### Scenario: Email case and spaces - **WHEN** staff enter ` Aisyah@Example.COM ` - **THEN** it is stored and matched as `aisyah@example.com` #### Scenario: Neither mobile nor email - **WHEN** staff submit a lead with no mobile and no email - **THEN** the capture is refused and both fields are named #### Scenario: Invalid mobile - **WHEN** staff enter `12345` as the mobile - **THEN** the capture is refused with a message on the mobile field ### Requirement: New or existing lead The system SHALL show, before capture, the company's leads matching the entered mobile or email. A capture with no match or as a different person SHALL create a new lead marked NEW. A capture of a picked match SHALL be marked EXISTING and SHALL fill only that lead's blank fields. The mark SHALL never be recalculated. The lead and its event lead SHALL be saved together or not at all. #### Scenario: First time seen - **GIVEN** no lead with mobile `+60123456789` - **WHEN** staff capture `Aisyah` with `0123456789` at `KL Food Fair 2027` - **THEN** a new lead is created and the event lead is NEW #### Scenario: Known person picked - **GIVEN** a lead `Aisyah` with mobile `+60123456789` and no email, captured at an earlier event - **WHEN** staff enter `012-345 6789` and `aisyah@example.com`, and pick `Aisyah` from the matches - **THEN** the event lead is EXISTING - **AND** the lead now has email `aisyah@example.com` and its name is unchanged #### Scenario: Stored values are not overwritten - **GIVEN** a lead with company `Acme` - **WHEN** staff pick that lead and enter company `Other Co` - **THEN** the lead's company stays `Acme` #### Scenario: Mobile and email match different people - **GIVEN** lead `A` with mobile `+60123456789` and lead `B` with email `b@example.com` - **WHEN** staff enter that mobile and that email - **THEN** both `A` and `B` are shown as matches and nothing is merged #### Scenario: Different person - **GIVEN** a lead with mobile `+60123456789` - **WHEN** staff choose a different person and capture `Ahmad` with that mobile - **THEN** a second lead `Ahmad` is created and the event lead is NEW #### Scenario: Already captured at this event - **GIVEN** `Aisyah` is already captured at `KL Food Fair 2027` - **WHEN** staff enter her mobile there again - **THEN** the match shows she is already captured and offers to open that event lead - **AND** a capture of her at the same event is refused without creating anything ### Requirement: Salesperson from the event team The system SHALL let staff set an event lead's salesperson, which MAY be empty. A salesperson newly set on an event lead SHALL be an active member of that event's team. A salesperson already set SHALL remain allowed after they leave the team or are deactivated. #### Scenario: Team member assigned - **GIVEN** `KL Food Fair 2027` has `sales1` and `sales2` on its team - **WHEN** staff capture a lead with salesperson `sales2` - **THEN** the event lead's salesperson is `sales2` #### Scenario: Outsider refused - **GIVEN** `sales3` is not on the team of `KL Food Fair 2027` - **WHEN** staff set `sales3` as an event lead's salesperson there - **THEN** the save is refused with a message on the salesperson field #### Scenario: Salesperson later removed from team - **GIVEN** an event lead whose salesperson is `sales1` - **WHEN** `sales1` is removed from the event's team and staff edit the lead's status - **THEN** the save succeeds and the salesperson stays `sales1` ### Requirement: Event leads listing The system SHALL list one event's leads, newest capture first, paginated on the server, showing name, mobile, email, NEW or EXISTING, salesperson, temperature, status, interests and next follow-up date. The listing SHALL be filterable by salesperson, temperature, status, interest and NEW or EXISTING, and SHALL be usable at phone width. #### Scenario: Filter by temperature - **GIVEN** a HOT lead and a COLD lead at an event - **WHEN** staff filter by HOT - **THEN** only the HOT lead is listed #### Scenario: Filter by interest - **GIVEN** a lead tagged `Cookware` and a lead tagged `Kitchen appliances` - **WHEN** staff filter by `Cookware` - **THEN** only the lead tagged `Cookware` is listed #### Scenario: Phone width - **WHEN** staff open the listing on a 360 px wide screen - **THEN** each lead shows as a card with name, mobile, NEW or EXISTING, temperature, status and next follow-up, with no sideways scrolling ### Requirement: Event lead edit The system SHALL let staff with `BO_EVENT_LEADS` change an event lead's salesperson, temperature, status, interests, next follow-up date and notes. Temperature SHALL be HOT, WARM, COLD or empty. Status SHALL be OPEN, CONTACTED, QUALIFIED, WON or LOST, and a new event lead SHALL be OPEN. Only active interests SHALL be newly added; an inactive interest already on the event lead SHALL stay until removed. #### Scenario: Work a lead - **GIVEN** an OPEN event lead - **WHEN** staff set status CONTACTED, temperature HOT and next follow-up 2027-01-20 - **THEN** the listing shows CONTACTED, HOT and 20/01/2027 for that lead #### Scenario: Inactive interest kept - **GIVEN** an event lead tagged `Cookware`, and `Cookware` is then deactivated - **WHEN** staff change the lead's status - **THEN** the save succeeds and the lead is still tagged `Cookware` ### Requirement: Event lead status history The system SHALL record every change of an event lead's status with the previous status, the new status, the time and the user who made it. Capturing an event lead SHALL record its first status with no previous status, at the capture time. An edit that leaves the status unchanged SHALL record nothing. The history SHALL never be edited or deleted through the application. #### Scenario: Capture records the first status - **WHEN** staff capture a lead at an event with no status chosen - **THEN** the history holds one entry from no status to OPEN at the capture time, by that user #### Scenario: Status change recorded - **GIVEN** an OPEN event lead - **WHEN** staff change its status to CONTACTED and later to WON - **THEN** the history holds OPEN to CONTACTED and CONTACTED to WON, each with its time and user #### Scenario: Edit without a status change - **GIVEN** a CONTACTED event lead - **WHEN** staff change only its temperature and notes - **THEN** no history entry is added