rez_core 5.0.16 → 5.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.16",
3
+ "version": "5.0.17",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -597,10 +597,10 @@ export class EntityDynamicService {
597
597
  );
598
598
 
599
599
  const columns = validAttributes
600
- .map((attr) => `${attr.attribute_key}`)
600
+ .map((attr) => `t.${attr.attribute_key}`)
601
601
  .join(', ');
602
602
  const selectQuery = `SELECT ${columns}
603
- FROM ${tableName}
603
+ FROM ${tableName} t
604
604
  WHERE id = $1`;
605
605
 
606
606
  const result = await this.dataSource.query(selectQuery, [id]);
@@ -13,6 +13,8 @@ import * as moment from 'moment';
13
13
  import { MediaDataService } from 'src/module/meta/service/media-data.service';
14
14
  import axios from 'axios';
15
15
  import { ConfigService } from '@nestjs/config';
16
+ import { ListMasterData } from 'src/module/listmaster/entity/list-master.entity';
17
+ import { StageGroup } from '../entity/stage-group.entity';
16
18
 
17
19
  @Injectable()
18
20
  export class StageGroupService extends EntityServiceImpl {
@@ -27,6 +29,10 @@ export class StageGroupService extends EntityServiceImpl {
27
29
  private readonly stageMovementRepo: Repository<StageMovementData>,
28
30
  private readonly mediaDataService: MediaDataService,
29
31
  private readonly configService: ConfigService,
32
+ @InjectRepository(ListMasterData)
33
+ private readonly listMasterRepo: Repository<ListMasterData>,
34
+ @InjectRepository(StageGroup)
35
+ private readonly stageGroupRepo: Repository<StageGroup>,
30
36
  ) {
31
37
  super();
32
38
  }
@@ -78,38 +84,53 @@ export class StageGroupService extends EntityServiceImpl {
78
84
 
79
85
  // if (!workflowLevelMapping) return null;
80
86
 
81
- let stage_movement_data: StageMovementData[] = [];
82
- stage_movement_data = await this.stageMovementRepo.find({
87
+ let stageMovement = await this.stageMovementRepo.find({
83
88
  where: {
84
89
  mapped_entity_type: 'LEAD',
85
90
  mapped_entity_id: lead_id,
86
91
  },
87
92
  });
88
93
 
89
- let stage_group_data = await this.stageMovementRepo.query(
90
- `SELECT * FROM frm_wf_stage_group WHERE id = $1`,
91
- [stage_movement_data[0].stage_group_id],
92
- );
94
+ if (!stageMovement || stageMovement.length === 0) {
95
+ return [];
96
+ }
97
+
98
+ console.log('stageMovementttegst', stageMovement);
99
+
100
+ const stageGroupData = await this.stageGroupRepo.findOne({
101
+ where: {
102
+ id: stageMovement[0].stage_group_id,
103
+ },
104
+ });
105
+
106
+ if (!stageGroupData) {
107
+ return [];
108
+ }
93
109
 
94
110
  // 3) Lead status (parameterized)
95
111
  let leadStatus: string | null = null;
96
- const leadData = await this.dataSource.query(
97
- `SELECT lead_status FROM crm_lead WHERE id = $1`,
98
- [lead_id],
99
- );
100
- if (leadData.length > 0 && leadData[0].lead_status != null) {
101
- const leadStatusResolved = await this.dataSource.query(
102
- `SELECT name FROM frm_list_master_items WHERE id = $1 AND organization_id = $2`,
103
- [leadData[0].lead_status, loggedInUser.organization_id],
104
- );
105
- if (leadStatusResolved.length > 0) {
106
- leadStatus = leadStatusResolved[0].name;
112
+
113
+ const leadData = await this.getEntityData('LEAD', lead_id, loggedInUser);
114
+ console.log('leadData', leadData);
115
+ const leadRecord = Array.isArray(leadData) ? leadData[0] : null;
116
+
117
+ if (leadRecord && leadRecord.lead_status != null) {
118
+ const leadStatusItem = await this.listMasterRepo.findOne({
119
+ where: {
120
+ id: leadRecord.lead_status,
121
+ organization_id: loggedInUser.organization_id,
122
+ },
123
+ select: ['name'],
124
+ });
125
+ if (leadStatusItem) {
126
+ leadStatus = leadStatusItem.name;
107
127
  }
108
128
  }
129
+
109
130
  // 4. Fetch stage groups & hierarchy
110
131
  const stageGroupAndStageHierarchy =
111
132
  (await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
112
- stage_group_data[0].workflow_id,
133
+ stageGroupData[0].workflow_id,
113
134
  loggedInUser,
114
135
  lead_id,
115
136
  )) as Array<{
@@ -63,6 +63,7 @@ import { ActivityLogController } from './controller/activity-log.controller';
63
63
  import { NotificationModule } from '../notification/notification.module';
64
64
  import { MapperModule } from '../mapper/mapper.module';
65
65
  import { WorkflowAutomationModule } from '../workflow-automation/workflow-automation.module';
66
+ import { ListMasterData } from '../listmaster/entity/list-master.entity';
66
67
 
67
68
  @Module({
68
69
  imports: [
@@ -83,9 +84,10 @@ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automa
83
84
  ActionDataEntity,
84
85
  ActionResourcesMapping,
85
86
  ActivityLog,
87
+ ListMasterData,
86
88
  ]),
87
- EntityModule,
88
89
  ListMasterModule,
90
+ EntityModule,
89
91
  NotificationModule,
90
92
  MapperModule,
91
93
  WorkflowAutomationModule,