making entries in host track
This commit is contained in:
@@ -19,6 +19,8 @@ import {
|
||||
STEPPER,
|
||||
} from '@/common/utils/constants/host.constant';
|
||||
import {
|
||||
ACTIVITY_TRACK_STATUS,
|
||||
ACTIVITY_TRACK_TYPE,
|
||||
MINGLAR_STATUS_DISPLAY,
|
||||
MINGLAR_STATUS_INTERNAL,
|
||||
} from '@/common/utils/constants/minglar.constant';
|
||||
@@ -1244,46 +1246,74 @@ export class HostService {
|
||||
});
|
||||
}
|
||||
|
||||
async submitpqqforreview(activity_xid: number) {
|
||||
const activity = await this.prisma.activities.findFirst({
|
||||
where: { id: activity_xid, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
activityTitle: true,
|
||||
activityRefNumber: true,
|
||||
activityDisplayStatus: true,
|
||||
activityInternalStatus: true,
|
||||
amInternalStatus: true,
|
||||
amDisplayStatus: true
|
||||
async submitpqqforreview(activity_xid: number, user_xid: number) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
const activity = await this.prisma.activities.findFirst({
|
||||
where: { id: activity_xid, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
activityTitle: true,
|
||||
activityRefNumber: true,
|
||||
activityDisplayStatus: true,
|
||||
activityInternalStatus: true,
|
||||
amInternalStatus: true,
|
||||
amDisplayStatus: true
|
||||
}
|
||||
})
|
||||
|
||||
if (!activity) {
|
||||
throw new ApiError(404, "Activity not found")
|
||||
}
|
||||
|
||||
if (activity.activityInternalStatus == ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.REVISED
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activity_xid,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.PQ_SUBMITTED,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.HOST,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.NEW
|
||||
}
|
||||
})
|
||||
|
||||
await tx.activityTrack.create({
|
||||
data: {
|
||||
activityXid: activity_xid,
|
||||
trackType: ACTIVITY_TRACK_TYPE.PQ,
|
||||
trackStatus: ACTIVITY_TRACK_STATUS.PQ_SUBMITTED,
|
||||
updatedByXid: user_xid,
|
||||
updatedByRole: ROLE_NAME.HOST,
|
||||
updatedOn: new Date()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
if (!activity) {
|
||||
throw new ApiError(404, "Activity not found")
|
||||
}
|
||||
|
||||
if (activity.activityInternalStatus == ACTIVITY_INTERNAL_STATUS.PQ_TO_UPDATE) {
|
||||
return await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.REVISED
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return await this.prisma.activities.update({
|
||||
where: { id: activity_xid },
|
||||
data: {
|
||||
activityInternalStatus: ACTIVITY_INTERNAL_STATUS.PQ_SUBMITTED,
|
||||
activityDisplayStatus: ACTIVITY_DISPLAY_STATUS.PQ_IN_REVIEW,
|
||||
amInternalStatus: ACTIVITY_AM_INTERNAL_STATUS.PQ_TO_REVIEW,
|
||||
amDisplayStatus: ACTIVITY_AM_DISPLAY_STATUS.NEW
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async updateSupportingFile(
|
||||
|
||||
Reference in New Issue
Block a user