gwm
This commit is contained in:
parent
567030b99e
commit
c414b9bf69
@ -18,22 +18,28 @@ 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 }});
|
CreditGeneralInformationDataExist = await CreditGeneralInformation.findOne({ where : { ref_no : req.body.pdid ,product:req.body.product,case_no :req.body.caseno, is_active : 1 }});
|
||||||
if(CreditGeneralInformationDataExist)
|
if(CreditGeneralInformationDataExist)
|
||||||
{
|
{
|
||||||
await CreditGeneralInformation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id},
|
|
||||||
include : [
|
CreditGeneralInformation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}
|
||||||
{model: CreditAddressDetail }, {model: CreditFuturePlans },
|
}).then(data=>{
|
||||||
{model : CreditBorrowerAndGuarantorDetails },
|
CreditAddressDetail.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditBusinessAndPersonalBankingDetails }, {model: BusinessAsset },
|
CreditFuturePlans.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditFinancialInformation }, {model: CreditKeyShareholder },
|
CreditBorrowerAndGuarantorDetails.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditKeyProductBusinessContribution }, {model: EmployeeStrength },
|
CreditBusinessAndPersonalBankingDetails.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: ClientDetail }, {model: StockDetail },
|
BusinessAsset.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditExistingLoanObligation },
|
CreditFinancialInformation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: FamilyMemberInvolvedInBusiness },
|
CreditKeyShareholder.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model : CreditManager },
|
CreditKeyProductBusinessContribution.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditFinalRemarks }, {model: CreditLoanDetail },
|
EmployeeStrength.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: CreditGeneralBusinessInformation },
|
ClientDetail.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
{model: SupplierDetail }
|
StockDetail.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
]
|
CreditExistingLoanObligation.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
});
|
FamilyMemberInvolvedInBusiness.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
|
CreditManager.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
|
CreditFinalRemarks.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
|
CreditLoanDetail.destroy({ where : { pd_id : CreditGeneralInformationDataExist.dataValues.pd_id}});
|
||||||
|
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" });
|
// res.send({'status':200, 'message': "data already exist." ,'data': "No data" });
|
||||||
// logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid);
|
// logMsg.info("CreditGeneralInformation data already exist.,PdId(ref_no)= "+req.body.pdid);
|
||||||
// }
|
// }
|
||||||
@ -61,13 +67,14 @@ exports.PullCreditPdData = async (req, res) => {
|
|||||||
await CreditGeneralInformation.create(obj)
|
await CreditGeneralInformation.create(obj)
|
||||||
.then((successData)=>{logMsg.info("GeneralInformation insert success ,PdId= "+successData.dataValues.pd_id);})
|
.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); });
|
.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 }});
|
PDID = await CreditGeneralInformation.findOne({ where : { ref_no : req.body.pdid ,case_no :req.body.caseno, is_active : 1 }});
|
||||||
|
length = [];
|
||||||
for (var [OverallKey, OverallValue] of Object.entries(tempData.data)) {
|
for (var [OverallKey, OverallValue] of Object.entries(tempData.data)) {
|
||||||
|
length.push(OverallKey);
|
||||||
if(OverallKey != "Officer Details")
|
if(OverallKey != "Officer Details" || OverallKey != "last_index"){
|
||||||
table_name = await CreditFilterTable.findAll({ raw: true, attributes: [ 'table_name'], where : { section : OverallKey , is_active : 1 } , group: ['table_name']})
|
table_name = await CreditFilterTable.findAll({ raw: true, attributes: [ 'table_name'], where : { section : OverallKey , is_active : 1 } , group: ['table_name']});
|
||||||
|
}
|
||||||
obj = { };
|
obj = { };
|
||||||
temp_array.length = 0 ;
|
temp_array.length = 0 ;
|
||||||
for (var [ObjectKey, ObjectValue] of Object.entries(OverallValue)) {
|
for (var [ObjectKey, ObjectValue] of Object.entries(OverallValue)) {
|
||||||
@ -96,7 +103,8 @@ exports.PullCreditPdData = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// DB Insertion
|
// DB Insertion
|
||||||
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 (Object.entries(tempData.data).length == length.length) { 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)
|
if (temp_array.length > 0)
|
||||||
{
|
{
|
||||||
temp_array.forEach(async(element) => {
|
temp_array.forEach(async(element) => {
|
||||||
@ -112,6 +120,7 @@ exports.PullCreditPdData = async (req, res) => {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(OverallKey != "Officer Details") {
|
||||||
Object.assign(obj , {pd_id : PDID.dataValues.pd_id} );
|
Object.assign(obj , {pd_id : PDID.dataValues.pd_id} );
|
||||||
var index = table_name[0].table_name;
|
var index = table_name[0].table_name;
|
||||||
var tableName = arr[index];
|
var tableName = arr[index];
|
||||||
@ -119,9 +128,11 @@ exports.PullCreditPdData = async (req, res) => {
|
|||||||
await tableName.create(obj)
|
await tableName.create(obj)
|
||||||
.then((successData)=>{logMsg.info(tableName+" insert success ,PdId= "+successData.dataValues.pd_id);})
|
.then((successData)=>{logMsg.info(tableName+" insert success ,PdId= "+successData.dataValues.pd_id);})
|
||||||
.catch((err)=>{ logMsg.info(tableName+" insert failed ,PdId= "+PDID.dataValues.pd_id+ " ERR =" + err); });
|
.catch((err)=>{ logMsg.info(tableName+" insert failed ,PdId= "+PDID.dataValues.pd_id+ " ERR =" + err); });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send({'status':200,'message':"success"});
|
res.send({'status':200,'message':"success"});
|
||||||
}//end of else condition
|
}//end of else condition
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ module.exports = app => {
|
|||||||
* description: success
|
* description: success
|
||||||
*/
|
*/
|
||||||
router.get("/demo", Mycontroller.Welcome);
|
router.get("/demo", Mycontroller.Welcome);
|
||||||
router.get("/test", Mycontroller.test);
|
|
||||||
|
|
||||||
|
|
||||||
router.post("/ReInsertImageData", CreditPdController.ReInsertImageData);
|
router.post("/ReInsertImageData", CreditPdController.ReInsertImageData);
|
||||||
|
|||||||
@ -102,7 +102,6 @@ async function ARRAY(Array , GenInfoObj , OverallKey) {
|
|||||||
|
|
||||||
//RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString();
|
//RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString();
|
||||||
RoundOfValue = Number((element.numbers_of_years_business_running).toFixed(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 });
|
Object.assign(ArrayObj,{ numbers_of_years_business_running : RoundOfValue });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +113,6 @@ async function ARRAY(Array , GenInfoObj , OverallKey) {
|
|||||||
{
|
{
|
||||||
//RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString();
|
//RoundOfValue = Math.round(element.numbers_of_years_business_running,2).toString();
|
||||||
RoundOfAge = Number((element.borrower_age).toFixed(2).toString());
|
RoundOfAge = Number((element.borrower_age).toFixed(2).toString());
|
||||||
console.log(RoundOfAge);
|
|
||||||
Object.assign(ArrayObj,{ borrower_age : RoundOfAge });
|
Object.assign(ArrayObj,{ borrower_age : RoundOfAge });
|
||||||
} else if(typeof element.borrower_age === 'string'){ Object.assign(ArrayObj,{ borrower_age : null }); }
|
} else if(typeof element.borrower_age === 'string'){ Object.assign(ArrayObj,{ borrower_age : null }); }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user