From 30e05d13ebaddb24fed99e9b1b205d8838010b9b Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Fri, 6 Jan 2023 19:01:58 +0530 Subject: [PATCH] suseendhiran --- app/controllers/creditpd.controller.js | 68 +++--------------- app/routes/routes.js | 3 - app/services/CreditPdHelper.js | 6 +- .../uploads/1673011131265-company-logo.png | Bin 0 -> 1698 bytes 4 files changed, 11 insertions(+), 66 deletions(-) create mode 100644 storage/uploads/1673011131265-company-logo.png diff --git a/app/controllers/creditpd.controller.js b/app/controllers/creditpd.controller.js index 5cf90c9..c6c5087 100644 --- a/app/controllers/creditpd.controller.js +++ b/app/controllers/creditpd.controller.js @@ -3,6 +3,7 @@ const { logMsg } = require('../services/logger.js'); const Credit_PdHelper = require('../services/CreditPdHelper.js'); const request = require('request'); const moment = require('moment'); +const { json } = require('body-parser'); // var global = require('global'); // global.arr = [ CreditAddressDetail , CreditBorrowerAndGuarantorDetails , CreditBusinessAndPersonalBankingDetails, BusinessAsset , ClientDetail , Covid19Questions , EmployeeStrength , CreditExistingLoanObligation , FamilyMemberInvolvedInBusiness , CreditFinalRemarks , CreditFinancialAnalysis , CreditFinancialInformation , CreditFuturePlans , CreditGeneralBusinessInformation , CreditGeneralInformation , CreditKeyProductBusinessContribution , CreditKeyShareholder , CreditLoanDetail , OverallPlanOfAction , PortFolioHealth , ProductAndProcess , CreditProfile , SizeAndGeographicalResearch , StockDetail , SupplierDetail , TotalOverallDebit , ValidationPoint , CreditManager , Photograph ] @@ -13,15 +14,16 @@ exports.PullCreditPdData = async (req, res) => { try { const arr = [ CreditAddressDetail , CreditBorrowerAndGuarantorDetails , CreditBusinessAndPersonalBankingDetails, BusinessAsset , ClientDetail , Covid19Questions , EmployeeStrength , CreditExistingLoanObligation , FamilyMemberInvolvedInBusiness , CreditFinalRemarks , CreditFinancialAnalysis , CreditFinancialInformation , CreditFuturePlans , CreditGeneralBusinessInformation , CreditGeneralInformation , CreditKeyProductBusinessContribution , CreditKeyShareholder , CreditLoanDetail , OverallPlanOfAction , PortFolioHealth , ProductAndProcess , CreditProfile , SizeAndGeographicalResearch , StockDetail , SupplierDetail , TotalOverallDebit , ValidationPoint , CreditManager , Photograph ] ; - const tempData = JSON.parse(JSON.stringify(req.body)); + const tempData = JSON.parse(JSON.stringify(req.body)); obj = {}; GenInfoObj = {}; temp_array = []; // create creditGeneralInormationData - Object.assign(obj, { ref_no: tempData[0].pdid , product :tempData[0].product , case_no :tempData[0].caseno}); + Object.assign(obj, { ref_no: tempData.pdid , product : tempData.product , case_no : tempData.caseno}); PDID = await CreditGeneralInformation.create(obj); logMsg.info("GeneralInformation insert success ,PdId= "+PDID.dataValues.pd_id); - for (var [OverallKey, OverallValue] of Object.entries(tempData[0].data)) { + for (var [OverallKey, OverallValue] of Object.entries(tempData.data)) { + if(OverallKey != "Officer Details") table_name = await CreditFilterTable.findAll({ raw: true, attributes: [ 'table_name'], where : { section : OverallKey , is_active : 1 } , group: ['table_name']}) obj = { }; temp_array.length = 0 ; @@ -57,6 +59,7 @@ exports.PullCreditPdData = async (req, res) => { Object.assign(element , {pd_id : PDID.dataValues.pd_id} ); Object.assign(element ,obj ); var index = table_name[0].table_name; var tableName = arr[index]; + console.log(tableName); await tableName.create(element); logMsg.info(OverallKey+" insert success ,PdId= "+PDID.dataValues.pd_id); }); } @@ -65,6 +68,7 @@ exports.PullCreditPdData = async (req, res) => { Object.assign(obj , {pd_id : PDID.dataValues.pd_id} ); var index = table_name[0].table_name; var tableName = arr[index]; + console.log(tableName); await tableName.create(obj);logMsg.info(OverallKey+" insert success ,PdId= "+PDID.dataValues.pd_id); } } @@ -186,6 +190,7 @@ exports.GetCreditPdData = async (req, res) => { try { + console.log(req.query.losid); applicantDetails = await Credit_PdHelper.MainApplicantDetails(req.query.losid); MainApplicantDetails = JSON.parse(applicantDetails); if(MainApplicantDetails.status == 200) @@ -242,60 +247,3 @@ exports.GetCreditPdData = async (req, res) => - - -// 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 :410,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 035cd4a..f89ef81 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -188,9 +188,6 @@ router.get('/imageView',CreditPdController.imageView); */ router.get('/GetCreditPdData',CreditPdController.GetCreditPdData) - -// router.get('/GetCreditPdData__1',CreditPdController.GetCreditPdData__1) - // DownloadPdReport diff --git a/app/services/CreditPdHelper.js b/app/services/CreditPdHelper.js index 392eea0..ed28f90 100644 --- a/app/services/CreditPdHelper.js +++ b/app/services/CreditPdHelper.js @@ -15,7 +15,7 @@ async function CreditPd(credit_key , credit_value ,credit_temp_array ,credit_ob async function MainApplicantDetails(losid) { try { - const url = "https://demo.devopsmcfinance.com/cet_mainapp/api/MainApplicantDetailsList?losid="+losid; + const url = `${ process.env.MAIN_APPLICANT_DETAIL }/MainApplicantDetailsList?losid=`+losid; return new Promise((resolve, reject) => { request({ @@ -89,10 +89,10 @@ async function ARRAY(Array , GenInfoObj , OverallKey) { if (typeof Value === "object" && ( Value !== null )) { Obj = await OBJECT( element, Key , Value ); Object.assign(ArrayObj, Obj ) - if (OverallKey == "Borrower & Guarantor Details" && Key == "borrower_name" && element.borrower_type == "Main Applicant") { Object.assign(GenInfoObj,{borrower_name : element.borrower_name}) } + if (OverallKey == "Borrower & Guarantor Details" && Key == "borrower_name" && element.borrower_type == "Main Applicant") { Object.assign(GenInfoObj,{name : element.borrower_name}); } } else { Object.assign(ArrayObj,{ [Key] : Value }) - if (OverallKey == "Borrower & Guarantor Details" && Key == "borrower_name" && element.borrower_type == "Main Applicant") { Object.assign(GenInfoObj,{borrower_name : element.borrower_name}) } + if (OverallKey == "Borrower & Guarantor Details" && Key == "borrower_name" && element.borrower_type == "Main Applicant") { Object.assign(GenInfoObj,{name : element.borrower_name}); } } } tempArr.push(ArrayObj) diff --git a/storage/uploads/1673011131265-company-logo.png b/storage/uploads/1673011131265-company-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..dd539c95477226d8422599a90d66e7bff64208eb GIT binary patch literal 1698 zcmV;T23`4yP)n`1{Qdu9c7%wPpSr=vw!g*c?CULOPg*ggDg6rRtW<^*7hkk$7)8Z& z5l%BI!^E}TW*DW>I+$i`XLxPKO(>meTf>NswqZ15Yr|_Z9)rjm9SkEHMBeCP7+v#* zYd?SJWEe!=XltlE{m&aM4M)E;Rn6#m-e_rV{h5DoxK3{LN zHY8-S9hJ@Kao*@)NaFZ#YsQ&BpVZhuUOPmS*iLo*L^C8LSx04u<4xX}FAcUAafsWc zo$7iSOG6Sbre!mxe&mgKwxb5J4XBIidJ$*kXY$&pe&vlyP12T|A&HH=F?=&V-;l(~ zv5?K^L*D4YkmZf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