sending the connection interest count and generating the activity ref number

This commit is contained in:
2026-02-27 17:24:39 +05:30
parent 85437ebc2e
commit b98b8cf864
2 changed files with 446 additions and 13 deletions

View File

@@ -61,7 +61,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({
@@ -131,7 +132,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")}`;
@@ -2763,6 +2764,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 },
});
@@ -2770,6 +2783,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');
@@ -2780,7 +2797,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: {