OtherParameter update api: suseendhiran

This commit is contained in:
suseendhiran17 2022-08-06 10:21:18 +05:30
parent f489736f8d
commit c54103230c
3 changed files with 54 additions and 51 deletions

View File

@ -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" });

View File

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

View File

@ -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"]
});
})