diff --git a/app/controllers/creditpd.controller.js b/app/controllers/creditpd.controller.js index 9cd30ac..d70ef9a 100644 --- a/app/controllers/creditpd.controller.js +++ b/app/controllers/creditpd.controller.js @@ -18,11 +18,27 @@ exports.PullCreditPdData = async (req, res) => { CreditGeneralInformationDataExist = await CreditGeneralInformation.findOne({ where : { ref_no : req.body.pdid ,product:req.body.product,case_no :req.body.caseno, is_active : 1 }}); if(CreditGeneralInformationDataExist) { - res.send({'status':200, 'message': "data already exist." ,'data': "No data" }); - logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid); - } - else - { + CreditGeneralInformation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}, + 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: CreditFinalRemarks }, {model: CreditLoanDetail }, + {model: CreditGeneralBusinessInformation }, + {model: SupplierDetail } + ] + }); + // res.send({'status':200, 'message': "data already exist." ,'data': "No data" }); + // logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid); + // } + // else + // { 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)); PDID = []; @@ -45,7 +61,7 @@ exports.PullCreditPdData = async (req, res) => { await CreditGeneralInformation.create(obj) .then((successData)=>{logMsg.info("GeneralInformation insert success ,PdId= "+successData.dataValues.pd_id);}) .catch((err)=>{ logMsg.info("GeneralInformation insert failed ,PdId(ref_no)= "+req.body.pdid+ " ERR =" + err); }); - + Object.assign(tempData.data , {last_index : {}}); PDID = await CreditGeneralInformation.findOne({ where : { ref_no : req.body.pdid ,case_no :req.body.caseno, is_active : 1 }}); for (var [OverallKey, OverallValue] of Object.entries(tempData.data)) { @@ -80,7 +96,7 @@ exports.PullCreditPdData = async (req, res) => { } } // DB Insertion - if (OverallKey == "Officer Details") { await CreditGeneralInformation.update(GenInfoObj , { where : { pd_id : PDID.dataValues.pd_id , is_active : 1}}); logMsg.info("CreditGeneralInformation update success ,PdId= "+PDID.dataValues.pd_id); } + if (OverallKey == "last_index") { await CreditGeneralInformation.update(GenInfoObj , { where : { pd_id : PDID.dataValues.pd_id , is_active : 1}}); logMsg.info("CreditGeneralInformation update success ,PdId= "+PDID.dataValues.pd_id); } if (temp_array.length > 0) { temp_array.forEach(async(element) => { @@ -351,9 +367,6 @@ exports.ReInsertImageData = async (req, res) => - - - // exports.GetCreditPdData__1 = async (req, res) => // { // try diff --git a/app/controllers/test.controller.js b/app/controllers/test.controller.js index 7214530..3bde004 100644 --- a/app/controllers/test.controller.js +++ b/app/controllers/test.controller.js @@ -6,6 +6,8 @@ exports.Welcome = (req, res) => { try { + + const Msg = "Welcome....!"; console.log(Msg); logMsg.info("Api Call Success"); diff --git a/app/models/CreditExistingLoanOblogation.js b/app/models/CreditExistingLoanOblogation.js index 829ffe7..96cfd11 100644 --- a/app/models/CreditExistingLoanOblogation.js +++ b/app/models/CreditExistingLoanOblogation.js @@ -8,7 +8,7 @@ module.exports = (sequelize, DataTypes) => { { pd_id: { type: DataTypes.INTEGER }, loan_type: { type: DataTypes.STRING }, - loan_amount: { type: DataTypes.INTEGER }, + loan_amount: { type: DataTypes.STRING }, lender_name: { type: DataTypes.STRING }, loan_taken_by: { type: DataTypes.STRING }, instalment_amount: { type: DataTypes.STRING }, diff --git a/app/routes/routes.js b/app/routes/routes.js index bb606ee..0eac733 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -19,13 +19,14 @@ module.exports = app => { * description: success */ router.get("/demo", Mycontroller.Welcome); - + router.get("/test", Mycontroller.test); router.post("/ReInsertImageData", CreditPdController.ReInsertImageData); + // Pull CreditPd Data /** * @swagger diff --git a/app/services/CreditPdHelper.js b/app/services/CreditPdHelper.js index 02fe6aa..f2f7085 100644 --- a/app/services/CreditPdHelper.js +++ b/app/services/CreditPdHelper.js @@ -102,9 +102,22 @@ async function ARRAY(Array , GenInfoObj , OverallKey) { //RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString(); RoundOfValue = Number((element.numbers_of_years_business_running).toFixed(2).toString()); + console.log(RoundOfValue); Object.assign(ArrayObj,{ numbers_of_years_business_running : RoundOfValue }); } } + + if (OverallKey == "Borrower & Guarantor Details" && Key == "borrower_age" ) + { + + if(typeof element.borrower_age === 'number') + { + //RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString(); + RoundOfAge = Number((element.borrower_age).toFixed(2).toString()); + console.log(RoundOfAge); + Object.assign(ArrayObj,{ borrower_age : RoundOfAge }); + } else if(typeof element.borrower_age === 'string'){ Object.assign(ArrayObj,{ borrower_age : null }); } + } } tempArr.push(ArrayObj) ArrayObj = { };