Swagger array of object update : suseendhiran
This commit is contained in:
parent
604a9122d0
commit
cc933c4d05
@ -423,7 +423,6 @@ exports.updateDueDiligenceCheck = async (req, res) =>
|
|||||||
{
|
{
|
||||||
id = element.id;
|
id = element.id;
|
||||||
delete element.id;
|
delete element.id;
|
||||||
console.log(element);
|
|
||||||
// update value
|
// update value
|
||||||
DueDiligenceCheck.update(element,{ where: { id: id }}).then(data =>
|
DueDiligenceCheck.update(element,{ where: { id: id }}).then(data =>
|
||||||
{
|
{
|
||||||
@ -965,7 +964,6 @@ exports.updateLoanDetail = async (req, res) =>
|
|||||||
updatedby = req.body.updatedby;
|
updatedby = req.body.updatedby;
|
||||||
delete req.body.id;
|
delete req.body.id;
|
||||||
delete req.body.updatedby;
|
delete req.body.updatedby;
|
||||||
// update old value is_active = 0 where requested id
|
|
||||||
await LoanDetail.update(req.body,{ where: { id: id }}).then(data=>{
|
await LoanDetail.update(req.body,{ where: { id: id }}).then(data=>{
|
||||||
res.send({'status':200,'message':"success",'data':data})
|
res.send({'status':200,'message':"success",'data':data})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -12,71 +12,165 @@ exports.LoanDeatilListTEST = async (req, res) =>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
data = await ApiCallHelper.loanDetailsDataApiCall('MW00004618','AXZPP6264B');
|
data = await ApiCallHelper.loanDetailsDataApiCall('MW00004618','AXZPP6264B');
|
||||||
|
Applicant_id = { };
|
||||||
|
if (data.lstLoanApplication.length != 0)
|
||||||
|
{
|
||||||
|
loanDetailData = data.lstLoanApplication[0];
|
||||||
|
loanDetailObject =
|
||||||
|
{
|
||||||
|
applicationNo : loanDetailData.applicationNo,
|
||||||
|
losid : loanDetailData.loginNo ,
|
||||||
|
date_of_login : moment(new Date(loanDetailData.loginDate)).format("YYYY-MM-DD"),
|
||||||
|
sourcing_channel_name : loanDetailData.source,
|
||||||
|
emi_of_loan_applied_for : Number(loanDetailData.loanAmount),
|
||||||
|
product : loanDetailData.loanProductName
|
||||||
|
}
|
||||||
|
LoanDetail.create(loanDetailObject).then(LoanDetailData =>
|
||||||
|
{
|
||||||
|
// entity detail promise
|
||||||
|
var EntityKYCDetailDataInsert = new Promise(async(resolve, reject) =>
|
||||||
|
{
|
||||||
|
lstEntityKYCDetailDataArray = [];
|
||||||
|
data.lstApplicantKYCDetail.forEach(async(value,index,array) => {
|
||||||
|
if (value.kycType == "Non-Individual ")
|
||||||
|
{
|
||||||
|
lstEntityKYCDetailObj =
|
||||||
|
{
|
||||||
|
losid : LoanDetailData.dataValues.losid ,
|
||||||
|
loan_no_id : LoanDetailData.dataValues.id ,
|
||||||
|
entity_name : [value.firstName, value.middleName, value.lastName ].filter(Boolean).join(" "),
|
||||||
|
entity_formation_date : moment(new Date(value.doi)).format("YYYY-MM-DD"),
|
||||||
|
// entity_type : value.kycType
|
||||||
|
}
|
||||||
|
data.lstApplicantAddress.forEach(async(address_value,index) =>
|
||||||
|
{
|
||||||
|
if (value.iD_ApplicantKYCDetail == address_value.iD_ApplicantKYCDetail && address_value.iD_OwnershipTypes == "Permanent" )
|
||||||
|
{
|
||||||
|
lstEntityAddressDetailObj =
|
||||||
|
{
|
||||||
|
registered_address_of_business: [address_value.address1, address_value.address2, address_value.address3 ].filter(Boolean).join(" "),
|
||||||
|
registered_address_state: address_value.iD_States,
|
||||||
|
registered_address_city: address_value.city,
|
||||||
|
registered_address_pin: address_value.pin,
|
||||||
|
registered_address_ownership_status:address_value.iD_OwnershipTypes
|
||||||
|
}
|
||||||
|
Object.assign(lstEntityKYCDetailObj,lstEntityAddressDetailObj)
|
||||||
|
}
|
||||||
|
else if(value.iD_ApplicantKYCDetail == address_value.iD_ApplicantKYCDetail && address_value.iD_OwnershipTypes == "Current" )
|
||||||
|
{
|
||||||
|
lstEntityAddress1DetailObj =
|
||||||
|
{
|
||||||
|
operating_address_of_business: [address_value.address1, address_value.address2, address_value.address3 ].filter(Boolean).join(" "),
|
||||||
|
operating_address_state: address_value.iD_States,
|
||||||
|
operating_address_city: address_value.city,
|
||||||
|
operating_address_pin: address_value.pin,
|
||||||
|
operating_address_ownership_status:address_value.iD_OwnershipTypes,
|
||||||
|
// operating_address_city_category : address_value.addressCategory
|
||||||
|
}
|
||||||
|
Object.assign(lstEntityKYCDetailObj,lstEntityAddress1DetailObj)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
lstEntityKYCDetailDataArray.push(lstEntityKYCDetailObj);
|
||||||
|
}
|
||||||
|
if (index === array.length -1)
|
||||||
|
{
|
||||||
|
resolve(lstEntityKYCDetailDataArray);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); // end of entity detail promise
|
||||||
|
// Create entity detail
|
||||||
|
EntityKYCDetailDataInsert.then(async(lstEntityKYCDetailDataArray)=>
|
||||||
|
{
|
||||||
|
lstEntityKYCDetailDataArray.forEach(async(element) =>
|
||||||
|
{
|
||||||
|
await EntityDetails.create(element)
|
||||||
|
.then(data=>{ logMsg.info("EntityDetails inserted"); })
|
||||||
|
.catch(err=>{ logMsg.info("EntityDetails Failed , Msg :" +err); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// application detail promise
|
||||||
|
var ApplicantKYCDetailDataInsert = new Promise(async(resolve, reject) =>
|
||||||
|
{
|
||||||
|
lstApplicantKYCDetailDataArray = [];
|
||||||
|
data.lstApplicantKYCDetail.forEach(async(value,index,array) => {
|
||||||
|
if (value.kycType == "Individual ")
|
||||||
|
{
|
||||||
|
Applicant_id = value.iD_ApplicantKYCDetail;
|
||||||
|
lstApplicantKYCDetailObj =
|
||||||
|
{
|
||||||
|
losid : LoanDetailData.dataValues.losid ,
|
||||||
|
loan_no_id : LoanDetailData.dataValues.id ,
|
||||||
|
name : [value.firstName, value.middleName, value.lastName ].filter(Boolean).join(" "),
|
||||||
|
}
|
||||||
|
lstApplicantKYCDetailDataArray.push(lstApplicantKYCDetailObj);
|
||||||
|
}
|
||||||
|
if (index === array.length -1)
|
||||||
|
{
|
||||||
|
resolve(lstApplicantKYCDetailDataArray);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); // end of application detail promise
|
||||||
|
// Create Application detail, Address detail , Relationship detail
|
||||||
|
ApplicantKYCDetailDataInsert.then(async(lstApplicantKYCDetailDataArray)=>
|
||||||
|
{
|
||||||
|
await ApplicantsDetails.bulkCreate(lstApplicantKYCDetailDataArray)
|
||||||
|
.then(ApplicantsDetailsData=>{
|
||||||
|
if(data.lstLoanApplication.entity_type == "Individual " && data.lstApplicantAddress.length != 0 )
|
||||||
|
{
|
||||||
|
// ResidenceAddressDetails data
|
||||||
|
data.lstApplicantAddress.forEach(async(ApplicantAddress) =>
|
||||||
|
{
|
||||||
|
// Applicant Address Create
|
||||||
|
if (ApplicantAddress.iD_ApplicantKYCDetail == Applicant_id && ApplicantAddress.iD_OwnershipTypes == "Permanent")
|
||||||
|
{
|
||||||
|
Object.assign(ApplicantAddress,
|
||||||
|
{
|
||||||
|
loan_no_id : LoanDetailData.dataValues.losid ,
|
||||||
|
losid : ApplicantsDetailsData.dataValues.losid ,
|
||||||
|
applicant_id: ApplicantsDetailsData.dataValues.id ,
|
||||||
|
residence_address : [ApplicantAddress.address1, ApplicantAddress.address2, ApplicantAddress.address3 , ApplicantAddress.iD_States , ApplicantAddress.city , ApplicantAddress.pin ].filter(Boolean).join(" "),
|
||||||
|
ownership_status : ApplicantAddress.iD_OwnershipTypes ,
|
||||||
|
// residence_location_area
|
||||||
|
})
|
||||||
|
await ResidenceAddressDetails.create(ApplicantAddress)
|
||||||
|
.then(data=>{logMsg.info("ResidenceAddressDetails inserted");})
|
||||||
|
.catch(err=>{logMsg.info("ResidenceAddressDetails Failed , Msg :" +err);});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).catch(err=>{ logMsg.info("ApplicantsDetails Failed , Msg :" +err); }); // ApplicantsDetails Create catch block
|
||||||
|
});
|
||||||
|
}).catch(err=>{ logMsg.info("LoanDetails Failed , Msg :" +err); }) // Loan deatil Create catch block
|
||||||
|
} // end of if lstLoanApplication
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logMsg.info("Los api call failed Failed , Msg :" +err);
|
||||||
|
} // Los api call failed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Final Response
|
||||||
|
LoanDetail.findAll({raw: true , where : { losid : "MW00004618" , is_active : 1}}).then(data =>
|
||||||
|
{
|
||||||
|
if(data.length > 0)
|
||||||
|
{
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
res.send({'status':200,'message':"success",'data':data});
|
||||||
// if (data.status == 'Successful')
|
}
|
||||||
// {
|
else {
|
||||||
// if (data.lstLoanApplication.length != 0)
|
res.send({'status':404,'message':"failed",'data':"No data"});
|
||||||
// {
|
}
|
||||||
// loanDetailData = data.lstLoanApplication[0];
|
})
|
||||||
// loanDetailObject = {
|
.catch(err => {
|
||||||
// applicationNo : loanDetailData.applicationNo,
|
res.send({'status':404,
|
||||||
// losid : loanDetailData.loginNo ,
|
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||||
// date_of_login : moment(new Date(loanDetailData.loginDate)).format("YYYY-MM-DD"),
|
});
|
||||||
// sourcing_channel_name : loanDetailData.source,
|
|
||||||
// emi_of_loan_applied_for : LoanDeatilList.loanAmount,
|
|
||||||
// //product : LoanDeatilList.iD_LoanProduct
|
|
||||||
// }
|
|
||||||
// LoanDetail.create(loanDetailObject).then(LoanDetailData =>
|
|
||||||
// {
|
|
||||||
// if (data.lstApplicantKYCDetail.length != 0)
|
|
||||||
// {
|
|
||||||
// var ApplicantKYCDetailDataInsert = new Promise(async(resolve, reject) => {
|
|
||||||
// lstApplicantKYCDetailDataArray = [];
|
|
||||||
// data.lstApplicantKYCDetail.forEach(async(value,index,array) => {
|
|
||||||
|
|
||||||
// lstApplicantKYCDetailObj = {
|
} // end of try block
|
||||||
|
catch(err)
|
||||||
|
{
|
||||||
// }
|
|
||||||
// lstApplicantKYCDetailDataArray.push(lstApplicantKYCDetailObj);
|
|
||||||
|
|
||||||
// if (index === array.length -1) { resolve(lstApplicantKYCDetailDataArray); }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// ApplicantKYCDetailDataInsert.then(async(lstApplicantKYCDetailDataArray)=>{
|
|
||||||
// console.log(lstApplicantKYCDetailDataArray);
|
|
||||||
// await ApplicantsDetails.bulkCreate(lstApplicantKYCDetailDataArray).catch(err=>{ });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// } else { } // lstApplicantKYCDetail array is empty from Los api
|
|
||||||
|
|
||||||
// }).catch(err => {res.send({'status':404,message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });});
|
|
||||||
|
|
||||||
|
|
||||||
// } else { } // lstLoanApplication array is empty from Los api
|
|
||||||
|
|
||||||
// } else { } // Los api call failed
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// LoanDetail.findAll({raw: true , where : { losid : req.query.losid , 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" });
|
|
||||||
// });
|
|
||||||
|
|
||||||
} catch(err) {
|
|
||||||
res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" });
|
res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" });
|
||||||
} //end of try catch
|
} //end of try catch
|
||||||
|
|
||||||
|
|||||||
@ -1433,6 +1433,8 @@ router.post("/updateEnquiriesAndDisbursementsDetails", Entitycontroller.updateEn
|
|||||||
* @swagger
|
* @swagger
|
||||||
* definitions:
|
* definitions:
|
||||||
* updateDueDiligenceCheck:
|
* updateDueDiligenceCheck:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
* id:
|
* id:
|
||||||
@ -2084,6 +2086,8 @@ router.get("/atnwRelationMaster", Mastercontroller.atnwRelationMaster);
|
|||||||
* @swagger
|
* @swagger
|
||||||
* definitions:
|
* definitions:
|
||||||
* updateATNWrelatedInputs:
|
* updateATNWrelatedInputs:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
* type: object
|
* type: object
|
||||||
* properties:
|
* properties:
|
||||||
* id:
|
* id:
|
||||||
@ -2111,9 +2115,30 @@ router.get("/atnwRelationMaster", Mastercontroller.atnwRelationMaster);
|
|||||||
* description:
|
* description:
|
||||||
* example: 1
|
* example: 1
|
||||||
* subValue:
|
* subValue:
|
||||||
* type: string
|
* type: array
|
||||||
* description: json string
|
* items:
|
||||||
* example:
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: integer
|
||||||
|
* description:
|
||||||
|
* example: 1
|
||||||
|
* master_id:
|
||||||
|
* type: integer
|
||||||
|
* description:
|
||||||
|
* example: 1
|
||||||
|
* atnw_related_input:
|
||||||
|
* type: integer
|
||||||
|
* description:
|
||||||
|
* example: 1
|
||||||
|
* atnw_related_input_value:
|
||||||
|
* type: integer
|
||||||
|
* description:
|
||||||
|
* example: 1
|
||||||
|
* updatedby:
|
||||||
|
* type: integer
|
||||||
|
* description:
|
||||||
|
* example: 1
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user