rez_core 2.2.31 → 2.2.33

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.
Files changed (35) hide show
  1. package/dist/module/workflow/controller/action-category.controller.d.ts +10 -10
  2. package/dist/module/workflow/controller/action-category.controller.js +11 -16
  3. package/dist/module/workflow/controller/action-category.controller.js.map +1 -1
  4. package/dist/module/workflow/controller/task.controller.d.ts +9 -0
  5. package/dist/module/workflow/controller/task.controller.js +14 -0
  6. package/dist/module/workflow/controller/task.controller.js.map +1 -1
  7. package/dist/module/workflow/entity/task-data.entity.js +1 -1
  8. package/dist/module/workflow/entity/task-data.entity.js.map +1 -1
  9. package/dist/module/workflow/repository/action-category.repository.d.ts +18 -0
  10. package/dist/module/workflow/repository/action-category.repository.js +67 -0
  11. package/dist/module/workflow/repository/action-category.repository.js.map +1 -0
  12. package/dist/module/workflow/repository/action.repository.d.ts +4 -0
  13. package/dist/module/workflow/repository/action.repository.js +104 -0
  14. package/dist/module/workflow/repository/action.repository.js.map +1 -1
  15. package/dist/module/workflow/service/action-category.service.d.ts +12 -5
  16. package/dist/module/workflow/service/action-category.service.js +10 -30
  17. package/dist/module/workflow/service/action-category.service.js.map +1 -1
  18. package/dist/module/workflow/service/action.service.js +3 -98
  19. package/dist/module/workflow/service/action.service.js.map +1 -1
  20. package/dist/module/workflow/service/task.service.d.ts +11 -1
  21. package/dist/module/workflow/service/task.service.js +48 -2
  22. package/dist/module/workflow/service/task.service.js.map +1 -1
  23. package/dist/module/workflow/workflow.module.js +4 -0
  24. package/dist/module/workflow/workflow.module.js.map +1 -1
  25. package/dist/tsconfig.build.tsbuildinfo +1 -1
  26. package/package.json +1 -1
  27. package/src/module/workflow/controller/action-category.controller.ts +4 -19
  28. package/src/module/workflow/controller/task.controller.ts +18 -0
  29. package/src/module/workflow/entity/task-data.entity.ts +1 -1
  30. package/src/module/workflow/repository/action-category.repository.ts +56 -0
  31. package/src/module/workflow/repository/action.repository.ts +151 -0
  32. package/src/module/workflow/service/action-category.service.ts +11 -42
  33. package/src/module/workflow/service/action.service.ts +3 -141
  34. package/src/module/workflow/service/task.service.ts +80 -0
  35. package/src/module/workflow/workflow.module.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.2.31",
