From 68a06b6451108d8c75665ff9815e2e62f8dbf140 Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:50:00 +0530 Subject: [PATCH] susee --- app/controllers/loan.details.controller.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/loan.details.controller.js b/app/controllers/loan.details.controller.js index 03b9bd7..4ccbb90 100644 --- a/app/controllers/loan.details.controller.js +++ b/app/controllers/loan.details.controller.js @@ -16,10 +16,10 @@ exports.mainLandingPage = async (req, res) => if(req.query.is_loan_api_call == 0) { LoanDetail.findAll({raw: true ,where:{ losid:req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: ApplicantsDetails , // Set the alias for the relationship attributes: [ [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column - ] , limit: 1 , order: [['createdAt', 'DESC']] }] }).then(data => + ] , where: { 'applicant_type' : 'Main Applicant'} }] }).then(data => { if(data.length > 0) { @@ -60,10 +60,10 @@ exports.mainLandingPage = async (req, res) => ModuleWiseStatusHelper.moduleCompletionStatusDataCreationHelper(loanDetailData.loginNo); // Final Response LoanDetail.findAll({raw: true , where : {losid :req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship - attributes: [ - [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column - ] , limit: 1 , order: [['createdAt', 'DESC']] }] }).then(data => { if(data.length > 0) { res.send({'status':200,'message':"success",'data':data}); } else { res.send({'status':404,'message':"failed",'data':"No data"}); } }) + include: [{ model: ApplicantsDetails , // Set the alias for the relationship + attributes: [ + [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column + ] , where: { 'applicant_type' : 'Main Applicant'} }] }).then(data => { if(data.length > 0) { res.send({'status':200,'message':"success",'data':data}); } else { res.send({'status':404,'message':"failed",'data':"No data"}); } }) // Entity detail promise var EntityKYCDetailDataInsert = new Promise(async(resolve, reject) => @@ -150,6 +150,7 @@ exports.mainLandingPage = async (req, res) => name : [value.firstName, value.middleName, value.lastName ].filter(Boolean).join(" "), // concat and ignore null pan_no : value.panNo, entity_type : value.kycType.trim(), + applicant_type : 'Main Applicant' } lstApplicantKYCDetailDataArray.push(lstApplicantKYCDetailObj); } @@ -178,10 +179,10 @@ exports.mainLandingPage = async (req, res) => { logMsg.info("Los api call Failed " +req.query.losid); LoanDetail.findAll({raw: true , where : {losid :req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: ApplicantsDetails , // Set the alias for the relationship attributes: [ [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column - ] , limit: 1 }] }).then(data => + ] , where: { 'applicant_type' : 'Main Applicant'} }] }).then(data => { if(data.length > 0) { @@ -202,10 +203,10 @@ exports.mainLandingPage = async (req, res) => logMsg.info("Data already inserted " +req.query.losid); // Final Response LoanDetail.findAll({raw: true , where : {losid :req.query.losid , is_active : 1}, - include: [{ model: ApplicantsDetails , // Set the alias for the relationship + include: [{ model: ApplicantsDetails , // Set the alias for the relationship attributes: [ [sequelize.col('name'), 'loan_applicant_name'] // Alias for the 'name' column - ] , limit: 1 }]}).then(data => + ] , where: { 'applicant_type' : 'Main Applicant'} }] }).then(data => { if(data.length > 0) {