gwm
This commit is contained in:
parent
79714c36c3
commit
23ec1c55fd
@ -13,21 +13,36 @@ const { json } = require('body-parser');
|
||||
exports.PullCreditPdData = async (req, res) => {
|
||||
|
||||
try {
|
||||
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
|
||||
{
|
||||
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 = [];
|
||||
obj = {};
|
||||
GenInfoObj = {};
|
||||
temp_array = [];
|
||||
// create creditGeneralInormationData
|
||||
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);
|
||||
Object.assign(obj, { ref_no: tempData.pdid , product : tempData.product , case_no : tempData.caseno , credit_pd_type : req.body.credit_pd_type , completed_date : req.body.completed_date});
|
||||
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); });
|
||||
|
||||
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)) {
|
||||
|
||||
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 ;
|
||||
for (var [ObjectKey, ObjectValue] of Object.entries(OverallValue)) {
|
||||
|
||||
if (Array.isArray(OverallValue[ObjectKey]) == true)
|
||||
{
|
||||
temp_array = await Credit_PdHelper.ARRAY( OverallValue[ObjectKey] , GenInfoObj , OverallKey )
|
||||
@ -35,6 +50,7 @@ exports.PullCreditPdData = async (req, res) => {
|
||||
else if (typeof OverallValue[ObjectKey] === "object" && ( OverallValue[ObjectKey] !== null ))
|
||||
{
|
||||
delete OverallValue[ObjectKey].display_data; delete OverallValue.display_data;
|
||||
console.log(OverallValue);console.log(ObjectKey);console.log(OverallValue[ObjectKey]);
|
||||
obj = await Credit_PdHelper.OBJECT( OverallValue, ObjectKey , OverallValue[ObjectKey] )
|
||||
}
|
||||
else if (moment(OverallValue[ObjectKey], "DD-MM-YYYY", true).isValid() == true || moment(OverallValue[ObjectKey], "DD/MM/YYYY hh:mm:ss A", true).isValid() == true )
|
||||
@ -60,7 +76,10 @@ exports.PullCreditPdData = async (req, res) => {
|
||||
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);
|
||||
await tableName.create(element)
|
||||
.then((successData)=>{logMsg.info(OverallKey+"insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||
.catch((err)=>{ logMsg.info(OverallKey+"insert failed ,PdId = "+PDID.dataValues.pd_id+ " ERR =" + err); });
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -69,10 +88,15 @@ exports.PullCreditPdData = async (req, res) => {
|
||||
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);
|
||||
console.log(obj);
|
||||
await tableName.create(obj)
|
||||
.then((successData)=>{logMsg.info(OverallKey+"insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||
.catch((err)=>{ logMsg.info(OverallKey+"insert failed ,PdId= "+PDID.dataValues.pd_id+ " ERR =" + err); });
|
||||
|
||||
}
|
||||
}
|
||||
res.send({'status':200,'message':"success"});
|
||||
}//end of else condition
|
||||
}
|
||||
catch (err) {
|
||||
res.send({ 'status': 404, message: err.message || "Some error occurred while retrieving data.", 'data': "No data" });
|
||||
|
||||
5331
package-lock.json
generated
5331
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue
Block a user