skailan-crm
Version:
Servicio de CRM y gestión de ventas para Skailan
70 lines • 2.03 kB
JavaScript
export class Lead {
id;
organizationId;
name;
email;
phone;
status;
source;
notes;
score;
company;
title;
industry;
createdAt;
updatedAt;
constructor(id, organizationId, name, email, phone, status, source, notes, score, // New field for Lead Scoring
company, // New field for Data Enrichment
title, // New field for Data Enrichment
industry, // New field for Data Enrichment
createdAt, updatedAt) {
this.id = id;
this.organizationId = organizationId;
this.name = name;
this.email = email;
this.phone = phone;
this.status = status;
this.source = source;
this.notes = notes;
this.score = score;
this.company = company;
this.title = title;
this.industry = industry;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
}
// Example of domain logic within the entity
updateStatus(newStatus) {
// Add validation or business rules here
this.status = newStatus;
this.updatedAt = new Date();
}
updateContactInfo(email, phone) {
this.email = email;
this.phone = phone;
this.updatedAt = new Date();
}
// Method for Lead Scoring
calculateScore() {
let newScore = 0;
if (this.email)
newScore += 10; // Email present
if (this.phone)
newScore += 10; // Phone present
if (this.source === 'Web')
newScore += 5; // Source from web
if (this.status === 'Qualified')
newScore += 20; // Qualified lead
// Add more complex scoring logic based on other attributes
this.score = newScore;
this.updatedAt = new Date();
}
// Method for Data Enrichment
enrichData(company, title, industry) {
this.company = company;
this.title = title;
this.industry = industry;
this.updatedAt = new Date();
}
}
//# sourceMappingURL=Lead.js.map