| 37121 |
vikas |
1 |
package com.spice.profitmandi.dao.enumuration.dtr;
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* LMS lead lifecycle stage (SOP §8). This is the richer, forward-facing lifecycle the
|
|
|
5 |
* LMS screens read off. It sits ALONGSIDE the legacy {@link LeadStatus} (5 values) — every
|
|
|
6 |
* mutation writes {@code toLegacyStatus()} back onto {@code Lead.status} so the existing
|
|
|
7 |
* lists / exports / charts / geo / beat flows keep working untouched.
|
|
|
8 |
*
|
|
|
9 |
* NEW → ASSIGNED → CONTACTED → QUALIFIED → BEAT_PLANNED → VISITED → ONBOARDED → ACTIVE,
|
|
|
10 |
* with two terminal off-path states: NOT_INTERESTED and DROPPED.
|
|
|
11 |
*/
|
|
|
12 |
public enum LeadStage {
|
|
|
13 |
NEW,
|
|
|
14 |
ASSIGNED,
|
|
|
15 |
CONTACTED,
|
|
|
16 |
QUALIFIED,
|
|
|
17 |
BEAT_PLANNED,
|
|
|
18 |
VISITED,
|
|
|
19 |
ONBOARDED,
|
|
|
20 |
ACTIVE,
|
|
|
21 |
NOT_INTERESTED,
|
|
|
22 |
DROPPED;
|
|
|
23 |
|
|
|
24 |
/** Ordered happy-path (excludes terminal off-path states) — drives the stepper + forward-transition checks. */
|
|
|
25 |
public static final LeadStage[] HAPPY_PATH = {
|
|
|
26 |
NEW, ASSIGNED, CONTACTED, QUALIFIED, BEAT_PLANNED, VISITED, ONBOARDED, ACTIVE
|
|
|
27 |
};
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Map a stage onto the legacy {@link LeadStatus} so existing queries stay correct.
|
|
|
31 |
* pending = open/in-progress, followUp = qualified/scheduled, finalized = won, notInterested = lost/dead.
|
|
|
32 |
*/
|
|
|
33 |
public LeadStatus toLegacyStatus() {
|
|
|
34 |
switch (this) {
|
|
|
35 |
case NEW:
|
|
|
36 |
case ASSIGNED:
|
|
|
37 |
case CONTACTED:
|
|
|
38 |
return LeadStatus.pending;
|
|
|
39 |
case QUALIFIED:
|
|
|
40 |
case BEAT_PLANNED:
|
|
|
41 |
case VISITED:
|
|
|
42 |
return LeadStatus.followUp;
|
|
|
43 |
case ONBOARDED:
|
|
|
44 |
case ACTIVE:
|
|
|
45 |
return LeadStatus.finalized;
|
|
|
46 |
case NOT_INTERESTED:
|
|
|
47 |
case DROPPED:
|
|
|
48 |
default:
|
|
|
49 |
return LeadStatus.notInterested;
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Best-effort stage for a pre-existing lead that has no {@code stage} column value yet
|
|
|
55 |
* (rows created before the LMS columns were added). Used on read only.
|
|
|
56 |
*/
|
|
|
57 |
public static LeadStage fromLegacy(LeadStatus status, String color) {
|
|
|
58 |
if (status == null) {
|
|
|
59 |
return NEW;
|
|
|
60 |
}
|
|
|
61 |
switch (status) {
|
|
|
62 |
case pending:
|
|
|
63 |
return ASSIGNED; // already created + assigned, first contact not yet logged
|
|
|
64 |
case followUp:
|
|
|
65 |
return QUALIFIED; // in the working pipeline
|
|
|
66 |
case finalized:
|
|
|
67 |
return ONBOARDED;
|
|
|
68 |
case notInterested:
|
|
|
69 |
return NOT_INTERESTED;
|
|
|
70 |
default:
|
|
|
71 |
return NEW;
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/** Is {@code next} a forward move from this stage along the happy path? Terminal states are always allowed. */
|
|
|
76 |
public boolean canAdvanceTo(LeadStage next) {
|
|
|
77 |
if (next == NOT_INTERESTED || next == DROPPED) {
|
|
|
78 |
return true;
|
|
|
79 |
}
|
|
|
80 |
int here = indexOf(this);
|
|
|
81 |
int there = indexOf(next);
|
|
|
82 |
return here >= 0 && there > here;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
private static int indexOf(LeadStage s) {
|
|
|
86 |
for (int i = 0; i < HAPPY_PATH.length; i++) {
|
|
|
87 |
if (HAPPY_PATH[i] == s) {
|
|
|
88 |
return i;
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
return -1;
|
|
|
92 |
}
|
|
|
93 |
}
|