Merge branch 'mayankSprint2' of http://git.wdipl.com/Mayank.Mishra/MinglarBackendNestJS into paritosh-main1
This commit is contained in:
@@ -59,7 +59,8 @@ interface HostDocumentInput {
|
||||
export async function generateActivityRefNumber(
|
||||
tx: any,
|
||||
hostXid: number,
|
||||
activityTypeXid: number
|
||||
activityTypeXid: number,
|
||||
hostRefNumber: string
|
||||
) {
|
||||
// 1️⃣ Get ActivityType with Interest
|
||||
const activityType = await tx.activityTypes.findUnique({
|
||||
@@ -129,7 +130,7 @@ export async function generateActivityRefNumber(
|
||||
|
||||
const nextActivityTypeSequence = activityTypeCount + 1;
|
||||
|
||||
return `E-${interestCode}${String(interestSequence).padStart(
|
||||
return `${hostRefNumber}-E-${interestCode}${String(interestSequence).padStart(
|
||||
3,
|
||||
"0"
|
||||
)}-${String(nextActivityTypeSequence).padStart(2, "0")}`;
|
||||
@@ -2614,6 +2615,18 @@ export class HostService {
|
||||
frequenciesXid: number,
|
||||
) {
|
||||
return await this.prisma.$transaction(async (tx) => {
|
||||
|
||||
const hostUserDetail = await tx.user.findFirst({
|
||||
where: { id: userId, isActive: true},
|
||||
select: {
|
||||
id: true,
|
||||
userRefNumber: true,
|
||||
}
|
||||
})
|
||||
|
||||
if(!hostUserDetail) {
|
||||
throw new ApiError(404, 'User not found');
|
||||
}
|
||||
const host = await tx.hostHeader.findFirst({
|
||||
where: { userXid: userId, isActive: true },
|
||||
});
|
||||
@@ -2621,6 +2634,10 @@ export class HostService {
|
||||
|
||||
const activityType = await tx.activityTypes.findUnique({
|
||||
where: { id: activityTypeXid },
|
||||
include: {
|
||||
interests: true, // ✅ correct
|
||||
energyLevel: true, // ✅ this is correct already
|
||||
},
|
||||
});
|
||||
if (!activityType) throw new ApiError(404, 'Activity type not found');
|
||||
|
||||
@@ -2631,7 +2648,7 @@ export class HostService {
|
||||
if (!freq) throw new ApiError(404, 'Frequency not found');
|
||||
}
|
||||
|
||||
const referenceNumber = await generateActivityRefNumber(tx, host.id, activityTypeXid);
|
||||
const referenceNumber = await generateActivityRefNumber(tx, host.id, activityTypeXid, hostUserDetail.userRefNumber);
|
||||
|
||||
const created = await tx.activities.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user