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 0000000..dd539c9 Binary files /dev/null and b/storage/uploads/1673011131265-company-logo.png differ