mainLandingPage Api : suseendhiran
This commit is contained in:
parent
f470ebaba3
commit
0613dd7bba
@ -11,11 +11,11 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ResData = await ApiCallHelper.loanDetailsDataApiCall(req.query.losid);
|
Loan_Detail_Losid = await LoanDetail.findOne({ where : { losid : req.query.losid , is_active : 1}})
|
||||||
if (ResData.status != 'Not Found')
|
if (Loan_Detail_Losid == undefined)
|
||||||
{
|
{
|
||||||
Loan_Detail = await LoanDetail.findOne({ where : { losid : req.query.losid , is_active : 1}})
|
ResData = await ApiCallHelper.loanDetailsDataApiCall(req.query.losid);
|
||||||
if (ResData.lstLoanApplication.length != 0 && Loan_Detail == null )
|
if (ResData.status == "Successful" && ResData.lstLoanApplication.length != 0)
|
||||||
{
|
{
|
||||||
loanDetailData = ResData.lstLoanApplication[0];
|
loanDetailData = ResData.lstLoanApplication[0];
|
||||||
loanDetailObject =
|
loanDetailObject =
|
||||||
@ -30,21 +30,9 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
// Loan Detail Create
|
// Loan Detail Create
|
||||||
LoanDetail.create(loanDetailObject).then(LoanDetailData =>
|
LoanDetail.create(loanDetailObject).then(LoanDetailData =>
|
||||||
{
|
{
|
||||||
// Final Response
|
// Final Response
|
||||||
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data => { if(data.length > 0) { res.send({'status':200,'message':"success",'data':data}); } else { res.send({'status':404,'message':"failed",'data':"No data"}); } })
|
||||||
{
|
|
||||||
if(data.length > 0)
|
|
||||||
{
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res.send({'status':404,'message':"failed",'data':"No data"});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
res.send({'status':404,
|
|
||||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
|
||||||
});
|
|
||||||
// Entity detail promise
|
// Entity detail promise
|
||||||
var EntityKYCDetailDataInsert = new Promise(async(resolve, reject) =>
|
var EntityKYCDetailDataInsert = new Promise(async(resolve, reject) =>
|
||||||
{
|
{
|
||||||
@ -144,7 +132,7 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
logMsg.info("Applicants inserted");
|
logMsg.info("Applicants inserted");
|
||||||
ApplicantsDetailsData.forEach(async(ApplicantsDetailsDataElement , index ) =>
|
ApplicantsDetailsData.forEach(async(ApplicantsDetailsDataElement , index ) =>
|
||||||
{
|
{
|
||||||
await ApiCallHelper.ApplicantChildTable(ApplicantsDetailsDataElement.name , LoanDetailData.dataValues.id ,ApplicantsDetailsDataElement.id ,ApplicantsDetailsDataElement.losid ,lstApplicantKYCDetailDataArray[index].Applicant_entity_type , ResData , "Product" , lstApplicantKYCDetailDataArray[index].Applicant_id )
|
await ApiCallHelper.ApplicantChildTable(ApplicantsDetailsDataElement.name , LoanDetailData.dataValues.id ,ApplicantsDetailsDataElement.id ,ApplicantsDetailsDataElement.losid ,lstApplicantKYCDetailDataArray[index].Applicant_entity_type , ResData , "LFMP" , lstApplicantKYCDetailDataArray[index].Applicant_id )
|
||||||
});
|
});
|
||||||
}).catch(err=>{ logMsg.info("ApplicantsDetails Failed , Msg :" +err); }); // ApplicantsDetails Create catch block
|
}).catch(err=>{ logMsg.info("ApplicantsDetails Failed , Msg :" +err); }); // ApplicantsDetails Create catch block
|
||||||
});
|
});
|
||||||
@ -152,6 +140,7 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
} // end of if lstLoanApplication
|
} // end of if lstLoanApplication
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
logMsg.info("Los api call failed Failed " +req.query.losid);
|
||||||
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
||||||
{
|
{
|
||||||
if(data.length > 0)
|
if(data.length > 0)
|
||||||
@ -170,7 +159,7 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logMsg.info("Los api call failed Failed " +ResData.losid);
|
logMsg.info("Data already inserted " +req.query.losid);
|
||||||
// Final Response
|
// Final Response
|
||||||
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
||||||
{
|
{
|
||||||
@ -187,26 +176,6 @@ exports.mainLandingPage = async (req, res) =>
|
|||||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||||
});
|
});
|
||||||
} // Los api call failed
|
} // Los api call failed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // Final Response
|
|
||||||
// LoanDetail.findAll({raw: true , where : { is_active : 1}}).then(data =>
|
|
||||||
// {
|
|
||||||
// if(data.length > 0)
|
|
||||||
// {
|
|
||||||
// res.send({'status':200,'message':"success",'data':data});
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// res.send({'status':404,'message':"failed",'data':"No data"});
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// res.send({'status':404,
|
|
||||||
// message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
|
||||||
// });
|
|
||||||
|
|
||||||
} // end of try block
|
} // end of try block
|
||||||
catch(err)
|
catch(err)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -227,7 +227,7 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
|
|||||||
// ResidenceAddressDetails Table
|
// ResidenceAddressDetails Table
|
||||||
var ResidenceAddressDetailsPromise = new Promise(async(resolve, reject) =>
|
var ResidenceAddressDetailsPromise = new Promise(async(resolve, reject) =>
|
||||||
{
|
{
|
||||||
if(ApiArray.lstApplicantAddress.length != 0 )
|
if(ApiArray.lstApplicantAddress.length != 0 /* && EntityType == "Individual" */)
|
||||||
{
|
{
|
||||||
// ResidenceAddressDetails data
|
// ResidenceAddressDetails data
|
||||||
ApiArray.lstApplicantAddress.forEach(async(ApplicantAddress,index) =>
|
ApiArray.lstApplicantAddress.forEach(async(ApplicantAddress,index) =>
|
||||||
@ -261,7 +261,7 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
|
|||||||
// ResidenceAddressDetails Table
|
// ResidenceAddressDetails Table
|
||||||
var PropertyOwnershipIncomeConsideredPromise = new Promise(async(resolve, reject) =>
|
var PropertyOwnershipIncomeConsideredPromise = new Promise(async(resolve, reject) =>
|
||||||
{
|
{
|
||||||
// if (EntityType == "Individual")
|
// if (product == "LFMP")
|
||||||
// {
|
// {
|
||||||
PropertyOwnershipIncomeConsideredData = { }
|
PropertyOwnershipIncomeConsideredData = { }
|
||||||
Object.assign(PropertyOwnershipIncomeConsideredData, {name_of_the_loan_applicants : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid });
|
Object.assign(PropertyOwnershipIncomeConsideredData, {name_of_the_loan_applicants : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid });
|
||||||
@ -287,6 +287,9 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
loanDetailsDataApiCall : loanDetailsDataApiCall,
|
loanDetailsDataApiCall : loanDetailsDataApiCall,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user