rez_core 2.1.158 → 2.1.159

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 (36) hide show
  1. package/dist/constant/global.constant.d.ts +1 -0
  2. package/dist/constant/global.constant.js +2 -1
  3. package/dist/constant/global.constant.js.map +1 -1
  4. package/dist/module/workflow/controller/action-category.controller.d.ts +6 -0
  5. package/dist/module/workflow/controller/action-category.controller.js +14 -0
  6. package/dist/module/workflow/controller/action-category.controller.js.map +1 -1
  7. package/dist/module/workflow/controller/action-resource-mapping.controller.d.ts +5 -0
  8. package/dist/module/workflow/controller/action-resource-mapping.controller.js +31 -0
  9. package/dist/module/workflow/controller/action-resource-mapping.controller.js.map +1 -0
  10. package/dist/module/workflow/controller/action.controller.d.ts +3 -0
  11. package/dist/module/workflow/entity/action-category.entity.d.ts +3 -0
  12. package/dist/module/workflow/entity/action-category.entity.js +12 -0
  13. package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
  14. package/dist/module/workflow/entity/action-resources-mapping.entity.d.ts +7 -0
  15. package/dist/module/workflow/entity/action-resources-mapping.entity.js +39 -0
  16. package/dist/module/workflow/entity/action-resources-mapping.entity.js.map +1 -0
  17. package/dist/module/workflow/repository/action.repository.d.ts +3 -0
  18. package/dist/module/workflow/repository/action.repository.js +28 -3
  19. package/dist/module/workflow/repository/action.repository.js.map +1 -1
  20. package/dist/module/workflow/service/action-category.service.d.ts +4 -0
  21. package/dist/module/workflow/service/action-category.service.js +12 -0
  22. package/dist/module/workflow/service/action-category.service.js.map +1 -1
  23. package/dist/module/workflow/service/action-resources-mapping.service.d.ts +6 -0
  24. package/dist/module/workflow/service/action-resources-mapping.service.js +27 -0
  25. package/dist/module/workflow/service/action-resources-mapping.service.js.map +1 -0
  26. package/dist/module/workflow/service/action.service.d.ts +3 -0
  27. package/dist/tsconfig.build.tsbuildinfo +1 -1
  28. package/package.json +1 -1
  29. package/src/constant/global.constant.ts +1 -0
  30. package/src/module/workflow/controller/action-category.controller.ts +14 -0
  31. package/src/module/workflow/controller/action-resource-mapping.controller.ts +23 -0
  32. package/src/module/workflow/entity/action-category.entity.ts +9 -0
  33. package/src/module/workflow/entity/action-resources-mapping.entity.ts +23 -0
  34. package/src/module/workflow/repository/action.repository.ts +39 -7
  35. package/src/module/workflow/service/action-category.service.ts +20 -0
  36. package/src/module/workflow/service/action-resources-mapping.service.ts +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.158",
3
+ "version": "2.1.159",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -52,3 +52,4 @@ export const WORKFLOW_DATA = 'WFDT';
52
52
  export const STAGE_MOVEMENT_DATA = 'STMV';
53
53
 
54
54
  export const ENTITY_MODIFICATION = 'ENMD';
55
+ export const ACTION_RESOURCES_MAPPING = 'ARMS';
@@ -32,4 +32,18 @@ export class ActionCategoryController {
32
32
  );
33
33
  return result;
34
34
  }
35
+
36
+ @Post('/getreasoncode')
37
+ @HttpCode(HttpStatus.OK)
38
+ async getReasonCodeByActionCategoryId(
39
+ @Req() req: Request & { user: any },
40
+ @Body('action_cat_code') action_cat_code: string,
41
+ ) {
42
+ const loggedInUser = req.user.userData;
43
+ const result = this.actionCategoryService.getReasonCodeByActionCategoryId(
44
+ loggedInUser,
45
+ action_cat_code,
46
+ );
47
+ return result;
48
+ }
35
49
  }
