diff --git a/app/controllers/creditpd.controller.js b/app/controllers/creditpd.controller.js index ea15610..d70b9c8 100644 --- a/app/controllers/creditpd.controller.js +++ b/app/controllers/creditpd.controller.js @@ -18,10 +18,10 @@ exports.PullCreditPdData = async (req, res) => { GenInfoObj = {}; temp_array = []; // create creditGeneralInormationData - Object.assign(obj, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno}); - PDID = await CreditGeneralInformation.create(obj) + Object.assign(obj, { ref_no: tempData[0].pdid , product :tempData[0].product , case_no :tempData[0].caseno}); + PDID = await CreditGeneralInformation.create(obj); logMsg.info("GeneralInformation insert success ,PdId= "+PDID.dataValues.pd_id); - for (var [OverallKey, OverallValue] of Object.entries(tempData)) { + for (var [OverallKey, OverallValue] of Object.entries(tempData[0].data)) { table_name = await CreditFilterTable.findAll({ raw: true, attributes: [ 'table_name'], where : { section : OverallKey , is_active : 1 } , group: ['table_name']}) obj = { }; temp_array.length = 0 ; @@ -55,14 +55,16 @@ exports.PullCreditPdData = async (req, res) => { { temp_array.forEach(async(element) => { Object.assign(element , {pd_id : PDID.dataValues.pd_id} ); Object.assign(element ,obj ); - var index = table_name[0].table_name; var tableName = arr[index] + var index = table_name[0].table_name; + var tableName = arr[index]; await tableName.create(element); logMsg.info(OverallKey+" insert success ,PdId= "+PDID.dataValues.pd_id); }); } else { Object.assign(obj , {pd_id : PDID.dataValues.pd_id} ); - var index = table_name[0].table_name; var tableName = arr[index] + var index = table_name[0].table_name; + var tableName = arr[index]; tableName.create(obj);logMsg.info(OverallKey+" insert success ,PdId= "+PDID.dataValues.pd_id); } } @@ -238,12 +240,59 @@ exports.GetCreditPdData = async (req, res) => -// // test - - - - - + + + + +// exports.GetCreditPdData__1 = async (req, res) => +// { +// try +// { + // applicantDetails = await Credit_PdHelper.MainApplicantDetails(req.query.losid); + // MainApplicantDetails = JSON.parse(applicantDetails); + // if(MainApplicantDetails.status == 200) + // { + // CreditGeneralInformation.findAll({ where : { pd_id :407,is_active : 1}, + // include : [ + // {model: CreditAddressDetail }, {model: CreditFuturePlans }, + // {model : CreditBorrowerAndGuarantorDetails }, + // {model: CreditBusinessAndPersonalBankingDetails }, {model: BusinessAsset }, + // {model: CreditFinancialInformation }, {model: CreditKeyShareholder }, + // {model: CreditKeyProductBusinessContribution }, {model: EmployeeStrength }, + // {model: ClientDetail }, {model: StockDetail }, + // {model: CreditExistingLoanObligation }, + // {model: FamilyMemberInvolvedInBusiness }, + // {model : CreditManager }, + // {model: Photograph }, + // {model: CreditFinalRemarks }, {model: CreditLoanDetail }, + // {model: CreditGeneralBusinessInformation }, + // {model: SupplierDetail } + // ] + // }) + // .then((data)=>{ + // if (data.length > 0) + // { + // res.send({'status':200,'message':"success",'data':data}); + // } + // else + // { + // res.send({'status':404,'message':"failed",'data':"No data"}); + // } + // }) + + // } + // else + // { + // res.send({'status':404,'message':"failed",'data':"No data"}); + // } + +// } catch(err) { +// res.status(500).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 d7d7a2f..035cd4a 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -189,7 +189,7 @@ router.get('/imageView',CreditPdController.imageView); router.get('/GetCreditPdData',CreditPdController.GetCreditPdData) - +// router.get('/GetCreditPdData__1',CreditPdController.GetCreditPdData__1)