task-d.5.1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Task D.5.1: Lead Foundation Schema & Compatibility Layer
|
||||
# Task D.5.1: Lead Foundation Stabilization & Output Completion
|
||||
|
||||
## Status
|
||||
|
||||
@@ -6,11 +6,18 @@ Planned
|
||||
|
||||
## Objective
|
||||
|
||||
Create the foundational schema and compatibility layer required for Lead / Enquiry Domain Separation without breaking the existing CRM workflow.
|
||||
Complete and stabilize the Lead Foundation introduced by Task D.5 Phase 1.
|
||||
|
||||
This task introduces the Lead domain but does not yet migrate business flows.
|
||||
This task must not recreate existing schema objects that already exist.
|
||||
|
||||
The objective is to prepare the platform for D.5.2 and later phases while keeping all existing CRM features operational.
|
||||
The objective is to:
|
||||
|
||||
* verify completed D.5 foundation work
|
||||
* document missing outputs
|
||||
* complete missing seeds
|
||||
* complete foundation registration
|
||||
* establish migration verification
|
||||
* prepare the platform for D.5.2 Lead API Foundation
|
||||
|
||||
---
|
||||
|
||||
@@ -21,111 +28,36 @@ Review:
|
||||
* AGENTS.md
|
||||
* Project Foundations Registry
|
||||
* Task Catalog
|
||||
* ADR-0011 Lead / Enquiry Ownership Model
|
||||
* ADR-0016 Won / Lost Lifecycle Governance
|
||||
* ADR-0018 Lead / Enquiry Domain Separation
|
||||
* Task D.3
|
||||
* Task D.3.1
|
||||
* Task D.4
|
||||
* Existing D.5 implementation summary
|
||||
* Current schema.ts
|
||||
* Current migration history
|
||||
* Current seed files
|
||||
|
||||
---
|
||||
|
||||
# Required Skills
|
||||
# Required Historical Verification
|
||||
|
||||
## Governance
|
||||
Before writing any code verify whether the following already exist:
|
||||
|
||||
* AGENTS.md
|
||||
* Architecture Rules
|
||||
* Task Contract Template
|
||||
* Task Review Checklist
|
||||
|
||||
## CRM
|
||||
|
||||
* Lead / Enquiry Governance
|
||||
* Won / Lost Governance
|
||||
* Customer Ownership Governance
|
||||
|
||||
## Backend
|
||||
|
||||
* Drizzle ORM Pattern
|
||||
* Service Layer Pattern
|
||||
* Route Handler Pattern
|
||||
|
||||
## Security
|
||||
|
||||
* CRM Authorization Foundation
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.1 Create Lead Table
|
||||
|
||||
Add:
|
||||
## Schema
|
||||
|
||||
```txt
|
||||
crm_leads
|
||||
```
|
||||
|
||||
Initial fields:
|
||||
|
||||
```txt
|
||||
id
|
||||
organizationId
|
||||
branchId
|
||||
|
||||
code
|
||||
|
||||
customerId
|
||||
contactId
|
||||
|
||||
projectName
|
||||
projectLocation
|
||||
|
||||
awarenessId
|
||||
|
||||
status
|
||||
followupStatus
|
||||
lostReason
|
||||
|
||||
outcome
|
||||
|
||||
ownerMarketingUserId
|
||||
|
||||
createdBy
|
||||
createdAt
|
||||
updatedAt
|
||||
deletedAt
|
||||
crm_enquiries.lead_id
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.2 Add Lead Reference to Enquiry
|
||||
|
||||
Modify:
|
||||
## ADR
|
||||
|
||||
```txt
|
||||
crm_enquiries
|
||||
ADR-0018
|
||||
```
|
||||
|
||||
Add:
|
||||
|
||||
```txt
|
||||
leadId nullable
|
||||
```
|
||||
|
||||
Relationship:
|
||||
|
||||
```txt
|
||||
crm_leads 1
|
||||
→ N crm_enquiries
|
||||
```
|
||||
|
||||
No business flow changes yet.
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.3 Master Data Foundation
|
||||
|
||||
Create categories:
|
||||
## Seed Categories
|
||||
|
||||
```txt
|
||||
crm_lead_awareness
|
||||
@@ -134,141 +66,193 @@ crm_lead_followup_status
|
||||
crm_lead_lost_reason
|
||||
```
|
||||
|
||||
Seed:
|
||||
|
||||
## crm_lead_awareness
|
||||
|
||||
```txt
|
||||
Google Search / Website
|
||||
Social Media
|
||||
Email Marketing
|
||||
Visit
|
||||
Exhibition / Event
|
||||
Brochure / Catalog
|
||||
Word of Mouth
|
||||
Corporate Car
|
||||
Product Label
|
||||
Re-purchasing
|
||||
Introducing
|
||||
BCI
|
||||
```
|
||||
|
||||
## crm_lead_status
|
||||
|
||||
```txt
|
||||
new_job
|
||||
follow_up
|
||||
closed_lost
|
||||
cancel
|
||||
```
|
||||
|
||||
## crm_lead_followup_status
|
||||
|
||||
```txt
|
||||
budget_pending
|
||||
project_under_review
|
||||
spec_clarification
|
||||
site_survey_waiting
|
||||
drawing_followup
|
||||
quotation_preparation
|
||||
waiting_po
|
||||
```
|
||||
|
||||
## crm_lead_lost_reason
|
||||
|
||||
```txt
|
||||
price
|
||||
delivery_time
|
||||
sales_person
|
||||
service
|
||||
customer
|
||||
product_quality
|
||||
other
|
||||
transfer
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.4 Document Sequence Foundation
|
||||
|
||||
Register:
|
||||
## Document Sequences
|
||||
|
||||
```txt
|
||||
crm_lead
|
||||
crm_enquiry
|
||||
```
|
||||
|
||||
Document codes:
|
||||
---
|
||||
|
||||
# Rule
|
||||
|
||||
If an item already exists:
|
||||
|
||||
```txt
|
||||
Lead:
|
||||
LD2606-001
|
||||
|
||||
Enquiry:
|
||||
EN2606-001
|
||||
DO NOT recreate it
|
||||
DO NOT generate duplicate migrations
|
||||
DO NOT rename existing objects
|
||||
```
|
||||
|
||||
Do not switch existing generation logic yet.
|
||||
|
||||
Only prepare configuration.
|
||||
Document the existing implementation instead.
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.5 Compatibility Layer
|
||||
# Scope D5.1.1 Foundation Audit
|
||||
|
||||
Keep existing:
|
||||
Create a verification report.
|
||||
|
||||
Document:
|
||||
|
||||
```txt
|
||||
crm_enquiries.pipeline_stage
|
||||
What already exists
|
||||
What is missing
|
||||
What is partially implemented
|
||||
```
|
||||
|
||||
unchanged.
|
||||
|
||||
No route behavior changes.
|
||||
|
||||
No dashboard changes.
|
||||
|
||||
No report changes.
|
||||
|
||||
No migration of existing records.
|
||||
|
||||
This task prepares schema only.
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.6 Authorization Preparation
|
||||
# Scope D5.1.2 Seed Completion
|
||||
|
||||
Add placeholders for future Lead permissions:
|
||||
Verify all Lead master options exist.
|
||||
|
||||
Missing options only:
|
||||
|
||||
```txt
|
||||
crm.lead.read
|
||||
crm.lead.create
|
||||
crm.lead.update
|
||||
crm.lead.assign
|
||||
crm.lead.delete
|
||||
create missing records
|
||||
```
|
||||
|
||||
No enforcement changes yet.
|
||||
Existing options:
|
||||
|
||||
```txt
|
||||
leave unchanged
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.3 Document Sequence Audit
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
crm_lead
|
||||
crm_enquiry
|
||||
```
|
||||
|
||||
exist in document sequence configuration.
|
||||
|
||||
If missing:
|
||||
|
||||
```txt
|
||||
add only missing configuration
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.4 Foundation Registration
|
||||
|
||||
Update:
|
||||
|
||||
```txt
|
||||
docs/standards/project-foundations.md
|
||||
```
|
||||
|
||||
Add:
|
||||
|
||||
```txt
|
||||
Lead Foundation
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
Marketing-owned lead domain.
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.5 Task Catalog Registration
|
||||
|
||||
Update:
|
||||
|
||||
```txt
|
||||
docs/standards/task-catalog.md
|
||||
```
|
||||
|
||||
Register:
|
||||
|
||||
```txt
|
||||
Task D.5
|
||||
Task D.5.1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.6 Output Documentation
|
||||
|
||||
Create:
|
||||
|
||||
```txt
|
||||
docs/implementation/task-d51-lead-foundation-stabilization.md
|
||||
```
|
||||
|
||||
Document:
|
||||
|
||||
* schema created
|
||||
* seeds created
|
||||
* sequence configuration
|
||||
* compatibility status
|
||||
|
||||
---
|
||||
|
||||
# Scope D5.1.7 Compatibility Verification
|
||||
|
||||
Verify:
|
||||
|
||||
Current CRM still works:
|
||||
|
||||
```txt
|
||||
Customer
|
||||
Contact
|
||||
Enquiry
|
||||
Quotation
|
||||
Dashboard
|
||||
Reports
|
||||
```
|
||||
|
||||
No behavior changes allowed.
|
||||
|
||||
---
|
||||
|
||||
# Deliverables
|
||||
|
||||
## New
|
||||
## New Documentation
|
||||
|
||||
* crm_leads schema
|
||||
* lead master option categories
|
||||
* lead document sequence configuration
|
||||
* ADR-0018 references
|
||||
* task-d51-lead-foundation-stabilization.md
|
||||
|
||||
---
|
||||
|
||||
## Modified
|
||||
## Updated Documentation
|
||||
|
||||
* crm_enquiries
|
||||
* foundation.seed.ts
|
||||
* document sequence seed
|
||||
* CRM permission registry
|
||||
* project-foundations.md
|
||||
* task-catalog.md
|
||||
|
||||
---
|
||||
|
||||
## Verification Output
|
||||
|
||||
Produce:
|
||||
|
||||
### Existing Foundation
|
||||
|
||||
```txt
|
||||
crm_leads
|
||||
crm_enquiries.lead_id
|
||||
ADR-0018
|
||||
```
|
||||
|
||||
### Missing Foundation
|
||||
|
||||
```txt
|
||||
...
|
||||
```
|
||||
|
||||
### Completed Foundation
|
||||
|
||||
```txt
|
||||
...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -278,54 +262,13 @@ Do NOT:
|
||||
|
||||
* create Lead APIs
|
||||
* create Lead UI
|
||||
* create Lead assignment workflow
|
||||
* migrate existing records
|
||||
* change dashboard
|
||||
* change reports
|
||||
* change security behavior
|
||||
* create Lead Assignment workflow
|
||||
* migrate records
|
||||
* update dashboard datasets
|
||||
* update report datasets
|
||||
* remove pipeline_stage
|
||||
|
||||
Those belong to later D.5 phases.
|
||||
|
||||
---
|
||||
|
||||
# Verification
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
npm exec tsc --noEmit
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
crm_leads table exists
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
crm_enquiries.leadId exists
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
lead master options seeded
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
document sequence configuration exists
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```txt
|
||||
existing CRM workflow remains unchanged
|
||||
```
|
||||
Those belong to D.5.2+
|
||||
|
||||
---
|
||||
|
||||
@@ -333,17 +276,17 @@ existing CRM workflow remains unchanged
|
||||
|
||||
Task is complete when:
|
||||
|
||||
* Lead schema exists
|
||||
* Enquiry can reference Lead
|
||||
* Lead master data exists
|
||||
* Lead document sequence exists
|
||||
* Existing CRM remains fully operational
|
||||
* No business workflow regression occurs
|
||||
* no duplicate schema is created
|
||||
* existing D.5 work is audited
|
||||
* missing seed/configuration is completed
|
||||
* foundation registry is updated
|
||||
* task catalog is updated
|
||||
* D.5 foundation state is documented
|
||||
|
||||
Result:
|
||||
|
||||
Lead Foundation = Established
|
||||
Lead Foundation = Stabilized
|
||||
|
||||
Compatibility Layer = Established
|
||||
Lead Foundation Outputs = Recorded
|
||||
|
||||
Ready for D.5.2 Lead APIs & UI
|
||||
Ready for D.5.2 Lead API Foundation
|
||||
|
||||
Reference in New Issue
Block a user