rez_core 3.1.126 → 3.1.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/workflow/controller/stage.controller.d.ts +1 -0
- package/dist/module/workflow/controller/stage.controller.js.map +1 -1
- package/dist/module/workflow/service/stage.service.d.ts +1 -0
- package/dist/module/workflow/service/stage.service.js +22 -2
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/controller/stage.controller.ts +1 -1
- package/src/module/workflow/service/stage.service.ts +40 -2
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ export class StageController {
|
|
|
24
24
|
@Post('/getAllStage')
|
|
25
25
|
async getAllStage(
|
|
26
26
|
@Req() req: Request & { user: any },
|
|
27
|
-
@Body() body: { stage_group_id: number },
|
|
27
|
+
@Body() body: { stage_group_id: number; mapped_entity_id: number },
|
|
28
28
|
@Query() query: { show_previous: boolean },
|
|
29
29
|
) {
|
|
30
30
|
const { organization_id } = req.user.userData;
|
|
@@ -34,6 +34,7 @@ export class StageService extends EntityServiceImpl {
|
|
|
34
34
|
async getAllStage(
|
|
35
35
|
payload: {
|
|
36
36
|
stage_group_id: number;
|
|
37
|
+
mapped_entity_id: number;
|
|
37
38
|
},
|
|
38
39
|
organization_id: number,
|
|
39
40
|
show_previous: boolean,
|
|
@@ -63,15 +64,52 @@ export class StageService extends EntityServiceImpl {
|
|
|
63
64
|
return allStages;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
// 1. Get all stages up to the current stage group
|
|
66
68
|
const allStageWithStageGroup =
|
|
67
69
|
await this.stageRepository.getAllStageGroupAndStageByStageMovement(
|
|
68
70
|
payload.stage_group_id,
|
|
69
71
|
organization_id,
|
|
70
72
|
);
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
// 2. Get stage movement history for this entity
|
|
75
|
+
const allStageMovementData = await this.dataSource.manager.find<{
|
|
76
|
+
id: number;
|
|
77
|
+
stage_group_id: number;
|
|
78
|
+
stage_id: number;
|
|
79
|
+
mapped_entity_id: number;
|
|
80
|
+
mapped_entity_type: string;
|
|
81
|
+
is_current: string;
|
|
82
|
+
}>('cr_wf_stage_movement_data', {
|
|
83
|
+
where: {
|
|
84
|
+
mapped_entity_id: payload.mapped_entity_id,
|
|
85
|
+
mapped_entity_type: 'LEAD',
|
|
86
|
+
},
|
|
87
|
+
order: { id: 'ASC' },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (!allStageMovementData || allStageMovementData.length === 0) {
|
|
91
|
+
return allStageWithStageGroup;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 3. Find the current stage movement (is_current === 'Y')
|
|
95
|
+
const currentMovement = allStageMovementData.find(
|
|
96
|
+
(m) => m.is_current === 'Y',
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (!currentMovement) {
|
|
100
|
+
return allStageWithStageGroup;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 4. Filter stages up to and including the current stage_id
|
|
104
|
+
const filteredStages: any[] = [];
|
|
105
|
+
for (const stage of allStageWithStageGroup) {
|
|
106
|
+
filteredStages.push(stage);
|
|
107
|
+
if (stage.id === currentMovement.stage_id) {
|
|
108
|
+
break; // stop once we reach the current stage
|
|
109
|
+
}
|
|
110
|
+
}
|
|
73
111
|
|
|
74
|
-
return
|
|
112
|
+
return filteredStages;
|
|
75
113
|
}
|
|
76
114
|
|
|
77
115
|
async updateEntity(
|