This commit is contained in:
suseendhiran17 2023-08-07 18:27:02 +05:30
parent 9bf2d8db78
commit 31722ce944
4 changed files with 25 additions and 13 deletions

View File

@ -1286,12 +1286,6 @@ exports.test = async (req, res) =>
// exports.queryConstruct = async (req, res) => {
// try
// {

View File

@ -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)
{

View File

@ -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
}

View File

@ -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 },