From ea1ac0e7c24bdbc732175a9fb863d5a1874ad4b2 Mon Sep 17 00:00:00 2001 From: sriramv Date: Thu, 6 Apr 2023 17:08:49 +0530 Subject: [PATCH] fin_info_table_error:GWM --- app/controllers/creditpd.controller.js | 8 +++++--- app/services/CreditPdHelper.js | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/creditpd.controller.js b/app/controllers/creditpd.controller.js index fbce4e9..81e3e67 100644 --- a/app/controllers/creditpd.controller.js +++ b/app/controllers/creditpd.controller.js @@ -40,8 +40,8 @@ exports.PullCreditPdData = async (req, res) => { CreditGeneralBusinessInformation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}}); SupplierDetail.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}}); }).catch(err=>{logMsg.info("GeneralInformation Deletion failed ,PdId(ref_no)= "+req.body.pdid+ " ERR =" + err); }); - // res.send({'status':200, 'message': "data already exist." ,'data': "No data" }); - // logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid); + // res.send({'status':200, 'message': "data already exist." ,'data': "No data" }); + // logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid); // } // else // { @@ -96,10 +96,12 @@ exports.PullCreditPdData = async (req, res) => { } else { + if(ObjectValue == "" && OverallKey == "Financial Information"){ delete OverallValue[ObjectKey]; } + else { Object.assign(obj, { [ObjectKey]: ObjectValue }); if (OverallKey == "Borrower & Guarantor Details" && ObjectKey == "common_remarks") { Object.assign(GenInfoObj,{remarks : ObjectValue}) }; if (OverallKey == "Loan details" && ObjectKey == "loan_amount") { Object.assign(GenInfoObj,{loan_amount : ObjectValue}) }; - if (OverallKey == "Officer Details") { Object.assign(GenInfoObj,{[ObjectKey] : ObjectValue}) }; + if (OverallKey == "Officer Details") { Object.assign(GenInfoObj,{[ObjectKey] : ObjectValue}) };} } } // DB Insertion diff --git a/app/services/CreditPdHelper.js b/app/services/CreditPdHelper.js index 1d31a2b..9207526 100644 --- a/app/services/CreditPdHelper.js +++ b/app/services/CreditPdHelper.js @@ -39,9 +39,11 @@ catch (error) { async function OBJECT(OverAllobject , objectKey , ParticularObj) { try { + const DumpObject = {"address_type" : "address_type" , "pd_locality" : "locality_name", "pd_location" : "description" , "comment_locality" : "rating" , "relationship" : "name" , "company_relation" : "name"} ; return new Promise((resolve, reject) => { + // if(OverAllobject[objectKey] == ""){delete OverAllobject[objectKey];} Objkey = DumpObject[objectKey]; Object.assign(OverAllobject , { [objectKey] : ParticularObj[Objkey]}) resolve(OverAllobject) @@ -86,6 +88,7 @@ async function ARRAY(Array , GenInfoObj , OverallKey) { { Array.forEach(async(element,index,array) => { for (var [Key, Value] of Object.entries(element)) { + // if(Value == ""){delete element[Key];} if (typeof Value === "object" && ( Value !== null )) { Obj = await OBJECT( element, Key , Value ); Object.assign(ArrayObj, Obj )