susee , updateATNW api
This commit is contained in:
parent
96b3388d1c
commit
56064ffb46
@ -1,3 +1,4 @@
|
||||
const { raw } = require('body-parser');
|
||||
const { sequelize , LoanDetail , EntityDetails , ApplicantsDetails , ApplicantsRelationship , ResidenceAddressDetails , PropertyOwnershipIncomeConsidered , DueDiligenceCheck , TradeReferences , CheckTypeMaster , EnquiriesAndDisbursements , PropertyAndLtv , ATNWrelatedInputs , SalesPD , ATNWrelatedInputMaster ,ATNWrelationship , OtherParameterMaster ,OtherParameterMasterValue , OtherParameterRelationship , OtherParameters , ATNErelatedInputSubVal , DataFromLos } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
@ -162,20 +163,26 @@ exports.createApplicantDetails = async (req, res) =>
|
||||
await ResidenceAddressDetails.create(ResidenceAddressDetailsData)
|
||||
.then(data=>{logMsg.info("ResidenceAddressDetails inserted");}).catch(err=>{logMsg.info("ResidenceAddressDetails Failed , Msg :" +err);});
|
||||
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {loan_no_id: req.body.loan_no_id});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {losid: req.body.losid});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {applicant_id: data.dataValues.id});
|
||||
await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData)
|
||||
.then(data=>{logMsg.info("PropertyOwnershipIncomeConsidered inserted");}).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);});
|
||||
if (req.body.product == "LFMP")
|
||||
{
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {loan_no_id: req.body.loan_no_id});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {losid: req.body.losid});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {applicant_id: data.dataValues.id});
|
||||
await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData)
|
||||
.then(data=>{logMsg.info("PropertyOwnershipIncomeConsidered inserted");}).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {loan_no_id: req.body.loan_no_id});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {losid: req.body.losid});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {applicant_id: data.dataValues.id});
|
||||
await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData)
|
||||
.then(data=>{logMsg.info("PropertyOwnershipIncomeConsidered inserted");}).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);});
|
||||
}
|
||||
if (req.body.product == "LFMP")
|
||||
{
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {loan_no_id: req.body.loan_no_id});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {losid: req.body.losid});
|
||||
PropertyOwnershipIncomeConsideredData = Object.assign(PropertyOwnershipIncomeConsideredData, {applicant_id: data.dataValues.id});
|
||||
await PropertyOwnershipIncomeConsidered.create(PropertyOwnershipIncomeConsideredData)
|
||||
.then(data=>{logMsg.info("PropertyOwnershipIncomeConsidered inserted");}).catch(err=>{logMsg.info("PropertyOwnershipIncomeConsidered Failed , Msg :" +err);});
|
||||
}
|
||||
}
|
||||
|
||||
// send response here
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
@ -761,43 +768,46 @@ exports.updateATNWrelatedInputs = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const update_subValue_data = req.body.subValue;
|
||||
delete req.body.subValue;
|
||||
id = req.body.id;
|
||||
delete req.body.id;
|
||||
// update value
|
||||
ATNWrelatedInputs.update(req.body,{ where: { id: id }}).then(data =>
|
||||
{
|
||||
if (req.body.atnw_related_input_id == 8)
|
||||
req.body.forEach( async (element , index ) =>
|
||||
{
|
||||
const update_subValue_data = element.subValue;
|
||||
delete element.subValue;
|
||||
id = element.id;
|
||||
delete element.id;
|
||||
ATNWrelatedInputs.update(element,{ where: { id: id }}).then(data =>
|
||||
{
|
||||
|
||||
update_subValue_data.forEach( async (update_subValue_data_element) => {
|
||||
id = update_subValue_data_element.id;
|
||||
delete update_subValue_data_element.id;
|
||||
ATNErelatedInputSubVal.update(update_subValue_data_element,{ 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" });
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
}
|
||||
logMsg.info("ATNWrelatedInputs Data Update Success "+data);
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (element.atnw_related_input_id == 8)
|
||||
{
|
||||
|
||||
update_subValue_data.forEach( async (update_subValue_data_element , index ) => {
|
||||
id = update_subValue_data_element.id;
|
||||
delete update_subValue_data_element.id;
|
||||
ATNErelatedInputSubVal.update(update_subValue_data_element,{ where: { id: id }}).then(data =>
|
||||
{
|
||||
if (update_subValue_data.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" });
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
// else if( req.body.length - 1 == index )
|
||||
// {
|
||||
// res.send({'status':200,'message':"success",'data':data});
|
||||
// }
|
||||
logMsg.info("ATNWrelatedInputs Data Update Success "+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" });
|
||||
} //end of try catch
|
||||
@ -971,12 +981,14 @@ exports.ATNWrelatedInputsList = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ATNWrelatedInputs.findAll({where : {entity_id : req.query.entity_id , is_active : 1},
|
||||
ATNWrelatedInputs.findAll( { where : {entity_id : req.query.entity_id , is_active : 1},
|
||||
include : [{ model: ATNErelatedInputSubVal }]
|
||||
}).then(data =>
|
||||
{
|
||||
if(data.length > 0)
|
||||
{
|
||||
Object.assign(data[7].ATNErelatedInputSubVals[0].dataValues ,{ 'market_valuation_rs' : data[7].ATNErelatedInputSubVals[0].atnw_related_input_value });
|
||||
Object.assign(data[7].ATNErelatedInputSubVals[1].dataValues,{ 'gross_book_value_rs' : data[7].ATNErelatedInputSubVals[1].atnw_related_input_value });
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
}
|
||||
else {
|
||||
|
||||
@ -485,6 +485,10 @@ router.post("/createEntityDetails", Entitycontroller.createEntityDetails);
|
||||
* type: integer
|
||||
* description:
|
||||
* example: 1
|
||||
* product:
|
||||
* type: string
|
||||
* description:
|
||||
* example: LFMP
|
||||
* pan_no:
|
||||
* type: string
|
||||
* description:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user