|
def score_opportunity(data): |
|
|
|
raw_score = ( |
|
0.3 * (data['lead_score'] or 0) + |
|
0.2 * (data['email_count'] or 0) + |
|
0.2 * (data['meeting_count'] or 0) - |
|
0.1 * (data['close_date_gap'] or 0) |
|
) |
|
raw_score += 0.1 * (1 if data['stage'] == "Negotiation" else 0) |
|
raw_score = max(0, min(100, round(raw_score))) |
|
|
|
|
|
if raw_score >= 75: |
|
risk = "Low" |
|
recommendation = "High chance of closing. Prioritize this deal." |
|
elif raw_score >= 50: |
|
risk = "Medium" |
|
recommendation = "Moderate potential. Consider a follow-up soon." |
|
else: |
|
risk = "High" |
|
recommendation = "Low potential. Reassess engagement or de-prioritize." |
|
|
|
return { |
|
"score": raw_score, |
|
"risk": risk, |
|
"recommendation": recommendation |
|
} |
|
|