5.1 KiB
Task D.3: Lead / Enquiry Ownership Refinement
Goal
ปรับ CRM Pipeline ให้สอดคล้องกับ Business Process ล่าสุด
Current:
Lead (unassigned enquiry)
↓
Opportunity (assigned enquiry)
↓
Quotation
↓
Won / Lost
New Business Flow:
Lead
↓ Assign To Sales
Enquiry
↓
Quotation
↓
Won / Lost
Important:
Task D.3 focuses on ownership, visibility, permissions, and lifecycle only.
Lead and Enquiry continue using the same underlying business fields and form structure.
Do NOT split the Lead form and Enquiry form yet.
Future form differences will be handled in a separate task if business requirements diverge.
Business Rules
Lead
Owner:
Marketing (MK)
Purpose:
Lead collection
Lead qualification
Lead nurturing
Status examples:
new
contacted
qualified
disqualified
assigned
Lead may exist without sales assignment.
Enquiry
Owner:
Sales
Purpose:
Project follow-up
Opportunity development
Competitor tracking
Quotation preparation
Enquiry begins when:
Lead assigned to Sales
or
Sales creates enquiry directly
Scope D3.1 Pipeline Terminology Refinement
Replace current KPI and workflow terminology.
Old:
Lead = enquiry without assignment
Opportunity = enquiry with assignment
New:
Lead = marketing-owned pipeline stage
Enquiry = sales-owned pipeline stage
Rules:
- Stop using Opportunity terminology in UI where practical
- Use Lead and Enquiry terminology consistently
- Preserve existing data compatibility
Scope D3.2 Enquiry Pipeline Stage
Add field:
pipelineStage
Allowed values:
lead
enquiry
closed_won
closed_lost
Default:
lead
Rules:
Marketing-created lead
pipelineStage = lead
assignedToUserId = null
Assign to sales
Automatically:
pipelineStage = enquiry
assignedToUserId = salesUserId
assignedAt = now()
Reassign
Keep:
pipelineStage = enquiry
Won
pipelineStage = closed_won
Lost
pipelineStage = closed_lost
Scope D3.3 Assign Flow Refinement
Current assign flow already exists.
Update behavior:
Assign:
Lead
↓
Enquiry
When assign executes:
assignedToUserId
assignedAt
assignedBy
pipelineStage = enquiry
Audit:
assign
lead_to_enquiry
Scope D3.4 MK Visibility Policy
Marketing users must be able to monitor progress.
MK can view:
Lead
Enquiry
Follow-ups
Status
Pipeline Stage
Assigned Sales
Won/Lost Result
MK cannot view:
Quotation Amount
Quotation Item
Quotation Cost
Discount
Margin
Approval Data
MK cannot:
Edit enquiry owned by sales
Create quotation
Modify quotation
Approve quotation
Scope D3.5 Sales Visibility Policy
Sales can:
View assigned enquiries
Edit assigned enquiries
Create quotations
Manage follow-ups
View quotation pricing
Rules remain compatible with existing assignment ownership.
Scope D3.6 Dashboard KPI Alignment
Update KPI service layer.
New definitions:
Lead Count
pipelineStage = lead
Enquiry Count
pipelineStage = enquiry
Won Count
pipelineStage = closed_won
Lost Count
pipelineStage = closed_lost
Remove dependency on:
assignedToUserId == null
for lead calculation.
Scope D3.7 Revenue Rules
No revenue logic change.
Still use:
Quotation Amount
Revenue Attribution
Project Party Governance
from Task D.2.1.
Scope D3.8 UI Labels
Update CRM wording.
Examples:
Assign Sales
→ Convert To Enquiry
Assigned Sales
→ Enquiry Owner
Open Opportunities
→ Active Enquiries
Do not rename database tables.
Only update business-facing labels.
Scope D3.9 Backward Compatibility
Do NOT:
Create crm_leads table
Split enquiry form
Split enquiry schema
Split enquiry API
Continue using:
crm_enquiries
as the single source of truth.
Lead vs Enquiry is determined by:
pipelineStage
and ownership.
Scope D3.10 ADR
Create:
docs/adr/0011-lead-enquiry-ownership-model.md
Document:
Lead ownership
Enquiry ownership
Assignment flow
MK visibility restrictions
Won/Lost lifecycle
This ADR supersedes the Opportunity terminology frozen in Task J.0.
Explicit Non-Scope
Do NOT implement:
crm_leads table
Lead form
Lead API
Lead import
Campaign module
Marketing automation
Lead scoring
New dashboard widgets
Output
- Files Added
- Files Modified
- Pipeline Changes
- Ownership Changes
- Visibility Rules Added
- KPI Changes
- ADR Added
- Migration Notes
- Remaining Risks
Definition of Done
✔ Lead and Enquiry terminology updated
✔ Assign converts Lead → Enquiry
✔ MK can monitor enquiries
✔ MK cannot see quotation pricing
✔ Sales owns enquiries
✔ Dashboard KPI follows pipelineStage
✔ No duplicate Lead module created
✔ Existing enquiry form reused
✔ Existing data remains compatible
✔ ADR created