diff --git a/app/controllers/entity.applicant.controller.js b/app/controllers/entity.applicant.controller.js index c035f4c..af82ef0 100644 --- a/app/controllers/entity.applicant.controller.js +++ b/app/controllers/entity.applicant.controller.js @@ -1015,18 +1015,24 @@ exports.updateOtherParameters = async (req, res) => { try { - id = req.body.id; - delete req.body.id; - // update value - OtherParameters.update(req.body,{ where: { id: id }}).then(data => - { - res.send({'status':200,'message':"success",'data':data}); - - }) - .catch(err => { - res.send({'status':404, - message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + req.body.forEach( async (element,index) => + { + id = element.id; + delete element.id; + // update value + OtherParameters.update(element,{ where: { id: id }}).then(data => + { + if ([req.body].length - 1 == index) { + res.send({'status':200,'message':"success",'data':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" }); diff --git a/app/routes/routes.js b/app/routes/routes.js index 40b6929..5e20af5 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -2201,32 +2201,34 @@ router.get("/otherParameterMaster", Mastercontroller.otherParameterMaster); * @swagger * definitions: * updateOtherParameters: -* type: object -* properties: -* id: -* type: integer -* description: -* example: 1 -* entity_id: -* type: integer -* description: -* example: 1 -* op_master_id: -* type: integer -* description: -* example: 1 -* master_name: -* type: string -* description: -* example: property_own_doc_avail -* value: -* type: string -* description: -* example: Yes -* updatedby: -* type: integer -* description: -* example: 1 +* type: array +* items: +* type: object +* properties: +* id: +* type: integer +* description: +* example: 1 +* entity_id: +* type: integer +* description: +* example: 1 +* op_master_id: +* type: integer +* description: +* example: 1 +* master_name: +* type: string +* description: +* example: property_own_doc_avail +* value: +* type: string +* description: +* example: Yes +* updatedby: +* type: integer +* description: +* example: 1 */ /** * @swagger diff --git a/app/services/ApiCallHelper.js b/app/services/ApiCallHelper.js index df1bb81..c19815a 100644 --- a/app/services/ApiCallHelper.js +++ b/app/services/ApiCallHelper.js @@ -213,21 +213,18 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti // ApplicantsRelationship Table var ApplicantsRelationshipPromise = new Promise(async(resolve, reject) => { - // if(EntityType == "Individual") - // { + if(EntityType == "Individual") + { ApplicantsRelationshipData = { } Object.assign(ApplicantsRelationshipData, {name_of_the_individual : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid }); - // if (ApiArray.lstApplicantsRelationship.length != 0) - // { await ApplicantsRelationship.create(ApplicantsRelationshipData) .then(data=>{ resolve("ApplicantsRelationship")}).catch(err=>{logMsg.info("ApplicantsRelationship Failed , Msg :" +err);}); - // } - // } + } }); // ResidenceAddressDetails Table var ResidenceAddressDetailsPromise = new Promise(async(resolve, reject) => { - if(ApiArray.lstApplicantAddress.length != 0 /* && EntityType == "Individual" */) + if(ApiArray.lstApplicantAddress.length != 0 && EntityType == "Individual" ) { // ResidenceAddressDetails data ApiArray.lstApplicantAddress.forEach(async(ApplicantAddress,index) => @@ -246,7 +243,6 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti await ResidenceAddressDetails.create(ApplicantAddress) .then(data=> { - // logMsg.info("ResidenceAddressDetails inserted"); if ([ApiArray.lstApplicantAddress].length - 1 == index) { resolve("ResidenceAddressDetails") @@ -255,26 +251,25 @@ function ApplicantChildTable(ApplicantName , LoanId , ApplicantId , Losid , Enti .catch(err=>{logMsg.info("ResidenceAddressDetails Failed , Msg :" +err);}); } }); - } }) - // ResidenceAddressDetails Table + // PropertyOwnershipIncomeConsidered Table var PropertyOwnershipIncomeConsideredPromise = new Promise(async(resolve, reject) => { - // if (product == "LFMP") - // { + if (Product == "LFMP") + { PropertyOwnershipIncomeConsideredData = { } Object.assign(PropertyOwnershipIncomeConsideredData, {name_of_the_loan_applicants : ApplicantName ,applicant_id: ApplicantId, loan_no_id: LoanId ,losid: Losid }); await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData) .then(data=>{ resolve("PropertyOwnershipIncomeConsidered") }).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);}); - // } + } }); Promise.all([ApplicantsRelationshipPromise, ResidenceAddressDetailsPromise, PropertyOwnershipIncomeConsideredPromise ]) .then((values) => { values.forEach(element => { - logMsg.info(element+ " Data Creation Success for EntityId= "+EntityId); // [3, 1337, "foo"] + logMsg.info(element+ " Data Creation Success for ApplicantId= "+ApplicantId); // [3, 1337, "foo"] }); })