From 0f6918614f1a666de7d82fbb35b996ba3df4a47c Mon Sep 17 00:00:00 2001 From: sriramv Date: Sat, 26 Mar 2022 17:22:17 +0530 Subject: [PATCH] losidchanged:GWM --- .../entity.applicant.controller.js | 182 +++++++++++++++--- app/models/ApplicantsDetails.js | 1 + app/models/ApplicantsRelationship.js | 1 + app/models/EntityDetails.js | 2 + .../PropertyOwnershipIncomeConsidered.js | 1 + app/models/ResidenceAddressDetails.js | 1 + app/routes/routes.js | 91 ++++++++- 7 files changed, 242 insertions(+), 37 deletions(-) diff --git a/app/controllers/entity.applicant.controller.js b/app/controllers/entity.applicant.controller.js index 5cf0b77..741cac6 100644 --- a/app/controllers/entity.applicant.controller.js +++ b/app/controllers/entity.applicant.controller.js @@ -87,16 +87,19 @@ exports.createApplicantDetails = async (req, res) => if(req.body.entity_type == "Individual") { ApplicantsRelationshipData = Object.assign(ApplicantsRelationshipData, {loan_no_id: req.body.loan_no_id}); + ApplicantsRelationshipData = Object.assign(ApplicantsRelationshipData, {losid: req.body.losid}); ApplicantsRelationshipData = Object.assign(ApplicantsRelationshipData, {applicant_id: data.dataValues.id}); await ApplicantsRelationship.create(ApplicantsRelationshipData) .then(data=>{logMsg.info("ApplicantsRelationship inserted");}).catch(err=>{logMsg.info("ApplicantsRelationship Failed , Msg :" +err);}); ResidenceAddressDetailsData = Object.assign(ResidenceAddressDetailsData, {loan_no_id: req.body.loan_no_id}); + ResidenceAddressDetailsData = Object.assign(ResidenceAddressDetailsData, {losid: req.body.losid}); ResidenceAddressDetailsData = Object.assign(ResidenceAddressDetailsData, {applicant_id: data.dataValues.id}); 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);}); @@ -104,6 +107,7 @@ exports.createApplicantDetails = async (req, res) => 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);}); @@ -449,7 +453,7 @@ exports.EntityDetailsList = async (req, res) => { try { - EntityDetails.findAll({raw: true ,where:{loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => + EntityDetails.findAll({raw: true ,where:{losid : req.query.losid , loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => { if(data.length > 0) { @@ -477,7 +481,7 @@ exports.ApplicantDetailsList = async (req, res) => { try { - ApplicantsDetails.findAll({raw: true , where:{loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => + ApplicantsDetails.findAll({raw: true , where:{losid : req.query.losid ,loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => { if(data.length > 0) { @@ -505,7 +509,7 @@ exports.ApplicantRelationshipList = async (req, res) => { try { - ApplicantsRelationship.findAll({raw: true , where:{loan_no_id : req.query.loan_no_id , is_active : 1 }}).then(data => + ApplicantsRelationship.findAll({raw: true , where:{losid : req.query.losid , loan_no_id : req.query.loan_no_id , is_active : 1 }}).then(data => { if(data.length > 0) { @@ -533,7 +537,7 @@ exports.ResidenceAddressDetailsList = async (req, res) => { try { - ResidenceAddressDetails.findAll({raw: true , where:{loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => + ResidenceAddressDetails.findAll({raw: true , where:{losid : req.query.losid , loan_no_id : req.query.loan_no_id , is_active : 1}}).then(data => { if(data.length > 0) { @@ -561,7 +565,7 @@ exports.PropertyOwnershipList = async (req, res) => { try { - PropertyOwnershipIncomeConsidered.findAll({raw: true , where:{loan_no_id : req.query.loan_no_id , is_active : 1 }}).then(data => + PropertyOwnershipIncomeConsidered.findAll({raw: true , where:{losid : req.query.losid , loan_no_id : req.query.loan_no_id , is_active : 1 }}).then(data => { if(data.length > 0) { @@ -670,39 +674,157 @@ exports.EnquiriesAndDisbursementsList = async (req, res) => +// Entity and Applicant Name List Api for banking module +exports.EntityApplicantNameList = async (req, res) => +{ + try + { + sequelize.query("select losid, entity_name as ac_in_name_of from entity_details where losid = '"+req.query.losid+"' and is_active = 1 union select losid, name as ac_in_name_of from applicants where losid = '"+req.query.losid+"' and is_active = 1") + .then(async(data)=>{ + res.send({'status':200,'message':"success",'data':data}); + }).catch(err=>{res.send({'status':404,message: err.message || "Some error occurred while fetching." ,'data': "No data" })}); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while fetching." ,'data': "No data" }); + } //end of try catch + +}; + + + + // test api exports.test = async (req, res) => { try { - start_date = "'2019-08-12'"; - let starting_date = new Date(start_date); - end_date = "'2021-05-12'"; - let date = new Date(end_date); - - years_skeleton = []; - for(let i=0;i<12;i++) - { - //store on fly month number - month_count = date.getMonth() + 1; - //create on fly month data - new_date = date.toLocaleString('default', { month: 'short' })+"-"+date.getFullYear(); - //create on fly period data - new_period = date.getFullYear()+"-"+month_count+"-01"; - obj = {month:new_date,period:new_period}; - // push skeleton object - years_skeleton.push(obj); - //Reset date here - date.setMonth(date.getMonth() - 1); - //check if loop meets starting date or not - if(starting_date.getFullYear() == date.getFullYear() && starting_date.getMonth() + 1 == month_count) { break; } - } - - console.log(years_skeleton); + } 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 fetching." ,'data': "No data" }); } //end of try catch }; + + + + + + + + + + + + + + + + + +// exports.queryConstruct = async (req, res) => { +// try +// { +// data = []; +// let Queryvalues = "CREATE TABLE com_borrower_profile "; +// data.forEach((result, index, array) => { +// Object.keys(result).forEach((key) => { +// if(index == 0) +// { +// if(result[key] == 'float') +// { Datatype = "numeric(25,0) NULL"; Queryvalues += "("+key +" "+Datatype+","; } +// else if(result[key] == 'NoneType') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += "("+key +" "+Datatype+","; } +// else if(result[key] == 'str') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += "("+key +" "+Datatype+","; } +// else if(result[key] == 'datetime') +// { Datatype = "datetime NULL"; Queryvalues += "("+key +" "+Datatype+","; } +// else if(result[key] == 'int') +// { Datatype = "int NULL"; Queryvalues += "("+key +" "+Datatype+","; } + +// } +// else if (array.length == index + 1 ) +// { +// if(result[key] == 'float') +// { Datatype = "numeric(25,0) NULL"; Queryvalues += key +" "+Datatype+", ";} +// else if(result[key] == 'NoneType') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += key +" "+Datatype+", ";} +// else if(result[key] == 'str') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += key +" "+Datatype+", "; } +// else if(result[key] == 'datetime') +// { Datatype = "datetime NULL"; Queryvalues += key +" "+Datatype+", "; } +// else if(result[key] == 'int') +// { Datatype = "int NULL"; Queryvalues += key +" "+Datatype+")"; } + +// } +// else +// { +// if(result[key] == 'float') +// { Datatype = "numeric(25,0) NULL"; Queryvalues += key +" "+Datatype+","; } +// else if(result[key] == 'NoneType') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += key +" "+Datatype+","; } +// else if(result[key] == 'str') +// { Datatype = "nvarchar(255) NULL"; Queryvalues += key +" "+Datatype+","; } +// else if(result[key] == 'datetime') +// { Datatype = "datetime NULL"; Queryvalues += key +" "+Datatype+","; } +// else if(result[key] == 'int') +// { Datatype = "int NULL"; Queryvalues += key +" "+Datatype+","; } + +// } +// }) + +// }) + +// setTimeout(() => { + +// Queryvalues += "createdby int NULL , createdAt datetimeoffset(7) NULL , updatedby int NULL , updatedAt datetimeoffset(7) NULL )" +// console.log(Queryvalues); +// }, 7000); + + +// }catch(err) { +// res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data"}); +// } + +// }; + + + +// exports.insertQueryConstruct = async (req, res) => { +// try +// { +// ColumnNameData = [{"PhoneDetailsID": "float"}, {"MemberReferenceNumber": "float"}, {"TelephoneNumber": "float"}, {"TelephoneExtension": "NoneType"}, {"TelephoneType": "str"}, {"EnrichedThroughEnquiry": "str"}]; +// QueryColumn = "INSERT INTO table_name "; +// ColumnNameData.forEach((result, index, array) => { +// Object.keys(result).forEach((key) => { +// if(index == 0) { QueryColumn += "( "+key; } +// else if (array.length == index + 1 ) { QueryColumn += ", "+key+" )"; } +// else { QueryColumn += ", "+key; } +// }) + +// }) +// data = []; +// let Queryvalues = ""; +// data.forEach((result, index, array) => { +// Object.keys(result).forEach((key , index , array ) => { +// if(index == 0) { +// if (typeof result[key] === 'string' ) { Queryvalues += "('"+result[key]+"',"; } else { Queryvalues += "("+result[key]+","; } +// } +// else if (array.length == index + 1 ) { +// if (typeof result[key] === 'string' ) { Queryvalues += "'"+result[key]+"'),"; } else { Queryvalues += result[key]+"),"; } +// } +// else { +// if (typeof result[key] === 'string' ) { Queryvalues += "'"+result[key]+"',"; } else { Queryvalues += result[key]+","; } +// } +// }) +// }) + +// setTimeout(() => { +// Queryvalues = Queryvalues.slice(0, -1); +// console.log(QueryColumn +" VALUES "+ Queryvalues); +// }, 7000); + +// }catch(err) { res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data"}); } + +// }; \ No newline at end of file diff --git a/app/models/ApplicantsDetails.js b/app/models/ApplicantsDetails.js index 318dcf6..a2358ba 100644 --- a/app/models/ApplicantsDetails.js +++ b/app/models/ApplicantsDetails.js @@ -17,6 +17,7 @@ module.exports = (sequelize, DataTypes) => { ApplicantsDetails.init( { loan_no_id: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, name: { type: DataTypes.STRING }, entity_type: { type: DataTypes.STRING }, designation: { type: DataTypes.STRING }, diff --git a/app/models/ApplicantsRelationship.js b/app/models/ApplicantsRelationship.js index 82dfca9..f521c67 100644 --- a/app/models/ApplicantsRelationship.js +++ b/app/models/ApplicantsRelationship.js @@ -8,6 +8,7 @@ module.exports = (sequelize, DataTypes) => { ApplicantsRelationship.init( { loan_no_id: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, applicant_id: { type: DataTypes.INTEGER }, name_of_the_individual: { type: DataTypes.STRING }, related_to: { type: DataTypes.STRING }, diff --git a/app/models/EntityDetails.js b/app/models/EntityDetails.js index 1fd10fc..698bbc2 100644 --- a/app/models/EntityDetails.js +++ b/app/models/EntityDetails.js @@ -16,7 +16,9 @@ module.exports = (sequelize, DataTypes) => { } EntityDetails.init( { + loan_no_id: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, snep_sep: { type: DataTypes.STRING }, cat_of_sep: { type: DataTypes.STRING }, sub_cat_of_sep: { type: DataTypes.STRING }, diff --git a/app/models/PropertyOwnershipIncomeConsidered.js b/app/models/PropertyOwnershipIncomeConsidered.js index f459567..591899b 100644 --- a/app/models/PropertyOwnershipIncomeConsidered.js +++ b/app/models/PropertyOwnershipIncomeConsidered.js @@ -7,6 +7,7 @@ module.exports = (sequelize, DataTypes) => { PropertyOwnershipIncomeConsidered.init( { loan_no_id: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, applicant_id: { type: DataTypes.INTEGER }, name_of_the_loan_applicants: { type: DataTypes.STRING }, applicant_type: { type: DataTypes.STRING }, diff --git a/app/models/ResidenceAddressDetails.js b/app/models/ResidenceAddressDetails.js index f5fe899..795b514 100644 --- a/app/models/ResidenceAddressDetails.js +++ b/app/models/ResidenceAddressDetails.js @@ -17,6 +17,7 @@ module.exports = (sequelize, DataTypes) => { ResidenceAddressDetails.init( { loan_no_id: { type: DataTypes.INTEGER }, + losid: { type: DataTypes.STRING }, applicant_id: { type: DataTypes.INTEGER }, name_of_the_individual: { type: DataTypes.STRING }, residence_address: { type: DataTypes.STRING }, diff --git a/app/routes/routes.js b/app/routes/routes.js index 42c6b8b..f0de09f 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -19,7 +19,6 @@ module.exports = app => { * description: success */ router.get("/demo", Testcontroller.Welcome); -router.get("/test", Entitycontroller.test); // Loan Details List Api @@ -36,6 +35,27 @@ router.get("/test", Entitycontroller.test); router.get("/landingPageApi", Entitycontroller.LoanNumberDetailsList); +// entity_applicant_name list for banking module +/** +* @swagger +* /api/entityApplicantNameList: +* get: +* summary: Entity & Applicant Name List +* description: Get Entity Applicant Name List for losid +* parameters: +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 +* responses: +* 200: +* description: success +*/ +router.get("/entityApplicantNameList", Entitycontroller.EntityApplicantNameList); + // Entity Details List Api /** * @swagger @@ -51,6 +71,13 @@ router.get("/landingPageApi", Entitycontroller.LoanNumberDetailsList); * required: true * description: id of the Loan Details (primart key of Los_id) * example: 1 +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 * responses: * 200: * description: success @@ -72,6 +99,13 @@ router.get("/entityDetailsList", Entitycontroller.EntityDetailsList); * required: true * description: id of the Loan Details (primart key of Los_id) * example: 1 +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 * responses: * 200: * description: success @@ -93,6 +127,13 @@ router.get("/applicantDetailsList", Entitycontroller.ApplicantDetailsList); * required: true * description: id of the Loan Details (primart key of Los_id) * example: 1 +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 * responses: * 200: * description: success @@ -114,6 +155,13 @@ router.get("/applicantRelationshipList", Entitycontroller.ApplicantRelationshipL * required: true * description: id of the Loan Details (primart key of Los_id) * example: 1 +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 * responses: * 200: * description: success @@ -136,6 +184,13 @@ router.get("/residenceAddressDetailsList", Entitycontroller.ResidenceAddressDeta * required: true * description: id of the Loan Details (primart key of Los_id) * example: 1 +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Loan ID +* example: MW112233 * responses: * 200: * description: success @@ -223,6 +278,10 @@ router.get("/enquiriesAndDisbursementsList", Entitycontroller.EnquiriesAndDisbur * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * snep_sep: * type: string * description: @@ -399,6 +458,10 @@ router.post("/createEntityDetails", Entitycontroller.createEntityDetails); * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * snep_sep: * type: string * description: @@ -571,6 +634,10 @@ router.post("/updateEntityDetails", Entitycontroller.updateEntityDetails); * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * name: * type: string * description: @@ -615,12 +682,6 @@ router.post("/updateEntityDetails", Entitycontroller.updateEntityDetails); * type: integer * description: * example: 003 -* applicant_relationship: -* type: application/json -* description: -* example: -* schema: -* $ref: '#/definitions/applicant_relationship' */ @@ -784,6 +845,10 @@ router.post("/createApplicantDetails", Entitycontroller.createApplicantDetails); * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * name: * type: string * description: @@ -864,6 +929,10 @@ router.post("/updateApplicantDetails", Entitycontroller.updateApplicantDetails); * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * applicant_id: * type: integer * description: @@ -952,6 +1021,10 @@ router.post("/updateApplicantsRelationship", Entitycontroller.updateApplicantsRe * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * applicant_id: * type: integer * description: @@ -1032,6 +1105,10 @@ router.post("/updateResidenceAddressDetails", Entitycontroller.updateResidenceAd * type: integer * description: * example: 1 +* losid: +* type: string +* description: +* example: MW112233 * applicant_id: * type: integer * description: