rez_core 5.0.89 → 5.0.91
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/meta/repository/entity-master.repository.d.ts +3 -1
- package/dist/module/meta/repository/entity-master.repository.js +10 -6
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
- package/dist/module/meta/service/entity-relation.service.d.ts +1 -3
- package/dist/module/meta/service/entity-relation.service.js +22 -31
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +3 -1
- package/dist/module/module/service/module-access.service.js +11 -4
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/controller/notification.controller.d.ts +1 -1
- package/dist/module/notification/service/notification.service.d.ts +6 -4
- package/dist/module/notification/service/notification.service.js +22 -20
- package/dist/module/notification/service/notification.service.js.map +1 -1
- package/dist/module/workflow/controller/action.controller.d.ts +5 -2
- package/dist/module/workflow/controller/form-master.controller.d.ts +4 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +2 -3
- package/dist/module/workflow/repository/action-data.repository.js +29 -18
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
- package/dist/module/workflow/repository/action.repository.d.ts +6 -7
- package/dist/module/workflow/repository/action.repository.js +53 -61
- package/dist/module/workflow/repository/action.repository.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +2 -3
- package/dist/module/workflow/repository/comm-template.repository.js +15 -9
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/repository/form-master.repository.d.ts +7 -4
- package/dist/module/workflow/repository/form-master.repository.js +14 -11
- package/dist/module/workflow/repository/form-master.repository.js.map +1 -1
- package/dist/module/workflow/repository/stage-group.repository.d.ts +4 -5
- package/dist/module/workflow/repository/stage-group.repository.js +34 -35
- package/dist/module/workflow/repository/stage-group.repository.js.map +1 -1
- package/dist/module/workflow/repository/stage-movement.repository.d.ts +6 -3
- package/dist/module/workflow/repository/stage-movement.repository.js +30 -17
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -1
- package/dist/module/workflow/service/action.service.d.ts +13 -5
- package/dist/module/workflow/service/action.service.js +71 -20
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.d.ts +3 -3
- package/dist/module/workflow/service/entity-modification.service.js +4 -4
- package/dist/module/workflow/service/entity-modification.service.js.map +1 -1
- package/dist/module/workflow/service/form-master.service.d.ts +4 -1
- package/dist/module/workflow/service/stage-group.service.d.ts +2 -7
- package/dist/module/workflow/service/stage-group.service.js +19 -17
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.d.ts +2 -3
- package/dist/module/workflow/service/stage.service.js +24 -11
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +2 -5
- package/dist/module/workflow/service/task.service.js +44 -45
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-list-master.service.d.ts +1 -3
- package/dist/module/workflow/service/workflow-list-master.service.js +38 -26
- package/dist/module/workflow/service/workflow-list-master.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.d.ts +6 -3
- package/dist/module/workflow/service/workflow-meta.service.js +78 -50
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.d.ts +1 -3
- package/dist/module/workflow/service/workflow.service.js +10 -6
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow-schedule/processors/schedule.processor.d.ts +4 -2
- package/dist/module/workflow-schedule/processors/schedule.processor.js +51 -38
- package/dist/module/workflow-schedule/processors/schedule.processor.js.map +1 -1
- package/dist/module/workflow-schedule/service/workflow-schedule.service.d.ts +2 -3
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js +15 -14
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/repository/entity-master.repository.ts +9 -8
- package/src/module/meta/service/entity-relation.service.ts +23 -41
- package/src/module/module/service/module-access.service.ts +8 -4
- package/src/module/notification/service/notification.service.ts +24 -20
- package/src/module/workflow/repository/action-data.repository.ts +33 -28
- package/src/module/workflow/repository/action.repository.ts +74 -77
- package/src/module/workflow/repository/comm-template.repository.ts +19 -13
- package/src/module/workflow/repository/form-master.repository.ts +15 -24
- package/src/module/workflow/repository/stage-group.repository.ts +41 -52
- package/src/module/workflow/repository/stage-movement.repository.ts +35 -32
- package/src/module/workflow/service/action.service.ts +70 -43
- package/src/module/workflow/service/entity-modification.service.ts +3 -3
- package/src/module/workflow/service/stage-group.service.ts +21 -19
- package/src/module/workflow/service/stage.service.ts +36 -28
- package/src/module/workflow/service/task.service.ts +53 -56
- package/src/module/workflow/service/workflow-list-master.service.ts +42 -34
- package/src/module/workflow/service/workflow-meta.service.ts +81 -77
- package/src/module/workflow/service/workflow.service.ts +9 -5
- package/src/module/workflow-schedule/processors/schedule.processor.ts +133 -97
- package/src/module/workflow-schedule/service/workflow-schedule.service.ts +24 -26
|
@@ -24,7 +24,6 @@ export class StageService extends EntityServiceImpl {
|
|
|
24
24
|
private readonly stageGroupRepository: StageGroupRepository,
|
|
25
25
|
@InjectRepository(StageMovementData)
|
|
26
26
|
private readonly stageMovementRepo: Repository<StageMovementData>,
|
|
27
|
-
private readonly dataSource: DataSource,
|
|
28
27
|
@Inject('ActionService')
|
|
29
28
|
private readonly actionService: ActionService,
|
|
30
29
|
) {
|
|
@@ -39,24 +38,33 @@ export class StageService extends EntityServiceImpl {
|
|
|
39
38
|
organization_id: number,
|
|
40
39
|
show_previous: boolean,
|
|
41
40
|
) {
|
|
41
|
+
const listRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
42
|
+
const stageMovementRepo =
|
|
43
|
+
this.reflectionHelper.getRepoService('StageMovementData');
|
|
44
|
+
|
|
42
45
|
if (!show_previous) {
|
|
43
46
|
const allStages = await this.stageRepository.getAllStage(
|
|
44
47
|
payload.stage_group_id,
|
|
45
48
|
organization_id,
|
|
46
49
|
);
|
|
47
50
|
|
|
48
|
-
const statusListMaster = await
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const statusListMaster = await listRepo.find({
|
|
52
|
+
where: {
|
|
53
|
+
listtype: 'STS',
|
|
54
|
+
organization_id: organization_id,
|
|
55
|
+
},
|
|
56
|
+
select: {
|
|
57
|
+
id: true,
|
|
58
|
+
name: true,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// id → name map
|
|
56
63
|
const statusMap = new Map(
|
|
57
64
|
statusListMaster.map((s) => [String(s.id), s.name]),
|
|
58
65
|
);
|
|
59
66
|
|
|
67
|
+
// Replace status IDs with names
|
|
60
68
|
for (const stage of allStages) {
|
|
61
69
|
stage.status = statusMap.get(String(stage.status)) as any;
|
|
62
70
|
}
|
|
@@ -64,22 +72,15 @@ export class StageService extends EntityServiceImpl {
|
|
|
64
72
|
return allStages;
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
// 1. Get all
|
|
75
|
+
// 1. Get all stage groups & stages
|
|
68
76
|
const allStageWithStageGroup =
|
|
69
77
|
await this.stageRepository.getAllStageGroupAndStageByStageMovement(
|
|
70
78
|
payload.stage_group_id,
|
|
71
79
|
organization_id,
|
|
72
80
|
);
|
|
73
81
|
|
|
74
|
-
// 2.
|
|
75
|
-
const allStageMovementData = await
|
|
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
|
-
}>('frm_wf_stage_movement_data', {
|
|
82
|
+
// 2. Replace raw manager.find with proper repository
|
|
83
|
+
const allStageMovementData = await stageMovementRepo.find({
|
|
83
84
|
where: {
|
|
84
85
|
mapped_entity_id: payload.mapped_entity_id,
|
|
85
86
|
mapped_entity_type: 'LEAD',
|
|
@@ -91,7 +92,7 @@ export class StageService extends EntityServiceImpl {
|
|
|
91
92
|
return allStageWithStageGroup;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
// 3. Find the current stage movement
|
|
95
|
+
// 3. Find the current stage movement
|
|
95
96
|
const currentMovement = allStageMovementData.find(
|
|
96
97
|
(m) => m.is_current === 'Y',
|
|
97
98
|
);
|
|
@@ -100,13 +101,11 @@ export class StageService extends EntityServiceImpl {
|
|
|
100
101
|
return allStageWithStageGroup;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
// 4. Filter stages up to
|
|
104
|
+
// 4. Filter stages up to current stage_id
|
|
104
105
|
const filteredStages: any[] = [];
|
|
105
106
|
for (const stage of allStageWithStageGroup) {
|
|
106
107
|
filteredStages.push(stage);
|
|
107
|
-
if (stage.id === currentMovement.stage_id)
|
|
108
|
-
break; // stop once we reach the current stage
|
|
109
|
-
}
|
|
108
|
+
if (stage.id === currentMovement.stage_id) break;
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
return filteredStages;
|
|
@@ -132,11 +131,19 @@ export class StageService extends EntityServiceImpl {
|
|
|
132
131
|
id: number,
|
|
133
132
|
loggedInUser: UserData,
|
|
134
133
|
): Promise<any> {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
134
|
+
const stageActionRepo =
|
|
135
|
+
this.reflectionHelper.getRepoService('StageActionMapping');
|
|
136
|
+
|
|
137
|
+
// 1. Fetch all actions mapped to this stage (replaces raw SQL)
|
|
138
|
+
const getAllStageAction = await stageActionRepo.find({
|
|
139
|
+
where: {
|
|
140
|
+
stage_id: id,
|
|
141
|
+
entity_type: 'WFSA',
|
|
142
|
+
},
|
|
143
|
+
select: ['action_id'],
|
|
144
|
+
});
|
|
139
145
|
|
|
146
|
+
// 2. Delete all related WFSA actions
|
|
140
147
|
if (getAllStageAction.length > 0) {
|
|
141
148
|
for (const action of getAllStageAction) {
|
|
142
149
|
await this.actionService.deleteEntity(
|
|
@@ -147,6 +154,7 @@ export class StageService extends EntityServiceImpl {
|
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
|
|
157
|
+
// 3. Delete the stage itself
|
|
150
158
|
const deleteStage = await super.deleteEntity(entityType, id, loggedInUser);
|
|
151
159
|
|
|
152
160
|
return deleteStage;
|
|
@@ -6,13 +6,10 @@ import { ActionDataService } from './action-data.service';
|
|
|
6
6
|
import { DataSource, EntityManager } from 'typeorm';
|
|
7
7
|
import { ActivityLogService } from './activity-log.service';
|
|
8
8
|
import { ACTIVITY_CATEGORIES } from '../repository/activity-log.repository';
|
|
9
|
-
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
10
9
|
import { ActionHandler } from 'src/module/workflow-automation/interface/action.decorator';
|
|
11
10
|
import * as moment from 'moment';
|
|
12
11
|
import { ConfigService } from '@nestjs/config';
|
|
13
12
|
import axios from 'axios';
|
|
14
|
-
import { ChecksumAlgorithm } from '@aws-sdk/client-s3';
|
|
15
|
-
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
16
13
|
|
|
17
14
|
@Injectable()
|
|
18
15
|
@ActionHandler('add_task')
|
|
@@ -20,10 +17,8 @@ export class TaskService extends EntityServiceImpl {
|
|
|
20
17
|
constructor(
|
|
21
18
|
private readonly taskRepository: TaskRepository,
|
|
22
19
|
private readonly actionDataService: ActionDataService,
|
|
23
|
-
private readonly dataSource: DataSource,
|
|
24
20
|
@Inject('ActivityLogService')
|
|
25
21
|
private readonly activityLogService: ActivityLogService,
|
|
26
|
-
private readonly mediaDataService: MediaDataService,
|
|
27
22
|
private readonly configService: ConfigService,
|
|
28
23
|
) {
|
|
29
24
|
super();
|
|
@@ -108,23 +103,25 @@ export class TaskService extends EntityServiceImpl {
|
|
|
108
103
|
// Logging should not block main flow
|
|
109
104
|
}
|
|
110
105
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
const entityRelationRepo =
|
|
107
|
+
this.reflectionHelper.getRepoService('EntityRelationData');
|
|
108
|
+
|
|
109
|
+
let relationData = await entityRelationRepo.findOne({
|
|
110
|
+
where: {
|
|
111
|
+
source_entity_type: createdEntity.mapped_entity_type,
|
|
112
|
+
target_entity_type: createdEntity.entity_type,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
115
|
|
|
116
116
|
if (relationData) {
|
|
117
|
-
await
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
relationData[0]?.relation_type,
|
|
126
|
-
],
|
|
127
|
-
);
|
|
117
|
+
await entityRelationRepo.save({
|
|
118
|
+
organization_id: loggedInUser.organization_id,
|
|
119
|
+
source_entity_id: createdEntity.mapped_entity_id,
|
|
120
|
+
source_entity_type: createdEntity.mapped_entity_type,
|
|
121
|
+
target_entity_id: createdEntity.id,
|
|
122
|
+
target_entity_type: createdEntity.entity_type,
|
|
123
|
+
relation_type: relationData?.relation_type,
|
|
124
|
+
});
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
return createdEntity;
|
|
@@ -135,37 +132,35 @@ export class TaskService extends EntityServiceImpl {
|
|
|
135
132
|
loggedInUser: UserData,
|
|
136
133
|
appcode?: string,
|
|
137
134
|
): Promise<any> {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
loggedInUser.organization_id,
|
|
168
|
-
]);
|
|
135
|
+
const listRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
136
|
+
const taskRepo = this.reflectionHelper.getRepoService('TaskDataEntity');
|
|
137
|
+
|
|
138
|
+
const statusRows = await listRepo.find({
|
|
139
|
+
where: {
|
|
140
|
+
id: entityData.status,
|
|
141
|
+
organization_id: loggedInUser.organization_id,
|
|
142
|
+
listtype: 'TKST',
|
|
143
|
+
},
|
|
144
|
+
take: 1,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const oldRow = await taskRepo.findOne({
|
|
148
|
+
where: {
|
|
149
|
+
id: entityData.id,
|
|
150
|
+
organization_id: loggedInUser.organization_id,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const oldStatusRows = oldRow
|
|
155
|
+
? await listRepo.find({
|
|
156
|
+
where: {
|
|
157
|
+
id: oldRow.status,
|
|
158
|
+
organization_id: loggedInUser.organization_id,
|
|
159
|
+
listtype: 'TKST',
|
|
160
|
+
},
|
|
161
|
+
take: 1,
|
|
162
|
+
})
|
|
163
|
+
: [];
|
|
169
164
|
|
|
170
165
|
const isStatusChanged =
|
|
171
166
|
statusRows.length > 0 &&
|
|
@@ -176,7 +171,6 @@ export class TaskService extends EntityServiceImpl {
|
|
|
176
171
|
statusRows.length > 0 &&
|
|
177
172
|
statusRows[0].name?.toLowerCase() === 'completed';
|
|
178
173
|
|
|
179
|
-
// Sync flags based on status
|
|
180
174
|
entityData.is_completed = isCompletedStatus;
|
|
181
175
|
entityData.is_done = isCompletedStatus;
|
|
182
176
|
|
|
@@ -195,11 +189,14 @@ export class TaskService extends EntityServiceImpl {
|
|
|
195
189
|
appcode,
|
|
196
190
|
);
|
|
197
191
|
|
|
198
|
-
// Convert boolean
|
|
192
|
+
// Convert boolean → "1"/"0"
|
|
199
193
|
if (updatedEntity && typeof updatedEntity['is_mandatory'] === 'boolean') {
|
|
200
194
|
updatedEntity['is_mandatory'] = updatedEntity['is_mandatory'] ? '1' : '0';
|
|
201
195
|
}
|
|
202
196
|
|
|
197
|
+
// -------------------------------
|
|
198
|
+
// Logging Activity
|
|
199
|
+
// -------------------------------
|
|
203
200
|
try {
|
|
204
201
|
if (isCompletedStatus && isStatusChanged) {
|
|
205
202
|
const completedLogData = {
|
|
@@ -234,7 +231,6 @@ export class TaskService extends EntityServiceImpl {
|
|
|
234
231
|
'Failed to log activity for task:',
|
|
235
232
|
error?.message || error,
|
|
236
233
|
);
|
|
237
|
-
// Don't block main flow
|
|
238
234
|
}
|
|
239
235
|
|
|
240
236
|
return updatedEntity;
|
|
@@ -524,12 +520,13 @@ export class TaskService extends EntityServiceImpl {
|
|
|
524
520
|
loggedInUser: any,
|
|
525
521
|
) {
|
|
526
522
|
if (!entity || !entity.mapped_entity_id || !entity.reason_code) return null;
|
|
527
|
-
const listMasterItemRepo =
|
|
523
|
+
const listMasterItemRepo =
|
|
524
|
+
this.reflectionHelper.getRepoService('ListMasterItems');
|
|
528
525
|
const reason = await listMasterItemRepo.findOne({
|
|
529
526
|
where: {
|
|
530
527
|
id: entity.reason_code,
|
|
531
528
|
organization_id: loggedInUser.organization_id,
|
|
532
|
-
}
|
|
529
|
+
},
|
|
533
530
|
});
|
|
534
531
|
|
|
535
532
|
const notePayload = {
|
|
@@ -4,57 +4,65 @@ import { DataSource } from 'typeorm';
|
|
|
4
4
|
|
|
5
5
|
@Injectable()
|
|
6
6
|
export class WorkflowListMasterService extends EntityServiceImpl {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor() {
|
|
8
8
|
super();
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async getActionCategoryListByStageId(stageId: number): Promise<any[]> {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ac.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const stageActionMapping = this.reflectionHelper.getRepoService('StageActionMapping');
|
|
13
|
+
|
|
14
|
+
const results = await stageActionMapping
|
|
15
|
+
.createQueryBuilder("sam")
|
|
16
|
+
.select([
|
|
17
|
+
"ac.name AS name",
|
|
18
|
+
"ac.logo AS logo",
|
|
19
|
+
"ac.modalname AS modalname",
|
|
20
|
+
"a.action_requirement AS actionRequirement",
|
|
21
|
+
])
|
|
22
|
+
.innerJoin("frm_wf_action", "a", "a.id = sam.action_id")
|
|
23
|
+
.innerJoin("frm_wf_action_category", "ac", "ac.id = a.action_category")
|
|
24
|
+
.where("sam.stage_id = :stageId", { stageId })
|
|
25
|
+
.getRawMany();
|
|
26
26
|
|
|
27
27
|
// Add actionStatus and return formatted output
|
|
28
|
-
return results.map((item
|
|
28
|
+
return results.map((item) => ({
|
|
29
29
|
name: item.name,
|
|
30
30
|
logo: item.logo,
|
|
31
|
-
|
|
31
|
+
modalname: item.modalname,
|
|
32
32
|
actionRequirement: item.actionRequirement,
|
|
33
|
-
actionStatus:
|
|
33
|
+
actionStatus: "Done",
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async getStagesByGroup(stageGroupId: number): Promise<any[]> {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
let stageRepo = this.reflectionHelper.getRepoService('Stage');
|
|
39
|
+
|
|
40
|
+
const results = await stageRepo.find({
|
|
41
|
+
where: {
|
|
42
|
+
stage_group_id: stageGroupId
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return results.map(stage => ({
|
|
47
|
+
id: stage.id,
|
|
48
|
+
full_name: stage.full_name,
|
|
49
|
+
}));
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
async getModes(loggedInUser): Promise<any[]> {
|
|
46
53
|
const { organization_id } = loggedInUser;
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
let listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
56
|
+
const modes = await listMasterItemsRepo.find({
|
|
57
|
+
where: {
|
|
58
|
+
listtype: 'MOD',
|
|
59
|
+
organization_id
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return modes.map(mode => ({
|
|
64
|
+
id: mode.id,
|
|
65
|
+
name: mode.name,
|
|
66
|
+
}));
|
|
59
67
|
}
|
|
60
68
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BadGatewayException,
|
|
3
|
-
Inject,
|
|
4
|
-
Injectable,
|
|
5
|
-
Logger,
|
|
6
|
-
} from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
7
2
|
import { ConfigService } from '@nestjs/config';
|
|
8
3
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
4
|
import axios from 'axios';
|
|
10
5
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
11
6
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
12
|
-
import {
|
|
7
|
+
import { In, Repository } from 'typeorm';
|
|
13
8
|
import { StageMovementData } from '../entity/stage-movement-data.entity';
|
|
14
9
|
import { ACTIVITY_CATEGORIES } from '../repository/activity-log.repository';
|
|
15
10
|
import { StageMovementRepository } from '../repository/stage-movement.repository';
|
|
@@ -20,6 +15,8 @@ import { EntityModificationService } from './entity-modification.service';
|
|
|
20
15
|
import { TaskService } from './task.service';
|
|
21
16
|
import { ActionCategory } from '../entity/action-category.entity';
|
|
22
17
|
import { StageGroup } from '../entity/stage-group.entity';
|
|
18
|
+
import { ActionDataEntity } from '../entity/action-data.entity';
|
|
19
|
+
import { TaskDataEntity } from '../entity/task-data.entity';
|
|
23
20
|
|
|
24
21
|
@Injectable()
|
|
25
22
|
export class WorkflowMetaService extends EntityServiceImpl {
|
|
@@ -27,7 +24,6 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
27
24
|
@InjectRepository(StageMovementData)
|
|
28
25
|
private readonly stageMovementRepo: Repository<StageMovementData>,
|
|
29
26
|
private readonly stageMovementRepository: StageMovementRepository,
|
|
30
|
-
private readonly dataSource: DataSource,
|
|
31
27
|
private readonly taskRepository: TaskRepository,
|
|
32
28
|
private readonly actionDataService: ActionDataService,
|
|
33
29
|
@Inject('TaskService')
|
|
@@ -41,6 +37,10 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
41
37
|
private readonly actionCategoryRepo: Repository<ActionCategory>,
|
|
42
38
|
@InjectRepository(StageGroup)
|
|
43
39
|
private readonly stageGroupRepo: Repository<StageGroup>,
|
|
40
|
+
@InjectRepository(ActionDataEntity)
|
|
41
|
+
private readonly actionDataEntityRepository:Repository<ActionDataEntity>,
|
|
42
|
+
@InjectRepository(TaskDataEntity)
|
|
43
|
+
private readonly taskDataEntityRepository:Repository<TaskDataEntity>,
|
|
44
44
|
) {
|
|
45
45
|
super();
|
|
46
46
|
}
|
|
@@ -92,7 +92,7 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
92
92
|
if (!latestMovement) return null;
|
|
93
93
|
|
|
94
94
|
let stageGroup = await this.stageGroupRepo.findOne({
|
|
95
|
-
where: {id: latestMovement?.stage_group_id}
|
|
95
|
+
where: { id: latestMovement?.stage_group_id },
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
return {
|
|
@@ -103,7 +103,7 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
103
103
|
|
|
104
104
|
// get group name for the current stage
|
|
105
105
|
const stageGroup = await this.stageGroupRepo.findOne({
|
|
106
|
-
where: {id: currentStage?.stage_group_id}
|
|
106
|
+
where: { id: currentStage?.stage_group_id },
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
// Return the found or newly created current stage movement
|
|
@@ -132,8 +132,8 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
132
132
|
const stageGroup = await this.stageGroupRepo.findOne({
|
|
133
133
|
where: {
|
|
134
134
|
id: nextStage?.stage_group_id,
|
|
135
|
-
}
|
|
136
|
-
})
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
137
|
|
|
138
138
|
return {
|
|
139
139
|
hasNextStage: !!nextStage,
|
|
@@ -227,8 +227,8 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
227
227
|
const actionCategory = await actionCategoryRepo.findOne({
|
|
228
228
|
where: {
|
|
229
229
|
id: Number(action.action_category),
|
|
230
|
-
}
|
|
231
|
-
})
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
232
|
|
|
233
233
|
if (actionCategory?.code == 'SGCP') {
|
|
234
234
|
await this.taskRepository.updateTaskStatus(
|
|
@@ -339,17 +339,17 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
339
339
|
|
|
340
340
|
const actionCategory = await this.actionCategoryRepo.findOne({
|
|
341
341
|
where: {
|
|
342
|
-
id: Number(firstAction.action_category)
|
|
343
|
-
}
|
|
344
|
-
})
|
|
342
|
+
id: Number(firstAction.action_category),
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
345
|
|
|
346
346
|
const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
347
347
|
|
|
348
348
|
const assignmentType = await listMasterItemsRepo.findOne({
|
|
349
349
|
where: {
|
|
350
|
-
id:Number(firstAction.assignment_type)
|
|
351
|
-
}
|
|
352
|
-
})
|
|
350
|
+
id: Number(firstAction.assignment_type),
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
353
|
|
|
354
354
|
// save in action data
|
|
355
355
|
await this.actionDataService.saveActionData(
|
|
@@ -413,13 +413,14 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
413
413
|
loggedInUser,
|
|
414
414
|
);
|
|
415
415
|
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
416
|
+
const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
417
|
+
const unassignedListMasterItemData = await listMasterItemsRepo.find({
|
|
418
|
+
where: {
|
|
419
|
+
listtype: 'LEST',
|
|
420
|
+
organization_id: loggedInUser.organization_id,
|
|
421
|
+
value: In(['unassigned', 'active'])
|
|
422
|
+
}
|
|
423
|
+
});
|
|
423
424
|
|
|
424
425
|
// Find the IDs explicitly
|
|
425
426
|
const unassignedId = unassignedListMasterItemData.find(
|
|
@@ -444,50 +445,54 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
444
445
|
loggedInUser,
|
|
445
446
|
);
|
|
446
447
|
|
|
447
|
-
await this.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
448
|
+
await this.actionDataEntityRepository
|
|
449
|
+
.createQueryBuilder()
|
|
450
|
+
.update()
|
|
451
|
+
.set({ user_id: lead_owner })
|
|
452
|
+
.where("mapped_entity_id = :leadId", { leadId: lead_id })
|
|
453
|
+
.andWhere("mapped_entity_type = :entityType", { entityType: entity_type })
|
|
454
|
+
.andWhere("stage_id = :stageId", { stageId: stage_id })
|
|
455
|
+
.andWhere("(is_current = 'Y' OR is_current IS NULL)")
|
|
456
|
+
.execute();
|
|
457
|
+
|
|
458
|
+
const leadMeetingRepo = this.reflectionHelper.getRepoService('LeadScheduleMeet');
|
|
459
|
+
|
|
460
|
+
await leadMeetingRepo
|
|
461
|
+
.createQueryBuilder()
|
|
462
|
+
.update()
|
|
463
|
+
.set({ user_id: lead_owner })
|
|
464
|
+
.where("stage_id = :stageId", { stageId: stage_id })
|
|
465
|
+
.andWhere("mapped_entity_id = :leadId", { leadId: lead_id })
|
|
466
|
+
.andWhere("mapped_entity_type = :entityType", { entityType: "LEAD" })
|
|
467
|
+
.andWhere("(status = 'scheduled' OR status = 'rescheduled')")
|
|
468
|
+
.execute();
|
|
469
|
+
|
|
470
|
+
const taskRows = await this.taskDataEntityRepository.find({
|
|
471
|
+
where: {
|
|
472
|
+
mapped_entity_id: lead_id,
|
|
473
|
+
mapped_entity_type: entity_type,
|
|
474
|
+
stage_id
|
|
475
|
+
}
|
|
476
|
+
});
|
|
474
477
|
|
|
475
478
|
for (const task of taskRows) {
|
|
476
|
-
const statusRows = await
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
const statusRows = await listMasterItemsRepo.findOne({
|
|
480
|
+
where: {
|
|
481
|
+
id: task.status,
|
|
482
|
+
organization_id: loggedInUser.organization_id
|
|
483
|
+
}
|
|
484
|
+
});
|
|
481
485
|
|
|
482
|
-
const statusName = statusRows
|
|
486
|
+
const statusName = statusRows?.value?.toLowerCase() || '';
|
|
483
487
|
if (
|
|
484
488
|
['todo', 'in_progress'].includes(statusName) ||
|
|
485
489
|
statusName === 'todo'
|
|
486
490
|
) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
+
|
|
492
|
+
await this.taskDataEntityRepository.update(task.id,{
|
|
493
|
+
user_id: lead_owner,
|
|
494
|
+
task_owner: lead_owner
|
|
495
|
+
});
|
|
491
496
|
}
|
|
492
497
|
}
|
|
493
498
|
|
|
@@ -572,19 +577,18 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
572
577
|
|
|
573
578
|
// 2) Find the last assigned *eligible* owner (use IN (...))
|
|
574
579
|
const placeholders = userIds.map(() => '?').join(',');
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
);
|
|
580
|
+
|
|
581
|
+
const leadRepo = this.reflectionHelper.getRepoService('CRMLead');
|
|
582
|
+
const lastRow = await leadRepo
|
|
583
|
+
.createQueryBuilder("cl")
|
|
584
|
+
.select("cl.lead_owner", "lead_owner")
|
|
585
|
+
.where("cl.organization_id = :orgId", { orgId: organization_id })
|
|
586
|
+
.andWhere("cl.level_id = :levelId", { levelId: Number(level_id) })
|
|
587
|
+
.andWhere("cl.level_type = :levelType", { levelType: level_type })
|
|
588
|
+
.andWhere("cl.lead_owner IN (:...owners)", { owners: userIds })
|
|
589
|
+
.orderBy("cl.created_date", "DESC")
|
|
590
|
+
.limit(1)
|
|
591
|
+
.getRawOne();
|
|
588
592
|
|
|
589
593
|
const lastAssigned = lastRow.length ? Number(lastRow[0].lead_owner) : null;
|
|
590
594
|
|