Files
co-lite/openspec/changes/add-lead-listing-export/proposal.md
T

4.0 KiB

Proposal

Why

Change 4a lets staff capture leads at an event and work them one event at a time. Staff still cannot see a person across events, correct a lead's details, or take a list out to work it elsewhere. This is change 4b of the design's change 4 (see docs/superpowers/specs/2026-11-26-co-lite-foundation-and-leads-design.md, Listings and Access). It completes what go-live needs for leads.

What Changes

  • Lead Listing (/leads): every lead in the company in one list. Search by name, mobile or email. Each row shows name, mobile, email, company, number of events, last event and latest salesperson, all worked out when the list is read. Server-side paging, newest capture first.
  • Lead detail (/leads/{leadUuid}): the lead's fields, plus its event history. The history lists every event the lead was captured at, newest first, with lead type, salesperson, temperature and status. When another lead in the company shares this lead's mobile or email, the page shows a warning naming that lead. Nothing is merged.
  • Lead edit on the detail page: name, mobile, email, company, job title and notes. These use the same normalisation and validation as capture. A save that makes the mobile or email the same as another lead's is allowed, and the warning then shows.
  • xlsx export of the Lead Listing and of the Event Leads Listing. Each export has exactly the columns shown on screen and applies the current search or filters, across all pages, not just the visible one.
    • Mobile numbers are written as text, so Excel keeps the +.
    • Dates are written as real dates.
    • The export stops at 20,000 rows; above that, staff are asked to narrow the filters.
    • The file is built in mobile-api with Apache POI's streaming writer.
    • Each export is logged with the username, the listing and the row count, but never with lead data.
  • Permissions:
    • New menu module BO_LEADS (/leads) to view the Lead Listing and lead detail.
    • New action modules BO_LEADS_EDIT (edit a lead) and BO_LEADS_EXPORT (export either listing). Action modules never show in the sidebar.
    • An export also needs the listing's own module: BO_LEADS for the Lead Listing, BO_EVENT_LEADS for the Event Leads Listing.
  • Link from the event lead edit page to the lead detail page, for users who hold BO_LEADS.
  • New dependency org.apache.poi:poi-ooxml 4.1.0 in mobile-api. It is the same library and version that services-system already uses for its spreadsheet exports.
  • New index event_lead (company_id, lead_uuid) for the per-lead aggregation and the event history.

Not in this change: reports beyond the on-screen listings, merging leads, and per-salesperson visibility.

Capabilities

New Capabilities

  • lead-records: the company-wide Lead Listing, the lead detail page with event history and shared-contact warnings, and lead edits.
  • lead-export: xlsx exports of the Lead Listing and the Event Leads Listing, and the export permission.

Modified Capabilities

None. The Event Leads Listing (event-lead-capture) keeps its requirements; the export of it is specified in lead-export.

Impact

  • solvway-services-counter:
    • a lead search (a native query with window functions for the latest capture and the latest salesperson);
    • lead detail with history and shared contacts;
    • lead update.
  • solvway-mobile-api:
    • AdminLeadController and its service;
    • xlsx export endpoints for both listings;
    • the poi-ooxml dependency.
  • solvway-admin-portal:
    • app/leads/** pages (the listing, and a phone-friendly detail page);
    • an Export button on both listings, shown only with BO_LEADS_EXPORT;
    • a binary-safe download route;
    • services, types and i18n;
    • a routeModules entry;
    • a "View lead" link on the event lead edit page.
  • Database: one new index on service-counter.event_lead, and three service-system.module rows. Additive only.
  • local/seed/03-colite.sql mirrors the index and the module rows.
  • No change to the gateway, existing tables or existing endpoints.