rez_core 2.2.80 → 2.2.81
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/repository/activity-log.repository.js +2 -2
- package/dist/module/workflow/repository/activity-log.repository.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.js +4 -5
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/repository/activity-log.repository.ts +2 -2
- package/src/module/workflow/service/stage-group.service.ts +14 -10
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|
|
2
2
|
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
3
3
|
import { ActivityLog } from '../entity/activity-log.entity';
|
|
4
4
|
import { Repository } from 'typeorm';
|
|
5
|
-
import * as moment from 'moment';
|
|
5
|
+
import * as moment from 'moment-timezone';
|
|
6
6
|
|
|
7
7
|
export const ACTIVITY_CATEGORIES = {
|
|
8
8
|
ASSIGN: 'ASSIGN',
|
|
@@ -78,7 +78,7 @@ export class ActivityLogRepository {
|
|
|
78
78
|
user_name: rows.raw[i].user_name,
|
|
79
79
|
profile, // whole JSON from media service
|
|
80
80
|
created_date: entity.created_date
|
|
81
|
-
? moment(entity.created_date).format('DD-MMM, hh:mm A')
|
|
81
|
+
? moment(entity.created_date).local().format('DD-MMM, hh:mm A')
|
|
82
82
|
: null,
|
|
83
83
|
};
|
|
84
84
|
}),
|
|
@@ -8,7 +8,7 @@ import { DataSource, Repository } from 'typeorm';
|
|
|
8
8
|
import { WorkflowLevelMappingEntity } from '../entity/workflow-level-mapping.entity';
|
|
9
9
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
10
10
|
import { StageMovementData } from '../entity/stage-movement-data.entity';
|
|
11
|
-
import * as moment from 'moment';
|
|
11
|
+
import * as moment from 'moment-timezone';
|
|
12
12
|
|
|
13
13
|
@Injectable()
|
|
14
14
|
export class StageGroupService extends EntityServiceImpl {
|
|
@@ -55,6 +55,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
55
55
|
|
|
56
56
|
if (!workflowLevelMapping) return null;
|
|
57
57
|
|
|
58
|
+
// 3. Get lead status
|
|
58
59
|
let leadStatus: string | null = null;
|
|
59
60
|
const leadData = await this.dataSource.query(
|
|
60
61
|
`SELECT lead_status FROM crm_lead WHERE id = ${lead_id}`,
|
|
@@ -70,7 +71,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
//
|
|
74
|
+
// 4. Fetch stage groups & hierarchy
|
|
74
75
|
const stageGroupAndStageHierarchy =
|
|
75
76
|
(await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
|
|
76
77
|
workflowLevelMapping.workflow_id,
|
|
@@ -79,13 +80,13 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
79
80
|
lead_id,
|
|
80
81
|
)) as Array<{
|
|
81
82
|
stages: any[];
|
|
82
|
-
stage_group_status?: string;
|
|
83
|
-
[key: string]: any;
|
|
83
|
+
stage_group_status?: string;
|
|
84
|
+
[key: string]: any;
|
|
84
85
|
}>;
|
|
85
86
|
|
|
86
87
|
if (stageGroupAndStageHierarchy.length === 0) return [];
|
|
87
88
|
|
|
88
|
-
//
|
|
89
|
+
// 5. Get stage movement data
|
|
89
90
|
const stageMovementData = await this.stageMovementRepo.find({
|
|
90
91
|
where: {
|
|
91
92
|
mapped_entity_type: 'LEAD',
|
|
@@ -95,12 +96,11 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
95
96
|
|
|
96
97
|
if (stageMovementData.length === 0) {
|
|
97
98
|
throw new BadGatewayException(
|
|
98
|
-
`No lead found with id ${lead_id} or no stage movements recorded for this lead
|
|
99
|
-
`,
|
|
99
|
+
`No lead found with id ${lead_id} or no stage movements recorded for this lead`,
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
//
|
|
103
|
+
// 6. Map stage_id => movement data
|
|
104
104
|
const stageMovementMap = new Map<number, any>();
|
|
105
105
|
for (const movement of stageMovementData) {
|
|
106
106
|
stageMovementMap.set(movement.stage_id, movement);
|
|
@@ -108,6 +108,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
108
108
|
|
|
109
109
|
let foundInProgressGroup = false;
|
|
110
110
|
|
|
111
|
+
// 7. Loop & apply IST conversions
|
|
111
112
|
for (const group of stageGroupAndStageHierarchy) {
|
|
112
113
|
for (const stage of group.stages || []) {
|
|
113
114
|
const movement = stageMovementMap.get(Number(stage.id));
|
|
@@ -115,12 +116,15 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
115
116
|
if (movement) {
|
|
116
117
|
stage.is_current = movement.is_current === 'Y';
|
|
117
118
|
stage.is_done = movement.is_current === 'N';
|
|
119
|
+
|
|
118
120
|
stage.start_time = movement.start_date
|
|
119
|
-
? moment(movement.start_date).format('DD-MMM, hh:mm A')
|
|
121
|
+
? moment.utc(movement.start_date).local().format('DD-MMM, hh:mm A')
|
|
120
122
|
: null;
|
|
123
|
+
|
|
121
124
|
stage.end_time = movement.end_date
|
|
122
|
-
? moment(movement.end_date).format('DD-MMM, hh:mm A')
|
|
125
|
+
? moment.utc(movement.end_date).local().format('DD-MMM, hh:mm A')
|
|
123
126
|
: null;
|
|
127
|
+
|
|
124
128
|
stage.time_spent = await this.calculateTimeSpent(
|
|
125
129
|
movement.start_date,
|
|
126
130
|
movement.end_date ?? new Date(),
|