3
+ "version": "2.2.33",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -21,22 +21,14 @@ export class ActionCategoryController {
21
21
 
22
22
  @Post('/getActionsCategory')
23
23
  @HttpCode(HttpStatus.OK)
24
- async getActionsCat(
25
- @Req() req: Request & { user: any },
26
- @Body('entity_type') entity_type: string,
27
- ) {
28
- const loggedInUser = req.user.userData;
29
- const result = this.actionCategoryService.getActionsCat(
30
- loggedInUser,
31
- entity_type,
32
- );
24
+ async getActionsCat(@Body('entity_type') entity_type: string) {
25
+ const result = this.actionCategoryService.getActionsCat(entity_type);
33
26
  return result;
34
27
  }
35
28
 
36
29
  @Post('/getreasoncode')
37
30
  @HttpCode(HttpStatus.OK)
38
31
  async getReasonCodeByActionCategoryId(
39
- @Req() req: Request & { user: any },
40
32
  @Body('action_cat_code') action_cat_code: string,
41
33
  ) {
42
34
  const result =
@@ -48,15 +40,8 @@ export class ActionCategoryController {
48
40
 
49
41
  @Post('/getactioncategorydata')
50
42
  @HttpCode(HttpStatus.OK)
51
- async getActionCategory(
52
- @Req() req: Request & { user: any },
53
- @Body('action_cat_id') action_cat_id: number,
54
- ) {
55
- const loggedInUser = req.user.userData;
56
- const result = this.actionCategoryService.getActionCategory(
57
- loggedInUser,
58
- action_cat_id,
59
- );
43
+ async getActionCategory(@Body('action_cat_id') action_cat_id: number) {
44
+ const result = this.actionCategoryService.getActionCategory(action_cat_id);
60
45
  return result;
61
46
  }
62
47
  }
@@ -54,4 +54,22 @@ export class TaskController {
54
54
  const result = this.taskService.moveTask(loggedInUser, body);
55
55
  return result;
56
56
  }
57
+
58
+ @Post('/listing')
59
+ @HttpCode(HttpStatus.OK)
60
+ async getAllTask(
61
+ @Req() req: Request & { user: any },
62
+ @Body()
63
+ body: {
64
+ mapped_entity_type: string;
65
+ mapped_entity_id: number;
66
+ status?: string;
67
+ mandatory?: boolean;
68
+ overdue?: boolean;
69
+ },
70
+ ) {
71
+ const loggedInUser = req.user.userData;
72
+ const result = this.taskService.getAllTask(loggedInUser, body);
73
+ return result;
74
+ }
57
75
  }
@@ -53,7 +53,7 @@ export class TaskDataEntity extends BaseEntity {
53
53
  @Column({ nullable: true })
54
54
  task_owner: string;
55
55
 
56
- @Column({ nullable: true, type: 'varchar' })
56
+ @Column({ nullable: true })
57
57
  due_date: Date;
58
58
 
59
59
  @Column({ nullable: true, type: 'varchar' })
@@ -0,0 +1,56 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { Repository } from 'typeorm';
4
+ import { ActionCategory } from '../entity/action-category.entity';
5
+ import { UserData } from 'src/module/user/entity/user.entity';
6
+
7
+ @Injectable()
8
+ export class ActionCategoryRepository {
9
+ constructor(
10
+ @InjectRepository(ActionCategory)
11
+ private readonly actionCategoryRepository: Repository<ActionCategory>,
12
+ ) {}
13
+
14
+ async getActionsCat(entity_type: string) {
15
+ const result = await this.actionCategoryRepository
16
+ .createQueryBuilder('ac')
17
+ .select(['ac.id', 'ac.name'])
18
+ .where('ac.mapped_entity_type = :entityType', { entityType: entity_type })
19
+ .getRawMany();
20
+
21
+ return result.map((row) => ({
22
+ label: row.ac_name,
23
+ value: String(row.ac_id),
24
+ }));
25
+ }
26
+
27
+ async getReasonCodeByActionCategoryId(action_cat_code: string) {
28
+ const result = await this.actionCategoryRepository
29
+ .createQueryBuilder('ac')
30
+ .select(['ac.id', 'ac.reason_code'])
31
+ .where('ac.code = :code', { code: action_cat_code })
32
+ .getOne();
33
+
34
+ if (!result || !result.reason_code) {
35
+ return {
36
+ success: false,
37
+ value: null,
38
+ };
39
+ }
40
+
41
+ return {
42
+ success: true,
43
+ value: result.reason_code,
44
+ };
45
+ }
46
+
47
+ async getActionCategory(action_cat_id: number) {
48
+ const result = await this.actionCategoryRepository
49
+ .createQueryBuilder('ac')
50
+ .select(['ac.*'])
51
+ .where('ac.id = :id', { id: action_cat_id })
52
+ .getRawMany();
53
+
54
+ return result;
55
+ }
56
+ }
@@ -7,6 +7,7 @@ import {
7
7
  import { InjectRepository } from '@nestjs/typeorm';
8
8
  import { DataSource, Repository } from 'typeorm';
9
9
  import { ActionEntity } from '../entity/action.entity';
10
+ import { UserData } from 'src/module/user/entity/user.entity';
10
11
 
11
12
  @Injectable()
12
13
  export class ActionRepository {
@@ -16,6 +17,156 @@ export class ActionRepository {
16
17
  private readonly dataSource: DataSource,
17
18
  ) {}
18
19
 
20
+ async getReasonCode(loggedInUser: UserData): Promise<any> {
21
+ const { organization_id } = loggedInUser;
22
+ const result = await this.dataSource.query(
23
+ `
24
+ SELECT name, type
25
+ FROM cr_list_master
26
+ WHERE organization_id = ? AND source = 'master'
27
+ `,
28
+ [organization_id],
29
+ );
30
+
31
+ const formatted = result.map((item: any) => ({
32
+ label: item.name,
33
+ value: item.type,
34
+ }));
35
+
36
+ return formatted;
37
+ }
38
+
39
+ async defaultReasonCode(list_type: string, loggedInUser: UserData) {
40
+ const { organization_id } = loggedInUser;
41
+ if (!list_type) {
42
+ throw new BadRequestException('list_type is required');
43
+ }
44
+ const result = await this.dataSource.query(
45
+ `
46
+ SELECT name, id
47
+ FROM cr_list_master_items
48
+ WHERE listtype = ? AND organization_id = ?
49
+ `,
50
+ [list_type, organization_id],
51
+ );
52
+
53
+ // Format as array of key-value pairs
54
+ return result.map((row: any) => ({
55
+ label: row.name,
56
+ value: row.id,
57
+ }));
58
+ }
59
+
60
+ async getActions(loggedInUser: UserData, stage_id: number) {
61
+ const { organization_id } = loggedInUser;
62
+
63
+ // Step 1: Get all action_ids for the provided stage_id
64
+ const stageActions = await this.dataSource.query(
65
+ `
66
+ SELECT id, action_id
67
+ FROM cr_wf_stage_action_mapping
68
+ WHERE stage_id = ?
69
+ `,
70
+ [stage_id],
71
+ );
72
+
73
+ if (!stageActions?.length) return [];
74
+
75
+ const actionIds = stageActions.map((sa) => sa.action_id);
76
+ const mappingIds = stageActions.map((sa) => sa.id);
77
+
78
+ // Step 2: Get template codes with mapping IDs
79
+ const templateMappings = await this.dataSource.query(
80
+ `
81
+ SELECT stg_act_mapping_id, template_code
82
+ FROM cr_wf_action_template_mapping
83
+ WHERE stg_act_mapping_id IN (${mappingIds.map(() => '?').join(',')})
84
+ `,
85
+ mappingIds,
86
+ );
87
+
88
+ const templateCodes = templateMappings.map((tm) => tm.template_code);
89
+
90
+ // Step 3: Fetch template names from cr_wf_comm_template
91
+ const templateCodeToName: Record<string, string> = {};
92
+
93
+ if (templateCodes.length > 0) {
94
+ const templates = await this.dataSource
95
+ .createQueryBuilder()
96
+ .select(['t.code AS code', 't.name AS name'])
97
+ .from('cr_wf_comm_template', 't')
98
+ .where('t.code IN (:...codes)', { codes: templateCodes })
99
+ .andWhere('t.organization_id = :orgId', { orgId: organization_id })
100
+ .getRawMany();
101
+
102
+ templates.forEach((tpl) => {
103
+ templateCodeToName[tpl.code] = tpl.name;
104
+ });
105
+ }
106
+
107
+ // Step 4: Build map of mapping_id → template names
108
+ const mappingIdToTemplates: Record<number, string[]> = {};
109
+
110
+ for (const tm of templateMappings) {
111
+ const mappingId = tm.stg_act_mapping_id;
112
+ const name = templateCodeToName[tm.template_code];
113
+ if (name) {
114
+ if (!mappingIdToTemplates[mappingId]) {
115
+ mappingIdToTemplates[mappingId] = [];
116
+ }
117
+ mappingIdToTemplates[mappingId].push(name);
118
+ }
119
+ }
120
+
121
+ // Step 5: Build action_id → template names using mappingIdToTemplates + stageActions
122
+ const actionIdToTemplates: Record<number, string[]> = {};
123
+
124
+ for (const sa of stageActions) {
125
+ const mappingId = sa.id;
126
+ const templates = mappingIdToTemplates[mappingId];
127
+ if (templates?.length) {
128
+ if (!actionIdToTemplates[sa.action_id]) {
129
+ actionIdToTemplates[sa.action_id] = [];
130
+ }
131
+ actionIdToTemplates[sa.action_id].push(...templates);
132
+ }
133
+ }
134
+
135
+ // Step 6: Fetch action details
136
+ const actionResults = await this.dataSource
137
+ .createQueryBuilder()
138
+ .select([
139
+ 'a.*',
140
+ 'ac.name AS action_category',
141
+ 'ar.name AS action_requirement',
142
+ ])
143
+ .from('cr_wf_action', 'a')
144
+ .leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
145
+ .leftJoin(
146
+ 'cr_list_master_items',
147
+ 'ar',
148
+ `ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
149
+ { orgId: organization_id },
150
+ )
151
+ .where('a.organization_id = :orgId', { orgId: organization_id })
152
+ .andWhere('a.id IN (:...actionIds)', { actionIds })
153
+ .getRawMany();
154
+
155
+ // Step 7: Enrich result with template field
156
+ const enrichedResult = actionResults.map((row) => {
157
+ const actionId = Number(row.id); // Ensure numeric ID match
158
+ const templates = actionIdToTemplates[actionId] || [];
159
+ const uniqueTemplates = [...new Set(templates)]; // remove duplicates
160
+
161
+ return {
162
+ ...row,
163
+ template: uniqueTemplates.join(', '),
164
+ };
165
+ });
166
+
167
+ return enrichedResult;
168
+ }
169
+
19
170
  async getAction(
20
171
  organization_id: number,
21
172
  stage_id: number,
@@ -2,59 +2,28 @@ import { Injectable } from '@nestjs/common';
2
2
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
3
  import { UserData } from 'src/module/user/entity/user.entity';
4
4
  import { DataSource } from 'typeorm';
5
+ import { ActionCategoryRepository } from '../repository/action-category.repository';
5
6
 
6
7
  @Injectable()
7
8
  export class ActionCategoryService extends EntityServiceImpl {
8
- constructor(private readonly dataSource: DataSource) {
9
+ constructor(
10
+ private readonly dataSource: DataSource,
11
+ private readonly actionCategoryRepository: ActionCategoryRepository,
12
+ ) {
9
13
  super();
10
14
  }
11
15
 
12
- async getActionsCat(loggedInUser: UserData, entity_type: string) {
13
- const { organization_id } = loggedInUser;
14
-
15
- console.log(entity_type, 'entity_type in action category service');
16
-
17
- const result = await this.dataSource.query(
18
- `
19
- SELECT id, name
20
- FROM cr_wf_action_category
21
- WHERE mapped_entity_type = ?`,
22
- [entity_type],
23
- );
24
-
25
- return result.map((row: any) => ({
26
- label: row.name,
27
- value: row.id,
28
- }));
16
+ async getActionsCat(entity_type: string) {
17
+ return this.actionCategoryRepository.getActionsCat(entity_type);
29
18
  }
30
19
 
31
20
  async getReasonCodeByActionCategoryId(action_cat_code: string) {
32
- const result = await this.dataSource.query(
33
- `
34
- SELECT id, reason_code
35
- FROM cr_wf_action_category
36
- WHERE code = ?
37
- `,
38
- [action_cat_code],
21
+ return this.actionCategoryRepository.getReasonCodeByActionCategoryId(
22
+ action_cat_code,
39
23
  );
40
-
41
- return {
42
- success: true,
43
- value: result?.[0]?.reason_code || null,
44
- };
45
24
  }
46
25
 
47
- async getActionCategory(loggedInUser: UserData, action_cat_id: number) {
48
- const { organization_id } = loggedInUser;
49
- const result = await this.dataSource.query(
50
- `
51
- SELECT *
52
- FROM cr_wf_action_category
53
- WHERE id = ?
54
- `,
55
- [action_cat_id],
56
- );
57
-
58
- return result;
26
+ async getActionCategory(action_cat_id: number) {
27
+ return this.actionCategoryRepository.getActionCategory(action_cat_id);
59
28
  }
60
29
  }
@@ -215,153 +215,15 @@ export class ActionService extends EntityServiceImpl {
215
215
  }
216
216
 
217
217
  async getReasonCode(loggedInUser: UserData): Promise<any> {
218
- const { organization_id } = loggedInUser;
219
- const result = await this.dataSource.query(
220
- `
221
- SELECT name, type
222
- FROM cr_list_master
223
- WHERE organization_id = ? AND source = 'master'
224
- `,
225
- [organization_id],
226
- );
227
-
228
- const formatted = result.map((item: any) => ({
229
- label: item.name,
230
- value: item.type,
231
- }));
232
-
233
- return formatted;
218
+ return this.actionRepository.getReasonCode(loggedInUser);
234
219
  }
235
220
 
236
221
  async defaultReasonCode(list_type: string, loggedInUser: UserData) {
237
- const { organization_id } = loggedInUser;
238
- if (!list_type) {
239
- throw new BadRequestException('list_type is required');
240
- }
241
- const result = await this.dataSource.query(
242
- `
243
- SELECT name, id
244
- FROM cr_list_master_items
245
- WHERE listtype = ? AND organization_id = ?
246
- `,
247
- [list_type, organization_id],
248
- );
249
-
250
- // Format as array of key-value pairs
251
- return result.map((row: any) => ({
252
- label: row.name,
253
- value: row.id,
254
- }));
222
+ return this.actionRepository.defaultReasonCode(list_type, loggedInUser);
255
223
  }
256
224
 
257
225
  async getActions(loggedInUser: UserData, stage_id: number) {
258
- const { organization_id } = loggedInUser;
259
-
260
- // Step 1: Get all action_ids for the provided stage_id
261
- const stageActions = await this.dataSource.query(
262
- `
263
- SELECT id, action_id
264
- FROM cr_wf_stage_action_mapping
265
- WHERE stage_id = ?
266
- `,
267
- [stage_id],
268
- );
269
-
270
- if (!stageActions?.length) return [];
271
-
272
- const actionIds = stageActions.map((sa) => sa.action_id);
273
- const mappingIds = stageActions.map((sa) => sa.id);
274
-
275
- // Step 2: Get template codes with mapping IDs
276
- const templateMappings = await this.dataSource.query(
277
- `
278
- SELECT stg_act_mapping_id, template_code
279
- FROM cr_wf_action_template_mapping
280
- WHERE stg_act_mapping_id IN (${mappingIds.map(() => '?').join(',')})
281
- `,
282
- mappingIds,
283
- );
284
-
285
- const templateCodes = templateMappings.map((tm) => tm.template_code);
286
-
287
- // Step 3: Fetch template names from cr_wf_comm_template
288
- const templateCodeToName: Record<string, string> = {};
289
-
290
- if (templateCodes.length > 0) {
291
- const templates = await this.dataSource
292
- .createQueryBuilder()
293
- .select(['t.code AS code', 't.name AS name'])
294
- .from('cr_wf_comm_template', 't')
295
- .where('t.code IN (:...codes)', { codes: templateCodes })
296
- .andWhere('t.organization_id = :orgId', { orgId: organization_id })
297
- .getRawMany();
298
-
299
- templates.forEach((tpl) => {
300
- templateCodeToName[tpl.code] = tpl.name;
301
- });
302
- }
303
-
304
- // Step 4: Build map of mapping_id → template names
305
- const mappingIdToTemplates: Record<number, string[]> = {};
306
-
307
- for (const tm of templateMappings) {
308
- const mappingId = tm.stg_act_mapping_id;
309
- const name = templateCodeToName[tm.template_code];
310
- if (name) {
311
- if (!mappingIdToTemplates[mappingId]) {
312
- mappingIdToTemplates[mappingId] = [];
313
- }
314
- mappingIdToTemplates[mappingId].push(name);
315
- }
316
- }
317
-
318
- // Step 5: Build action_id → template names using mappingIdToTemplates + stageActions
319
- const actionIdToTemplates: Record<number, string[]> = {};
320
-
321
- for (const sa of stageActions) {
322
- const mappingId = sa.id;
323
- const templates = mappingIdToTemplates[mappingId];
324
- if (templates?.length) {
325
- if (!actionIdToTemplates[sa.action_id]) {
326
- actionIdToTemplates[sa.action_id] = [];
327
- }
328
- actionIdToTemplates[sa.action_id].push(...templates);
329
- }
330
- }
331
-
332
- // Step 6: Fetch action details
333
- const actionResults = await this.dataSource
334
- .createQueryBuilder()
335
- .select([
336
- 'a.*',
337
- 'ac.name AS action_category',
338
- 'ar.name AS action_requirement',
339
- ])
340
- .from('cr_wf_action', 'a')
341
- .leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
342
- .leftJoin(
343
- 'cr_list_master_items',
344
- 'ar',
345
- `ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
346
- { orgId: organization_id },
347
- )
348
- .where('a.organization_id = :orgId', { orgId: organization_id })
349
- .andWhere('a.id IN (:...actionIds)', { actionIds })
350
- .getRawMany();
351
-
352
- // Step 7: Enrich result with template field
353
- const enrichedResult = actionResults.map((row) => {
354
- const actionId = Number(row.id); // Ensure numeric ID match
355
- const templates = actionIdToTemplates[actionId] || [];
356
- const uniqueTemplates = [...new Set(templates)]; // remove duplicates
357
-
358
- return {
359
- ...row,
360
- template: uniqueTemplates.join(', '),
361
- };
362
- });
363
-
364
- return enrichedResult;
226
+ return this.actionRepository.getActions(loggedInUser, stage_id);
365
227
  }
366
228
 
367
229
  async getAction(
@@ -3,12 +3,14 @@ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.s
3
3
  import { UserData } from 'src/module/user/entity/user.entity';
4
4
  import { TaskRepository } from '../repository/task.repository';
5
5
  import { ActionDataService } from './action-data.service';
6
+ import { DataSource } from 'typeorm';
6
7
 
7
8
  @Injectable()
8
9
  export class TaskService extends EntityServiceImpl {
9
10
  constructor(
10
11
  private readonly taskRepository: TaskRepository,
11
12
  private readonly actionDataService: ActionDataService,
13
+ private readonly dataSource: DataSource,
12
14
  ) {
13
15
  super();
14
16
  }
@@ -40,6 +42,60 @@ export class TaskService extends EntityServiceImpl {
40
42
  return grouped;
41
43
  }
42
44
 
45
+ async getAllTask(
46
+ loggedInUser: UserData,
47
+ data: {
48
+ mapped_entity_type: string;
49
+ mapped_entity_id: number;
50
+ status?: string;
51
+ mandatory?: boolean;
52
+ overdue?: boolean;
53
+ },
54
+ ): Promise<any[]> {
55
+ const { mapped_entity_type, mapped_entity_id, status, mandatory, overdue } =
56
+ data;
57
+
58
+ // Build dynamic WHERE clauses
59
+ const whereClauses = [`t.mapped_entity_type = ?`, `t.mapped_entity_id = ?`];
60
+ const params: any[] = [mapped_entity_type, mapped_entity_id];
61
+
62
+ if (status) {
63
+ whereClauses.push(`t.status = ?`);
64
+ params.push(status);
65
+ }
66
+ if (mandatory) {
67
+ whereClauses.push(`t.is_mandatory = ?`);
68
+ params.push(mandatory ? 1 : 0);
69
+ }
70
+
71
+ if (overdue) {
72
+ whereClauses.push(
73
+ `(t.due_date < CURDATE() OR (t.due_date = CURDATE() AND t.due_time < CURTIME()))`,
74
+ );
75
+ // exclude tasks that are already completed
76
+ whereClauses.push(`t.is_done = ?`);
77
+ params.push(0); // Only include tasks that are not done
78
+ }
79
+
80
+ const sql = `
81
+ SELECT
82
+ t.*,
83
+ sg.name AS stage_group_name,
84
+ s.name AS stage_name,
85
+ a.name AS action_name
86
+ FROM cr_wf_task_data t
87
+ LEFT JOIN cr_wf_stage s ON t.stage_id = s.id
88
+ LEFT JOIN cr_wf_stage_group sg ON s.stage_group_id = sg.id
89
+ LEFT JOIN cr_wf_action a ON t.action_id = a.id
90
+ WHERE ${whereClauses.join(' AND ')}
91
+ ORDER BY t.due_date ASC, t.due_time ASC
92
+ `;
93
+
94
+ const taskData = await this.dataSource.query(sql, params);
95
+
96
+ return taskData;
97
+ }
98
+
43
99
  async getEntityData(entityType: string, id: number, loggedInUser: any) {
44
100
  const taskData = await super.getEntityData(entityType, id, loggedInUser);
45
101
 
@@ -92,4 +148,28 @@ export class TaskService extends EntityServiceImpl {
92
148
 
93
149
  return 'Task moved successfully';
94
150
  }
151
+
152
+ async deleteEntity(
153
+ entity_type: string,
154
+ taskId,
155
+ loggedInUser: UserData,
156
+ ): Promise<any> {
157
+ // Logic to delete a task by its ID
158
+ const task: any = await super.getEntityData(
159
+ entity_type,
160
+ taskId,
161
+ loggedInUser,
162
+ );
163
+ if (!task) {
164
+ throw new Error('Task not found');
165
+ }
166
+
167
+ // Check if the task is system-generated using is_system flag
168
+ if (task.is_system) {
169
+ throw new Error('Cannot delete system-generated tasks');
170
+ }
171
+
172
+ // Perform the deletion
173
+ await super.deleteEntity(entity_type, taskId, loggedInUser);
174
+ }
95
175
  }
@@ -56,6 +56,7 @@ import { FormMasterRepository } from './repository/form-master.repository';
56
56
  import { ActionResourcesMapping } from './entity/action-resources-mapping.entity';
57
57
  import { ActionResourcesMappingService } from './service/action-resources-mapping.service';
58
58
  import { ActionResourcesMappingController } from './controller/action-resource-mapping.controller';
59
+ import { ActionCategoryRepository } from './repository/action-category.repository';
59
60
 
60
61
  @Module({
61
62
  imports: [
@@ -117,6 +118,7 @@ import { ActionResourcesMappingController } from './controller/action-resource-m
117
118
  ActionDataRepository,
118
119
  ActionDataService,
119
120
  FormMasterRepository,
121
+ ActionCategoryRepository,
120
122
  ],
121
123
  exports: [
122
124
  'ActionCategoryService',
@@ -128,11 +130,13 @@ import { ActionResourcesMappingController } from './controller/action-resource-m
128
130
  'EntityModificationService',
129
131
  'FormMasterService',
130
132
  'ActionResourcesMappingService',
133
+ 'TaskService',
131
134
  WorkflowRepository,
132
135
  StageGroupRepository,
133
136
  StageRepository,
134
137
  WorkflowMetaService,
135
138
  PopulateWorkflowService,
139
+ ActionCategoryRepository,
136
140
  ],
137
141
  controllers: [
138
142
  WorkflowListMasterController,