From 31722ce944886bd2beb3e196fe8329d5dec472fd Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:27:02 +0530 Subject: [PATCH] susee --- .../entity.applicant.controller.js | 6 ------ app/controllers/loan.details.controller.js | 20 +++++++++++++++---- app/models/LoanDetail.js | 10 ++++++++-- app/models/PropertyAndLtv.js | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app/controllers/entity.applicant.controller.js b/app/controllers/entity.applicant.controller.js index af82ef0..bb62bc5 100644 --- a/app/controllers/entity.applicant.controller.js +++ b/app/controllers/entity.applicant.controller.js @@ -1286,12 +1286,6 @@ exports.test = async (req, res) => - - - - - - // exports.queryConstruct = async (req, res) => { // try // { diff --git a/app/controllers/loan.details.controller.js b/app/controllers/loan.details.controller.js index 31b704e..ecfa392 100644 --- a/app/controllers/loan.details.controller.js +++ b/app/controllers/loan.details.controller.js @@ -15,7 +15,11 @@ 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}}).then(data => + 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) { @@ -44,7 +48,7 @@ exports.mainLandingPage = async (req, res) => applicationNo : loanDetailData.applicationNo, losid : loanDetailData.loginNo , date_of_login : moment(new Date(loanDetailData.loginDate)).format("YYYY-MM-DD"), - sourcing_channel_name : loanDetailData.source, + sourcing_channel_type : loanDetailData.source, additional_loan_amnt_applied_for : Number(loanDetailData.loanAmount), product : loanDetailData.loanProductName, pd_id : loanDetailData.pD_ID @@ -169,7 +173,11 @@ exports.mainLandingPage = async (req, res) => else { logMsg.info("Los api call Failed " +req.query.losid); - LoanDetail.findAll({raw: true , where : {losid :req.query.losid , is_active : 1}}).then(data => + 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 }] }).then(data => { if(data.length > 0) { @@ -189,7 +197,11 @@ 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}}).then(data => + 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 }]}).then(data => { if(data.length > 0) { diff --git a/app/models/LoanDetail.js b/app/models/LoanDetail.js index 171be56..033723f 100644 --- a/app/models/LoanDetail.js +++ b/app/models/LoanDetail.js @@ -10,8 +10,8 @@ module.exports = (sequelize, DataTypes) => { // applicationNo: { type: DataTypes.INTEGER }, product : { type: DataTypes.STRING }, date_of_login: { type: DataTypes.INTEGER }, - sourcing_channel_type: { type: DataTypes.INTEGER }, - sourcing_channel_name: { type: DataTypes.INTEGER }, + sourcing_channel_type: { type: DataTypes.STRING }, + sourcing_channel_name: { type: DataTypes.STRING }, proposal: { type: DataTypes.INTEGER }, sanction_date_of_earlier_exposure: { type: DataTypes.STRING }, sanction_amount_of_earlier_exposure: { type: DataTypes.INTEGER }, @@ -38,5 +38,11 @@ module.exports = (sequelize, DataTypes) => { modelName: 'LoanDetail', } ) + LoanDetail.associate = models => { + LoanDetail.hasMany(models.ApplicantsDetails, { + foreignKey: 'loan_no_id', + sourceKey : 'id' + }); + } return LoanDetail } \ No newline at end of file diff --git a/app/models/PropertyAndLtv.js b/app/models/PropertyAndLtv.js index b9e1ab5..7a8fbf1 100644 --- a/app/models/PropertyAndLtv.js +++ b/app/models/PropertyAndLtv.js @@ -16,7 +16,7 @@ module.exports = (sequelize, DataTypes) => { } PropertyAndLtv.init( { - losid: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, product : { type: DataTypes.STRING }, address_of_prop_to_be_mortgaged : { type: DataTypes.STRING }, property_type : { type: DataTypes.STRING },