@@ -0,0 +1,23 @@
1
+ import {
2
+ Body,
3
+ Controller,
4
+ HttpCode,
5
+ HttpStatus,
6
+ Inject,
7
+ Post,
8
+ Req,
9
+ UseGuards,
10
+ } from '@nestjs/common';
11
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
12
+ import { ActionCategoryService } from '../service/action-category.service';
13
+ import { ActionResourcesMapping } from '../entity/action-resources-mapping.entity';
14
+ import { ActionResourcesMappingService } from '../service/action-resources-mapping.service';
15
+
16
+ @Controller('/actionResourcesMapping')
17
+ @UseGuards(JwtAuthGuard)
18
+ export class ActionResourcesMappingController {
19
+ constructor(
20
+ @Inject('ActionResourcesMappingService')
21
+ private readonly actionResourcesMapping: ActionResourcesMappingService,
22
+ ) {}
23
+ }
@@ -17,4 +17,13 @@ export class ActionCategory extends BaseEntity {
17
17
 
18
18
  @Column({ type: 'varchar', nullable: true })
19
19
  mapped_entity_type: string;
20
+
21
+ @Column({ type: 'varchar', nullable: true })
22
+ reason_code: string;
23
+
24
+ @Column({ type: 'boolean', nullable: true })
25
+ is_template: boolean;
26
+
27
+ @Column({ type: 'boolean', nullable: true })
28
+ is_form: boolean;
20
29
  }
