add payment details modified and making seeder of pqq

This commit is contained in:
2025-11-18 17:44:51 +05:30
parent 05f97d33e7
commit ee38391d1e
7 changed files with 590 additions and 63 deletions

View File

@@ -30,11 +30,11 @@ model User {
updatedAt DateTime? @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
UserOtp UserOtp[]
Connections Connections? @relation(fields: [connectionsId], references: [id])
connectionsId Int?
EnergyLevels EnergyLevels? @relation(fields: [energyLevelsId], references: [id])
Connections Connections? @relation(fields: [connectionsXid], references: [id])
connectionsXid Int? @map("connections_xid")
EnergyLevels EnergyLevels? @relation(fields: [energyLevelsXid], references: [id])
isBiometric Boolean? @default(false) @map("is_biometric")
energyLevelsId Int?
energyLevelsXid Int? @map("energy_levels_xid")
hostHeaders HostHeader[] @relation("HostUser")
managedHostHeaders HostHeader[] @relation("AccountManager")
Token Token[]
@@ -226,17 +226,18 @@ model Countries {
}
model Currencies {
id Int @id @default(autoincrement())
countryXid Int @map("country_xid")
country Countries @relation(fields: [countryXid], references: [id], onDelete: Restrict)
currencyName String @unique @map("currency_name")
currencySymbol String @unique @map("currency_symbol")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
HostHeader HostHeader[]
Activities Activities[]
id Int @id @default(autoincrement())
countryXid Int @map("country_xid")
country Countries @relation(fields: [countryXid], references: [id], onDelete: Restrict)
currencyName String @unique @map("currency_name")
currencySymbol String @unique @map("currency_symbol")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
HostHeader HostHeader[]
Activities Activities[]
hostBankDetails HostBankDetails[]
@@map("currencies")
@@schema("mst")
@@ -371,6 +372,7 @@ model DocumentType {
id Int @id @default(autoincrement())
documentTypeName String @unique @map("document_type_name")
isVisible Boolean @default(true) @map("is_visible")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@ -474,33 +476,49 @@ model TransportModes {
}
model PQQCategories {
id Int @id @default(autoincrement())
categoryName String @unique @map("category_name")
subCategoryName String @map("sub_category_name")
categoryTitle String @map("category_title")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
PQQQuestions PQQQuestions[]
id Int @id @default(autoincrement())
categoryName String @unique @map("category_name")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
pqqsubCategories PQQSubCategories[]
@@map("pqq_categories")
@@schema("mst")
}
model PQQSubCategories {
id Int @id @default(autoincrement())
categoryXid Int @map("category_xid")
category PQQCategories @relation(fields: [categoryXid], references: [id], onDelete: Cascade)
subCategoryName String @map("sub_category_name")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
questions PQQQuestions[]
@@map("pqq_sub_categories")
@@schema("mst")
}
model PQQQuestions {
id Int @id @default(autoincrement())
pqqCategoryXid Int @map("pqq_category_xid")
pqqCategories PQQCategories @relation(fields: [pqqCategoryXid], references: [id], onDelete: Cascade)
questionName String @unique @map("question_name")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
PQQAnswers PQQAnswers[]
ActivityPQQheader ActivityPQQheader[]
id Int @id @default(autoincrement())
pqqSubCategoryXid Int @map("pqq_sub_category_xid")
pqqSubCategories PQQSubCategories @relation(fields: [pqqSubCategoryXid], references: [id], onDelete: Cascade)
questionName String @unique @map("question_name")
maxPoints Int @map("max_points")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
PQQAnswers PQQAnswers[]
ActivityPQQheader ActivityPQQheader[]
@@map("pqq_questions")
@@schema("mst")
@@ -511,7 +529,7 @@ model PQQAnswers {
pqqQuestionXid Int @map("pqq_question_xid")
pqqQuestions PQQQuestions @relation(fields: [pqqQuestionXid], references: [id], onDelete: Cascade)
answerName String @map("answer_name")
answerScore String @map("answer_score")
answerPoints Int @map("answer_points")
displayOrder Int @map("display_order")
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
@@ -689,6 +707,8 @@ model HostBankDetails {
accountHolderName String @map("account_holder_name")
accountNumber String @unique @map("account_number")
ifscCode String @map("ifsc_code")
currencyXid Int @map("currency_xid")
currencies Currencies @relation(fields: [currencyXid], references: [id], onDelete: Restrict)
isActive Boolean @default(true) @map("is_active")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

View File

@@ -241,42 +241,457 @@ async function main() {
});
// ✅ PQQ Categories + Questions + Answers
const category = await prisma.pQQCategories.upsert({
where: { categoryName: 'General' },
update: {},
create: {
categoryName: 'General',
subCategoryName: 'Basic',
categoryTitle: 'General Information',
// const PQQCategories = await prisma.pQQCategories.upsert({
// where: { categoryName: "Sustainability" },
// update: {},
// create: {
// categoryName: "Sustainability",
// displayOrder: 1,
// isActive: true,
// pqqsubCategories: {
// create: [
// // -----------------------------------------------------
// // SUBCATEGORY 1: Environmental Practices
// // -----------------------------------------------------
// {
// subCategoryName: "Environmental Practices",
// displayOrder: 1,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName: 'What waste management practices do you have in place to minimize environmental impact? Examples: Recycling bins, composting organic waste, reducing single-use plastics.',
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: 'We do not have specific waste management practices.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We separate waste and recycle basic items like paper and plastic.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have a comprehensive recycling program including composting organic waste.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We actively reduce waste at the source and partner with local recycling organizations.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// // QUESTION 2
// {
// questionName: 'Can you provide examples of energy-efficient appliances or renewable energy sources you use? Examples: Solar panels, energy-efficient lighting, renewable energy certificates.',
// maxPoints: 10,
// displayOrder: 2,
// PQQAnswers: {
// create: [
// { answerName: 'We do not use energy-efficient appliances or renewable energy sources.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We use energy-efficient light bulbs and appliances.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have solar panels and energy-efficient heating/cooling systems.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We utilize a combination of renewable energy sources and advanced energy-saving technologies.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'What measures do you take to conserve water? Examples: Low-flow fixtures, rainwater harvesting, greywater recycling.',
// maxPoints: 10,
// displayOrder: 3,
// PQQAnswers: {
// create: [
// { answerName: 'We do not have specific water conservation measures.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We encourage guests to limit water use.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have low-flow fixtures and water-saving appliances installed.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We implement rainwater harvesting and greywater recycling systems.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'How do you monitor and reduce your carbon footprint? Examples: Carbon audits, offsetting emissions, energy-saving initiatives.',
// maxPoints: 10,
// displayOrder: 4,
// PQQAnswers: {
// create: [
// { answerName: 'We do not monitor or take steps to reduce our carbon footprint.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We track our energy usage and try to minimize it.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We have set carbon reduction targets and regularly monitor our progress.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We offset our carbon emissions through verified programs and continually improve our sustainability practices.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// {
// questionName: 'Do you source products and materials sustainably? Can you provide examples? Examples: Local, organic, fair-trade products.',
// maxPoints: 10,
// displayOrder: 5,
// PQQAnswers: {
// create: [
// { answerName: 'We do not prioritize sustainable sourcing.', answerPoints: 0, displayOrder: 1 },
// { answerName: 'We source some products locally and sustainably.', answerPoints: 5, displayOrder: 2 },
// { answerName: 'We prioritize local, organic, and fair-trade products.', answerPoints: 8, displayOrder: 3 },
// { answerName: 'We have strict sourcing policies that ensure all products are sustainable and ethically produced.', answerPoints: 10, displayOrder: 4 },
// ],
// },
// },
// ]
// }
// },
// // -----------------------------------------------------
// // SUBCATEGORY 2: Community Impact
// // -----------------------------------------------------
// {
// subCategoryName: "Community Impact",
// displayOrder: 2,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName:
// "How do you support local employment and engage with the community? Examples: Hiring local staff, partnering with community organizations, participating in local events.",
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: "We do not have specific practices to support local employment or community engagement.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We hire local staff but do not have formal community engagement programs.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We actively employ local residents and participate in community events.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We have partnerships with local organizations and invest in community development projects.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// // QUESTION 2
// {
// questionName:
// "Are you involved in any community projects or cultural preservation activities? Examples: Supporting local artisans, sponsoring cultural festivals, contributing to community development.",
// maxPoints: 10,
// displayOrder: 2,
// PQQAnswers: {
// create: [
// { answerName: "We are not involved in any community or cultural preservation projects.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We support community projects through donations.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We participate in and organize community events and cultural preservation activities.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We lead major community development initiatives and cultural preservation projects.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// // QUESTION 3
// {
// questionName:
// "Can you provide examples of how your business benefits the local community? Examples: Providing jobs, sourcing local products, investing in local infrastructure.",
// maxPoints: 10,
// displayOrder: 3,
// PQQAnswers: {
// create: [
// { answerName: "We do not have specific examples.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We provide employment opportunities for local residents.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We support local businesses by sourcing products and services locally.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We invest in local infrastructure and educational programs.", answerPoints: 10, displayOrder: 4 }
// ]
// }
// },
// ]
// }
// },
// // -----------------------------------------------------
// //SUBCATEGORY 3 : Sustainable Tourism Certification
// // -----------------------------------------------------
// {
// subCategoryName: "Sustainable Tourism Certification",
// displayOrder: 2,
// isActive: true,
// questions: {
// create: [
// // QUESTION 1
// {
// questionName:
// "Do you have any recognized sustainable tourism certifications (e.g., Green Globe, EarthCheck, Travelife)? Please provide details. Examples: Certification names and details, certificates.",
// maxPoints: 10,
// displayOrder: 1,
// PQQAnswers: {
// create: [
// { answerName: "We do not have any sustainable tourism certifications.", answerPoints: 0, displayOrder: 1 },
// { answerName: "We are in the process of obtaining a certification.", answerPoints: 5, displayOrder: 2 },
// { answerName: "We have one recognized sustainable tourism certification.", answerPoints: 8, displayOrder: 3 },
// { answerName: "We hold multiple recognized sustainable tourism certifications and regularly audit our practices.", answerPoints: 10, displayOrder: 4 }
// { answerName: "Not applicable", answerPoints: 0, displayOrder: 5 }
// ]
// }
// }
// ]
// }
// },
// ]
// }
// },
// include: {
// pqqsubCategories: {
// include: {
// questions: {
// include: {
// PQQAnswers: true
// }
// }
// }
// }
// }
// });
const categoriesData = [
{
categoryName: "Sustainability",
displayOrder: 1,
isActive: true,
PQQQuestions: {
pqqsubCategories: {
create: [
// -----------------------------------------------------
// SUBCATEGORY 1: Environmental Practices
// -----------------------------------------------------
{
questionName: 'Do you have insurance?',
subCategoryName: "Environmental Practices",
displayOrder: 1,
PQQAnswers: {
isActive: true,
questions: {
create: [
{ answerName: 'Yes', answerScore: '10', displayOrder: 1 },
{ answerName: 'No', answerScore: '0', displayOrder: 2 },
],
},
// QUESTION 1
{
questionName: 'What waste management practices do you have in place to minimize environmental impact? Examples: Recycling bins, composting organic waste, reducing single-use plastics.',
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: 'We do not have specific waste management practices.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We separate waste and recycle basic items like paper and plastic.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have a comprehensive recycling program including composting organic waste.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We actively reduce waste at the source and partner with local recycling organizations.', answerPoints: 10, displayOrder: 4 },
],
},
},
// QUESTION 2
{
questionName: 'Can you provide examples of energy-efficient appliances or renewable energy sources you use? Examples: Solar panels, energy-efficient lighting, renewable energy certificates.',
maxPoints: 10,
displayOrder: 2,
PQQAnswers: {
create: [
{ answerName: 'We do not use energy-efficient appliances or renewable energy sources.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We use energy-efficient light bulbs and appliances.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have solar panels and energy-efficient heating/cooling systems.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We utilize a combination of renewable energy sources and advanced energy-saving technologies.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'What measures do you take to conserve water? Examples: Low-flow fixtures, rainwater harvesting, greywater recycling.',
maxPoints: 10,
displayOrder: 3,
PQQAnswers: {
create: [
{ answerName: 'We do not have specific water conservation measures.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We encourage guests to limit water use.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have low-flow fixtures and water-saving appliances installed.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We implement rainwater harvesting and greywater recycling systems.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'How do you monitor and reduce your carbon footprint? Examples: Carbon audits, offsetting emissions, energy-saving initiatives.',
maxPoints: 10,
displayOrder: 4,
PQQAnswers: {
create: [
{ answerName: 'We do not monitor or take steps to reduce our carbon footprint.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We track our energy usage and try to minimize it.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We have set carbon reduction targets and regularly monitor our progress.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We offset our carbon emissions through verified programs and continually improve our sustainability practices.', answerPoints: 10, displayOrder: 4 },
],
},
},
{
questionName: 'Do you source products and materials sustainably? Can you provide examples? Examples: Local, organic, fair-trade products.',
maxPoints: 10,
displayOrder: 5,
PQQAnswers: {
create: [
{ answerName: 'We do not prioritize sustainable sourcing.', answerPoints: 0, displayOrder: 1 },
{ answerName: 'We source some products locally and sustainably.', answerPoints: 5, displayOrder: 2 },
{ answerName: 'We prioritize local, organic, and fair-trade products.', answerPoints: 8, displayOrder: 3 },
{ answerName: 'We have strict sourcing policies that ensure all products are sustainable and ethically produced.', answerPoints: 10, displayOrder: 4 },
],
},
},
]
}
},
// -----------------------------------------------------
// SUBCATEGORY 2: Community Impact
// -----------------------------------------------------
{
questionName: 'Do you have ISO certification?',
subCategoryName: "Community Impact",
displayOrder: 2,
PQQAnswers: {
isActive: true,
questions: {
create: [
{ answerName: 'Yes', answerScore: '20', displayOrder: 1 },
{ answerName: 'No', answerScore: '0', displayOrder: 2 },
],
},
// QUESTION 1
{
questionName:
"How do you support local employment and engage with the community? Examples: Hiring local staff, partnering with community organizations, participating in local events.",
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: "We do not have specific practices to support local employment or community engagement.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We hire local staff but do not have formal community engagement programs.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We actively employ local residents and participate in community events.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We have partnerships with local organizations and invest in community development projects.", answerPoints: 10, displayOrder: 4 }
]
}
},
// QUESTION 2
{
questionName:
"Are you involved in any community projects or cultural preservation activities? Examples: Supporting local artisans, sponsoring cultural festivals, contributing to community development.",
maxPoints: 10,
displayOrder: 2,
PQQAnswers: {
create: [
{ answerName: "We are not involved in any community or cultural preservation projects.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We support community projects through donations.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We participate in and organize community events and cultural preservation activities.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We lead major community development initiatives and cultural preservation projects.", answerPoints: 10, displayOrder: 4 }
]
}
},
// QUESTION 3
{
questionName:
"Can you provide examples of how your business benefits the local community? Examples: Providing jobs, sourcing local products, investing in local infrastructure.",
maxPoints: 10,
displayOrder: 3,
PQQAnswers: {
create: [
{ answerName: "We do not have specific examples.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We provide employment opportunities for local residents.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We support local businesses by sourcing products and services locally.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We invest in local infrastructure and educational programs.", answerPoints: 10, displayOrder: 4 }
]
}
},
]
}
},
],
},
// -----------------------------------------------------
//SUBCATEGORY 3 : Sustainable Tourism Certification
// -----------------------------------------------------
{
subCategoryName: "Sustainable Tourism Certification",
displayOrder: 2,
isActive: true,
questions: {
create: [
// QUESTION 1
{
questionName:
"Do you have any recognized sustainable tourism certifications (e.g., Green Globe, EarthCheck, Travelife)? Please provide details. Examples: Certification names and details, certificates.",
maxPoints: 10,
displayOrder: 1,
PQQAnswers: {
create: [
{ answerName: "We do not have any sustainable tourism certifications.", answerPoints: 0, displayOrder: 1 },
{ answerName: "We are in the process of obtaining a certification.", answerPoints: 5, displayOrder: 2 },
{ answerName: "We have one recognized sustainable tourism certification.", answerPoints: 8, displayOrder: 3 },
{ answerName: "We hold multiple recognized sustainable tourism certifications and regularly audit our practices.", answerPoints: 10, displayOrder: 4 },
{ answerName: "Not applicable", answerPoints: 0, displayOrder: 5 }
]
}
}
]
}
},
]
}
},
include: { PQQQuestions: true },
});
// ----------------------------------------
// ADD MORE CATEGORIES HERE
// Example:
// ----------------------------------------
{
categoryName: "Safety",
displayOrder: 2,
subCategories: [
{
subCategoryName: "General Safety Protocols",
displayOrder: 1,
questions: [
{
questionName: "What safety measures do you have in place for your activities? Examples: Safety briefings, emergency exits, safety equipment.",
maxPoints: 10,
displayOrder: 1,
answers: [
{ name: "We do not have specific safety measures.", points: 0 },
{ name: "Basic fire extinguishers installed.", points: 5 },
{ name: "Full fire safety system installed.", points: 10 }
]
}
]
}
]
}
];
for (const category of categoriesData) {
await prisma.pQQCategories.upsert({
where: { categoryName: category.categoryName },
update: {},
create: {
categoryName: category.categoryName,
displayOrder: category.displayOrder,
isActive: true,
pqqsubCategories: {
create: category.subCategories.map((sub) => ({
subCategoryName: sub.subCategoryName,
displayOrder: sub.displayOrder,
isActive: true,
questions: {
create: sub.questions.map((q) => ({
questionName: q.questionName,
maxPoints: q.maxPoints,
displayOrder: q.displayOrder,
PQQAnswers: {
create: q.answers.map((ans, i) => ({
answerName: ans.name,
answerPoints: ans.points,
displayOrder: i + 1
}))
}
}))
}
}))
}
}
});
}
console.log('✅ Seed data inserted successfully!');
}