@@ -0,0 +1,23 @@
1
+ import {
2
+ ACTION_CATEGORY,
3
+ ACTION_RESOURCES_MAPPING,
4
+ } from 'src/constant/global.constant';
5
+ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
6
+ import { Column, Entity } from 'typeorm';
7
+
8
+ @Entity({ name: 'cr_wf_action_resources_mapping' })
9
+ export class ActionResourcesMapping extends BaseEntity {
10
+ constructor() {
11
+ super();
12
+ this.entity_type = ACTION_RESOURCES_MAPPING;
13
+ }
14
+
15
+ @Column({ type: 'varchar', nullable: true })
16
+ template_code: string;
17
+
18
+ @Column({ type: 'varchar', nullable: true })
19
+ type: string;
20
+
21
+ @Column({ type: 'varchar', nullable: true })
22
+ form_id: string;
23
+ }
@@ -33,12 +33,17 @@ export class ActionRepository {
33
33
 
34
34
  const actionIds = stageActions.map((sa) => sa.action_id);
35
35
 
36
- // Step 2: Fetch all actions from cr_wf_action
36
+ // Step 2: Fetch all actions with category details
37
37
  const actions = await this.dataSource
38
38
  .createQueryBuilder()
39
39
  .select([
40
40
  'a.id AS action_id',
41
41
  'a.name AS action_name',
42
+ 'a.reason_code AS action_reason_code',
43
+ 'a.default_reason_code AS default_reason_code',
44
+ 'a.default_value AS default_value',
45
+ 'a.action_category AS action_category_id',
46
+ 'ac.reason_code AS category_reason_code',
42
47
  'ac.modalName AS modalName',
43
48
  'ac.logo AS logo',
44
49
  'ac.name AS action_category_name',
@@ -49,7 +54,7 @@ export class ActionRepository {
49
54
  .andWhere('a.id IN (:...actionIds)', { actionIds })
50
55
  .getRawMany();
51
56
 
52
- // Step 3: Fetch action_data for the matched stage and entity
57
+ // Step 3: Fetch action_data
53
58
  const actionData = await this.dataSource
54
59
  .createQueryBuilder()
55
60
  .select([
@@ -61,15 +66,12 @@ export class ActionRepository {
61
66
  .from('cr_wf_action_data', 'ad')
62
67
  .where('ad.stage_id = :stageId', { stageId: stage_id })
63
68
  .andWhere('ad.action_id IN (:...actionIds)', { actionIds })
64
- .andWhere('ad.mapped_entity_id = :mapped_entity_id', {
65
- mapped_entity_id,
66
- })
69
+ .andWhere('ad.mapped_entity_id = :mapped_entity_id', { mapped_entity_id })
67
70
  .andWhere('ad.mapped_entity_type = :mapped_entity_type', {
68
71
  mapped_entity_type,
69
72
  })
70
73
  .getRawMany();
71
74
 
72
- // Step 4: Build map of action_id to data
73
75
  const actionIdToData = actionData.reduce((acc, row) => {
74
76
  acc[row.action_id] = {
75
77
  is_current: row.is_current === 'Y',
@@ -79,21 +81,51 @@ export class ActionRepository {
79
81
  return acc;
80
82
  }, {});
81
83
 
82
- // Step 5: Enrich actions and set default current = false (N)
84
+ // Step 4: Resolve all default_reason_code values (regardless of default_value)
85
+ const allDefaultReasonIds = actions
86
+ .filter((row) => row.default_reason_code)
87
+ .map((row) => row.default_reason_code);
88
+
89
+ let defaultReasonMap = {};
90
+ if (allDefaultReasonIds.length > 0) {
91
+ const listItems = await this.dataSource
92
+ .createQueryBuilder()
93
+ .select(['id', 'name'])
94
+ .from('cr_list_master_items', 'li')
95
+ .where('li.id IN (:...ids)', { ids: allDefaultReasonIds })
96
+ .getRawMany();
97
+
98
+ defaultReasonMap = listItems.reduce((acc, item) => {
99
+ acc[item.id] = item.name;
100
+ return acc;
101
+ }, {});
102
+ }
103
+
104
+ // Step 5: Enrich actions
83
105
  const enrichedResult = actions.map((row) => {
84
106
  const data = actionIdToData[row.action_id];
107
+
108
+ const reason_code =
109
+ row.action_reason_code && row.action_reason_code.trim()
110
+ ? row.action_reason_code
111
+ : row.category_reason_code;
112
+
85
113
  return {
86
114
  value: row.action_id,
87
115
  label: row.action_name,
88
116
  modalName: row.modalName,
89
117
  logo: row.logo,
90
118
  name: row.action_category_name,
119
+ reason_code,
120
+ default_reason_code: defaultReasonMap[row.default_reason_code] || null,
121
+ is_default: row.default_value === 1,
91
122
  is_current: data?.is_current ?? false,
92
123
  is_done: data?.is_done ?? false,
93
124
  is_mandatory: data?.is_mandatory ?? false,
94
125
  };
95
126
  });
96
127
 
128
+ // Step 6: Add fallback option
97
129
  enrichedResult.push({
98
130
  value: 0,
99
131
  label: 'Generic',
@@ -27,4 +27,24 @@ export class ActionCategoryService extends EntityServiceImpl {
27
27
  value: row.id,
28
28
  }));
29
29
  }
30
+
31
+ async getReasonCodeByActionCategoryId(
32
+ loggedInUser: UserData,
33
+ action_cat_code: string,
34
+ ) {
35
+ const { organization_id } = loggedInUser;
36
+ const result = await this.dataSource.query(
37
+ `
38
+ SELECT id, reason_code
39
+ FROM cr_wf_action_category
40
+ WHERE organization_id = ? AND code = ?
41
+ `,
42
+ [organization_id, action_cat_code],
43
+ );
44
+
45
+ return {
46
+ success: true,
47
+ value: result?.[0]?.reason_code || null,
48
+ };
49
+ }
30
50
  }
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
+ import { DataSource } from 'typeorm';
4
+
5
+ @Injectable()
6
+ export class ActionResourcesMappingService extends EntityServiceImpl {
7
+ constructor(private readonly dataSource: DataSource) {
8
+ super();
9
+ }
10
+ }