activecloseLoans:GWM
This commit is contained in:
parent
a1f25a2af0
commit
da155b4d1b
@ -1,10 +1,7 @@
|
||||
const { sequelize,OutputActiveAndClosedLoans,OutSanctionAmt_P,OutSanctionAmt_C,OutEnquiryAmountP,OutEnquiryAmountC,
|
||||
InBorrowerDetail,ConBorrowDetail,ConIDDetail,BorrowerProfile,BorrowidDetail
|
||||
,InEnquiryDetail,ConEnquiryDetail,EnquiryDetail
|
||||
,InCreditFacility,CreditFacilityCurrentDetail,ConAccountTranscation
|
||||
,InDpdTranscationTable,AcHistoryAndDPD,ConDPDTranscation} = require('../models')
|
||||
const { sequelize,OutputActiveAndClosedLoans,OutSanctionAmt_P,OutSanctionAmt_C,OutEnquiryAmountP,OutEnquiryAmountC,InBorrowerDetail,ConBorrowDetail,ConIDDetail,BorrowerProfile,BorrowidDetail,InEnquiryDetail,ConEnquiryDetail,EnquiryDetail,InCreditFacility,CreditFacilityCurrentDetail,ConAccountTranscation,InDpdTranscationTable,AcHistoryAndDPD,ConDPDTranscation} = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
const Helper = require('../services/cibil.controller.helper.js');
|
||||
const DataInsertHelper = require('../services/cibil.datainsert.helper.js');
|
||||
const { Op } = require('sequelize');
|
||||
|
||||
|
||||
@ -35,9 +32,12 @@ exports.ActiveAndClosedLoansDetailsList =async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
LoanData = await OutputActiveAndClosedLoans.findAll({raw : true , where:{losid:req.query.losid , ref_no :req.query.ref_no}});
|
||||
if(LoanData.length != 0)
|
||||
ActiveLoanData = await OutputActiveAndClosedLoans.findAll({raw : true , where:{losid:req.query.losid , ref_no :req.query.ref_no , DateClosed:null }});
|
||||
ClosedLoanData = await OutputActiveAndClosedLoans.findAll({raw : true , where:{losid:req.query.losid , ref_no :req.query.ref_no , DateClosed:{ [Op.ne]: null} }});
|
||||
if(ActiveLoanData.length != 0 || ClosedLoanData.length != 0)
|
||||
{
|
||||
|
||||
LoanData = {ActiveLoanData:ActiveLoanData , ClosedLoanData:ClosedLoanData }
|
||||
res.send({'status':200 , message:"Success." ,'data': LoanData});
|
||||
}
|
||||
else{
|
||||
@ -149,7 +149,7 @@ exports.SummaryViewOfCreditFacilities =async (req, res) =>
|
||||
try
|
||||
{
|
||||
|
||||
sequelize.query("select count(*) as total_accounts_count,count(case when overdue_amount > 0 then 1 else null end) as overdue_amount_count,count(case when current_balance = 0 then 1 else null end) as zero_balance_count,count(case when overdue_amount <= 0 then 1 else null end) as nill_overdue_amount_count,MAX(sanctioned_amount) as high_credit,SUM(current_balance) as sum_current_balance ,SUM(overdue_amount) as sum_overdue_amount ,MAX(opened_date) as latest_opened_date ,MIN(opened_date) as oldest_opened_date from out_active_and_closed_loans_details where losid = '"+req.query.losid+"' and is_active = 1 and ref_no = '"+req.query.ref_no+"'").then(async(data) => {
|
||||
sequelize.query("select count(*) as total_accounts_count,count(case when overdue_amount > 0 then 1 else null end) as overdue_amount_count,count(case when current_balance = 0 then 1 else null end) as zero_balance_count,count(case when overdue_amount <= 0 then 1 else null end) as nill_overdue_amount_count,SUM(sanctioned_amount) as high_credit,SUM(current_balance) as sum_current_balance ,SUM(overdue_amount) as sum_overdue_amount ,MAX(opened_date) as latest_opened_date ,MIN(opened_date) as oldest_opened_date from out_active_and_closed_loans_details where losid = '"+req.query.losid+"' and is_active = 1 and ref_no = '"+req.query.ref_no+"'").then(async(data) => {
|
||||
|
||||
res.send({'status':200 , message:"Success." ,'data':data});
|
||||
|
||||
@ -289,7 +289,7 @@ exports.ConsolidatedSummaryViewOfCreditFacilities =async (req, res) =>
|
||||
try
|
||||
{
|
||||
|
||||
sequelize.query("select count(*) as total_accounts_count,count(case when overdue_amount > 0 then 1 else null end) as overdue_amount_count,count(case when current_balance = 0 then 1 else null end) as zero_balance_count,count(case when overdue_amount <= 0 then 1 else null end) as nill_overdue_amount_count,MAX(sanctioned_amount) as high_credit,SUM(current_balance) as sum_current_balance ,SUM(overdue_amount) as sum_overdue_amount ,MAX(opened_date) as latest_opened_date ,MIN(opened_date) as oldest_opened_date from out_active_and_closed_loans_details where losid = '"+req.query.losid+"' and is_active = 1 " ).then(async(data) => {
|
||||
sequelize.query("select count(*) as total_accounts_count,count(case when overdue_amount > 0 then 1 else null end) as overdue_amount_count,count(case when current_balance = 0 then 1 else null end) as zero_balance_count,count(case when overdue_amount <= 0 then 1 else null end) as nill_overdue_amount_count,SUM(sanctioned_amount) as high_credit,SUM(current_balance) as sum_current_balance ,SUM(overdue_amount) as sum_overdue_amount ,MAX(opened_date) as latest_opened_date ,MIN(opened_date) as oldest_opened_date from out_active_and_closed_loans_details where losid = '"+req.query.losid+"' and is_active = 1 " ).then(async(data) => {
|
||||
|
||||
res.send({'status':200 , message:"Success." ,'data':data});
|
||||
|
||||
@ -526,16 +526,7 @@ exports.ConsolidatedSanctionAmountSplitUp =async (req, res) =>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.test =async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// end_date = '2022-05-05'
|
||||
// end_date = '2022-05-05'
|
||||
// sk = await Helper.createSkeleton(end_date);
|
||||
// res.send({sk})
|
||||
// dpd_dates = ['2019-10-01','2019-09-20','2019-08-20','2019-07-20','2019-06-20','2019-05-20','2019-04-20','2019-03-20'];
|
||||
@ -544,290 +535,59 @@ exports.test =async (req, res) =>
|
||||
// console.log(data);
|
||||
// });
|
||||
|
||||
srt = "Credit Facility 1";
|
||||
num = srt.replace ( /[^\d.]/g, '' );
|
||||
console.log(num);
|
||||
|
||||
|
||||
|
||||
exports.test = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// data = await Helper.cibilInputDataApiCall('MW55904793','AORPK5766N',2);
|
||||
// DataInsertHelper.consumerDataInsert(data);
|
||||
// res.send(data);
|
||||
|
||||
PanList = await Helper.panListApiCall('MW112233');
|
||||
|
||||
res.send({'status':200 , message:"Success." ,'data':PanList});
|
||||
// query = " test_group_loans @los_id = 'MW112233', @ref_no = '202201121115264000000' ";
|
||||
// sequelize.query(query).then(async(data) => {
|
||||
|
||||
// res.send({'status':200 , message:"Success." ,'data':data});
|
||||
// }).catch(err=>{ res.send({'status':400 , message: "Failed" ,'data': "Nodata"}); })
|
||||
|
||||
} catch(err) {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||
}); } //end of try catch
|
||||
});
|
||||
} //end of try catch
|
||||
|
||||
};
|
||||
|
||||
exports.testone =async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
data = await Helper.cibilInputDataApiCall('MW00045413','AAACR4282J',2);
|
||||
|
||||
DataInsertHelper.commercialDataInsert(data);
|
||||
res.send(data);
|
||||
} catch(err) {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||
});
|
||||
} //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.test2 =async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// BorrowerProfileData = await BorrowerProfile.findAll({attributes: ['losid','ApplicationRefno','EnqInfoBorrowerName','EnqInfoPan'],raw:true ,where:{losid:'MW112233'}});
|
||||
// BorrowerProfileArray = [];
|
||||
// BorrowerProfileData.forEach(value => {
|
||||
// BorrowerProfileDataObj = {
|
||||
// losid : value.losid,
|
||||
// ReferenceNumber : value.ApplicationRefno,
|
||||
// ConsumerNameField1 : value.EnqInfoBorrowerName,
|
||||
// ConsumerNameField2 : null,
|
||||
// ConsumerNameField3 : null,
|
||||
// ConsumerNameField4 : null,
|
||||
// ConsumerNameField5 : null,
|
||||
// PAN : value.EnqInfoPan,
|
||||
// cibil_type : 1
|
||||
// }
|
||||
// BorrowerProfileArray.push(BorrowerProfileDataObj);
|
||||
// });
|
||||
// await InBorrowerDetail.bulkCreate(BorrowerProfileArray);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ConBorrowDetailData = await ConBorrowDetail.findAll({attributes: ['losid','MemberReferenceNumber','ConsumerNameField1','ConsumerNameField2','ConsumerNameField3','ConsumerNameField4','ConsumerNameField5'],raw:true ,where:{losid:'MW112233'},include:[{model:ConIDDetail , attributes: ['IDNumber'],where:{IDType:'Income Tax ID Number'}}]});
|
||||
// ConBorrowDetailArray = [];
|
||||
// ConBorrowDetailData.forEach(value => {
|
||||
// ConBorrowDetailDataObj = {
|
||||
// losid : value.losid,
|
||||
// ReferenceNumber : value.MemberReferenceNumber,
|
||||
// ConsumerNameField1 : value.ConsumerNameField1,
|
||||
// ConsumerNameField2 : value.ConsumerNameField2,
|
||||
// ConsumerNameField3 : value.ConsumerNameField3,
|
||||
// ConsumerNameField4 : value.ConsumerNameField4,
|
||||
// ConsumerNameField5 : value.ConsumerNameField5,
|
||||
// PAN : value['ConIDDetails.IDNumber'],
|
||||
// cibil_type : 2
|
||||
// }
|
||||
|
||||
// ConBorrowDetailArray.push(ConBorrowDetailDataObj);
|
||||
// });
|
||||
// await InBorrowerDetail.bulkCreate(ConBorrowDetailArray);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// end_date = '2022-05-05'
|
||||
// sk = await Helper.createSkeleton(end_date);
|
||||
// ComEnquiryDetailData = await EnquiryDetail.findAll({attributes: ['losid','ApplicationRefno','EnquiryDetailsEnquiryDt','EnquiryDetailsEnquiryPurpose','EnquiryDetailsEnquiryAmt'],raw:true ,where:{losid:'MW112233'}});
|
||||
// ComEnquiryDetailArray = [];
|
||||
// ComEnquiryDetailData.forEach(async(value) => {
|
||||
// month_bucket_result = await Helper.findBucketCount(sk,value.EnquiryDetailsEnquiryDt);
|
||||
// ComEnquiryDetailDataObj = {
|
||||
// losid : value.losid,
|
||||
// ReferenceNumber : value.ApplicationRefno,
|
||||
// DateOfEnquiry : value.EnquiryDetailsEnquiryDt,
|
||||
// EnquiryPurpose : value.EnquiryDetailsEnquiryPurpose,
|
||||
// EnquiryAmount : value.EnquiryDetailsEnquiryAmt,
|
||||
// month_bucket_index : month_bucket_result,
|
||||
// cibil_type : 1
|
||||
// }
|
||||
// ComEnquiryDetailArray.push(ComEnquiryDetailDataObj);
|
||||
// });
|
||||
// setTimeout(async() => {
|
||||
|
||||
// await InEnquiryDetail.bulkCreate(ComEnquiryDetailArray).catch(err=>{res.send({data:err})});
|
||||
// res.send({data:ComEnquiryDetailArray})
|
||||
// }, 3000);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// end_date = '2022-05-05'
|
||||
// sk = await Helper.createSkeleton(end_date);
|
||||
// ConEnquiryDetailData = await ConEnquiryDetail.findAll({attributes: ['losid','MemberReferenceNumber','DateOfEnquiry','EnquiryPurpose','EnquiryAmount'],raw:true ,where:{losid:'MW112233'}});
|
||||
// ConEnquiryDetailArray = [];
|
||||
// ConEnquiryDetailData.forEach(async(value) => {
|
||||
// month_bucket_result = await Helper.findBucketCount(sk,value.DateOfEnquiry);
|
||||
// ConEnquiryDetailDataObj = {
|
||||
// losid : value.losid,
|
||||
// ReferenceNumber : value.MemberReferenceNumber,
|
||||
// DateOfEnquiry : value.DateOfEnquiry,
|
||||
// EnquiryPurpose : value.EnquiryPurpose,
|
||||
// EnquiryAmount : value.EnquiryAmount,
|
||||
// month_bucket_index : month_bucket_result,
|
||||
// cibil_type : 2
|
||||
// }
|
||||
// ConEnquiryDetailArray.push(ConEnquiryDetailDataObj);
|
||||
// });
|
||||
// setTimeout(async() => {
|
||||
|
||||
// await InEnquiryDetail.bulkCreate(ConEnquiryDetailArray).catch(err=>{res.send({data:err})});
|
||||
// res.send({data:ConEnquiryDetailArray})
|
||||
// }, 3000);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// end_date = '2022-05-05'
|
||||
// sk = await Helper.createSkeleton(end_date);
|
||||
// ComCreditFacilityCurrentDetailData = await CreditFacilityCurrentDetail.findAll({attributes: ['losid','ApplicationRefno','CreditFacilityCDcfSrNo','CreditFacilityCDcfType','CreditFacilityCDDatesSanctionedDt','CreditFacilityCDLstReportedDate','CreditFacilityCDAmtSanctionedAmt','CreditFacilityCDAmtoutstandingBalance','CreditFacilityCDAmtOverdue','CreditFacilityCDODTenure','CreditFacilityCDAmtinstallmentAmt','CreditFacilityCDStatus'],raw:true ,where:{losid:'MW112233'}});
|
||||
|
||||
// ComCreditFacilityCurrentDetailData.forEach(async(value) => {
|
||||
// month_bucket_result = await Helper.findBucketCount(sk,value.DateOpenedDisbursed);
|
||||
// Num = value.ApplicationRefno;
|
||||
// Refno = Num.toString();
|
||||
// AccountTranDetailsID = value.CreditFacilityCDcfSrNo.replace ( /[^\d.]/g, '' );
|
||||
// ComCreditFacilityCurrentDetailObj = {
|
||||
// losid : value.losid,
|
||||
// InTblAccountTranDetailsID : AccountTranDetailsID,
|
||||
// ReferenceNumber : Refno,
|
||||
// AccountType : value.CreditFacilityCDcfType,
|
||||
// OwnershipIndicator : null,
|
||||
// DateOpenedDisbursed:value.CreditFacilityCDDatesSanctionedDt ,
|
||||
// DateReportedAndCertified :value.CreditFacilityCDLstReportedDate ,
|
||||
// HighCreditSanctionedAmount : value.CreditFacilityCDAmtSanctionedAmt,
|
||||
// CurrentBalance : value.CreditFacilityCDAmtoutstandingBalance,
|
||||
// AmountOverdue : value.CreditFacilityCDAmtOverdue,
|
||||
// CreditLimit : null,
|
||||
// RepaymentTenure : value.CreditFacilityCDODTenure,
|
||||
// EMIAmount : value.CreditFacilityCDAmtinstallmentAmt,
|
||||
// month_bucket_index : month_bucket_result,
|
||||
// cibil_type : 1,
|
||||
// WrittenOffAndSettledStatus : value.CreditFacilityCDStatus
|
||||
// }
|
||||
|
||||
// await InCreditFacility.create(ComCreditFacilityCurrentDetailObj).then(async(ComInCreditFacilityData)=>{
|
||||
|
||||
// ComAcHistoryAndDPD = await AcHistoryAndDPD.findAll({attributes: ['ApplicationRefno','CFHistory24Monthsmonth','CFHistory24MonthsACorDPD','BorrowerCurrentDetailsID'],raw:true ,
|
||||
// where:{BorrowerCurrentDetailsID : ComInCreditFacilityData.dataValues.InTblAccountTranDetailsID ,ApplicationRefno:ComInCreditFacilityData.dataValues.ReferenceNumber}});
|
||||
|
||||
// if(ComAcHistoryAndDPD.length != 0)
|
||||
// {
|
||||
// var DpdDataInsert = new Promise(async(resolve, reject) => {
|
||||
// ComAcHistoryAndDPDArray = [];
|
||||
// ComAcHistoryAndDPD.forEach(async(value,index,array) => {
|
||||
// month_bucket_result_com_dpd = await Helper.findBucketCount(sk,value.CFHistory24Monthsmonth);
|
||||
// ComAcHistoryAndDPDObj = {
|
||||
// AccountTranDetailsID : ComInCreditFacilityData.dataValues.AccountTranDetailsID,
|
||||
// ReferenceNumber : value.ApplicationRefno,
|
||||
// cibil_type : 1,
|
||||
// StartDate : value.CFHistory24Monthsmonth,
|
||||
// Code : value.CFHistory24MonthsACorDPD,
|
||||
// month_bucket_index : month_bucket_result_com_dpd,
|
||||
// }
|
||||
// ComAcHistoryAndDPDArray.push(ComAcHistoryAndDPDObj);
|
||||
|
||||
// if (index === array.length -1) { resolve(ComAcHistoryAndDPDArray); }
|
||||
// });
|
||||
// });
|
||||
|
||||
// DpdDataInsert.then(async(ComAcHistoryAndDPDArray)=>{
|
||||
// await InDpdTranscationTable.bulkCreate(ComAcHistoryAndDPDArray).catch(err=>{res.send({data:err})});
|
||||
// });
|
||||
|
||||
// }
|
||||
// }).catch(err=>{res.send({data:err})});
|
||||
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// end_date = '2022-05-05'
|
||||
// sk = await Helper.createSkeleton(end_date);
|
||||
// ConAccountTranscationData = await ConAccountTranscation.findAll({attributes: ['losid','AccountTranDetailsID','MemberReferenceNumber','AccountType','OwnershipIndicator','DateOpenedDisbursed','DateReportedAndCertified','HighCreditSanctionedAmount','CurrentBalance','AmountOverdue','CreditLimit','RepaymentTenure','EMIAmount','WrittenOffAndSettledStatus'],raw:true ,where:{losid:'MW112233'}});
|
||||
|
||||
|
||||
// ConAccountTranscationData.forEach(async(value) => {
|
||||
// month_bucket_result = await Helper.findBucketCount(sk,value.DateOpenedDisbursed);
|
||||
// Num = value.MemberReferenceNumber;
|
||||
// MemberReferenceNumber = Num.toString();
|
||||
// ConAccountTranscationObj = {
|
||||
// losid : value.losid,
|
||||
// InTblAccountTranDetailsID : value.AccountTranDetailsID,
|
||||
// ReferenceNumber : MemberReferenceNumber,
|
||||
// AccountType : value.AccountType,
|
||||
// OwnershipIndicator : value.OwnershipIndicator,
|
||||
// DateOpenedDisbursed:value.DateOpenedDisbursed ,
|
||||
// DateReportedAndCertified :value.DateReportedAndCertified ,
|
||||
// HighCreditSanctionedAmount : value.HighCreditSanctionedAmount,
|
||||
// CurrentBalance : value.CurrentBalance,
|
||||
// AmountOverdue : value.AmountOverdue,
|
||||
// CreditLimit : value.CreditLimit,
|
||||
// RepaymentTenure : value.RepaymentTenure,
|
||||
// EMIAmount : value.EMIAmount,
|
||||
// month_bucket_index : month_bucket_result,
|
||||
// cibil_type : 2,
|
||||
// WrittenOffAndSettledStatus : value.WrittenOffAndSettledStatus
|
||||
// }
|
||||
|
||||
// await InCreditFacility.create(ConAccountTranscationObj).then(async(InCreditFacilityData)=>{
|
||||
|
||||
// RefNo = InCreditFacilityData.dataValues.ReferenceNumber;
|
||||
// ConDPDTranscationData = await ConDPDTranscation.findAll({attributes: ['AccountTranDetailsID','MemberRefNo','StartDate','Code'],raw:true ,
|
||||
// where:{MemberRefNo: RefNo,AccountTranDetailsID: InCreditFacilityData.dataValues.InTblAccountTranDetailsID}});
|
||||
// if(ConDPDTranscationData.length != 0)
|
||||
// {
|
||||
// var DataInsert = new Promise(async(resolve, reject) => {
|
||||
// ConDPDTranscationDataArray = [];
|
||||
// ConDPDTranscationData.forEach(async(value,index,array) => {
|
||||
|
||||
// month_bucket_result_dpd = await Helper.findBucketCount(sk,value.StartDate);
|
||||
// ConDPDTranscationDataObj = {
|
||||
// AccountTranDetailsID : InCreditFacilityData.dataValues.AccountTranDetailsID,
|
||||
// ReferenceNumber : value.MemberRefNo,
|
||||
// cibil_type : 2,
|
||||
// StartDate : value.StartDate,
|
||||
// Code : value.Code,
|
||||
// month_bucket_index : month_bucket_result_dpd,
|
||||
// }
|
||||
// ConDPDTranscationDataArray.push(ConDPDTranscationDataObj);
|
||||
// //resolve
|
||||
// if (index === array.length -1) { resolve(ConDPDTranscationDataArray); }
|
||||
// });
|
||||
// });
|
||||
// DataInsert.then(async(ConDPDTranscationDataArray)=>{
|
||||
|
||||
// // insert consumer DPd data here
|
||||
// await InDpdTranscationTable.bulkCreate(ConDPDTranscationDataArray).catch(err=>{res.send({data:err})});
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
// }).catch(err=>{res.send({data:err})});
|
||||
|
||||
// });//end of consumer credit facility data foreach loop
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -843,3 +603,95 @@ exports.test2 =async (req, res) =>
|
||||
|
||||
|
||||
|
||||
exports.starter = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
PanList = await Helper.panListApiCall(req.query.losid);
|
||||
if(PanList.length != 0)
|
||||
{
|
||||
var CibilDataInsert = new Promise(async(resolve, reject) => {
|
||||
PanList.forEach(async(PanListValue,PanListIndex,PanListArray) => {
|
||||
|
||||
//define cibil type based on entity type
|
||||
if(PanListValue.entity_type == "Individual"){ CibilType = 1; }else{CibilType = 2;}
|
||||
Object.assign(PanListValue, {cibil_type:CibilType})
|
||||
|
||||
BorrowerDetailData = await InBorrowerDetail.findOne({where:{losid:PanListValue.losid , PAN:PanListValue.PAN ,cibil_type:CibilType}});
|
||||
if(BorrowerDetailData)
|
||||
{
|
||||
//skip data insertion for this case
|
||||
//resolve here
|
||||
if (PanListIndex === PanListArray.length -1) { resolve(req.query.losid); }
|
||||
}
|
||||
else
|
||||
{
|
||||
//create Intermediate table borrower details (only losid,pan,cibil_type,entity_type)
|
||||
await InBorrowerDetail.create(PanListValue).then(async(PanListData)=>{
|
||||
//call cibil data api and insert cibil data in to input tables
|
||||
if(PanListData.cibil_type == 1)
|
||||
{
|
||||
//cibil data api call
|
||||
CibilData = await Helper.cibilInputDataApiCall(PanListData.losid,PanListData.PAN,PanListData.cibil_type);
|
||||
//insert cibil data in to input tables
|
||||
DataInsertHelper.consumerDataInsert(CibilData);
|
||||
//move cibil data from input table to intermediate table
|
||||
DataInsertHelper.consumerIntermediateDataInsert();
|
||||
|
||||
|
||||
//cibil output data generating python script api call
|
||||
Helper.cibilOutputGenerateApiCall(losid,ref_no,cibil_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
//cibil data api call
|
||||
CibilData = await Helper.cibilInputDataApiCall(PanListData.losid,PanListData.PAN,PanListData.cibil_type);
|
||||
//insert cibil data in to input tables
|
||||
DataInsertHelper.commercialDataInsert(CibilData);
|
||||
//move cibil data from input table to intermediate table
|
||||
DataInsertHelper.commercialIntermediateDataInsert();
|
||||
|
||||
|
||||
//cibil output data generating python script api call
|
||||
Helper.cibilOutputGenerateApiCall(losid,ref_no,cibil_type);
|
||||
}
|
||||
|
||||
}).catch(err=>{ });
|
||||
|
||||
//resolve here
|
||||
if (PanListIndex === PanListArray.length -1) { resolve(req.query.losid); }
|
||||
}
|
||||
|
||||
});//end of pan list foreach
|
||||
|
||||
});//end of promises
|
||||
|
||||
CibilDataInsert.then(async(losid)=>{
|
||||
//joint loan unique key update procedure call
|
||||
|
||||
BorrowerDetailData = await InBorrowerDetail.findAll({where:{losid:losid}});
|
||||
res.send({'status':200 , message:"Success." ,'data':BorrowerDetailData});
|
||||
|
||||
});
|
||||
}
|
||||
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"
|
||||
});
|
||||
} //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
BorrowerProfileBIDPan: { type: DataTypes.STRING },
|
||||
BorrowerProfileBIDCin: { type: DataTypes.STRING },
|
||||
BorrowerProfileBIDTin: { type: DataTypes.STRING },
|
||||
BorrowerProfileBIDRegistrationNo: { type: DataTypes.STRING },
|
||||
BorrowerProfileBIDRegistrationNo: { type: DataTypes.STRING },
|
||||
BorrowerProfileBIDServiceTaxNo: { type: DataTypes.STRING },
|
||||
BorrowerProfileLastReportedDate: { type: DataTypes.DATE },
|
||||
temp_id: { type: DataTypes.INTEGER }
|
||||
|
||||
@ -12,6 +12,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
MemberReferenceNumber: { type: DataTypes.INTEGER },
|
||||
DateOfEnquiry: { type: DataTypes.DATE },
|
||||
EnquiringMemberShortName: { type: DataTypes.STRING },
|
||||
ExpirationDate: { type: DataTypes.DATE },
|
||||
EnquiryPurpose: { type: DataTypes.STRING },
|
||||
EnquiryAmount: { type: DataTypes.INTEGER }
|
||||
},
|
||||
|
||||
@ -7,12 +7,13 @@ module.exports = (sequelize, DataTypes) => {
|
||||
ConPhoneDetail.init(
|
||||
|
||||
{
|
||||
phone_detail_id: { type: DataTypes.INTEGER },
|
||||
member_ref_no: { type: DataTypes.STRING }, //
|
||||
telephone_number: { type: DataTypes.INTEGER },
|
||||
telephone_extention: { type: DataTypes.INTEGER },
|
||||
telephone_type: { type: DataTypes.STRING },
|
||||
enrich_through_enquiry: { type: DataTypes.STRING }
|
||||
|
||||
PhoneDetailsID: { type: DataTypes.INTEGER },
|
||||
MemberReferenceNumber: { type: DataTypes.STRING }, //
|
||||
TelephoneNumber: { type: DataTypes.INTEGER },
|
||||
TelephoneExtension: { type: DataTypes.INTEGER },
|
||||
TelephoneType: { type: DataTypes.STRING },
|
||||
EnrichedThroughEnquiry: { type: DataTypes.STRING }
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@ -7,29 +7,29 @@ module.exports = (sequelize, DataTypes) => {
|
||||
ConScoreDetail.init(
|
||||
|
||||
{
|
||||
score_detail_id: { type: DataTypes.INTEGER },
|
||||
member_ref_no: { type: DataTypes.STRING }, //
|
||||
score_name: { type: DataTypes.STRING },
|
||||
score_card_name: { type: DataTypes.STRING },
|
||||
score_card_version: { type: DataTypes.INTEGER },
|
||||
score_date: { type: DataTypes.DATE },
|
||||
score: { type: DataTypes.INTEGER },
|
||||
exclution_code_1: { type: DataTypes.DATE },//
|
||||
exclution_code_2: { type: DataTypes.DATE }, //
|
||||
exclution_code_3: { type: DataTypes.DATE },//
|
||||
exclution_code_4: { type: DataTypes.DATE },//
|
||||
exclution_code_5: { type: DataTypes.DATE },//
|
||||
exclution_code_6: { type: DataTypes.DATE },//
|
||||
exclution_code_7: { type: DataTypes.DATE },//
|
||||
exclution_code_8: { type: DataTypes.DATE },//
|
||||
exclution_code_9: { type: DataTypes.DATE },//
|
||||
exclution_code_10: { type: DataTypes.DATE },//
|
||||
reason_code_1: { type: DataTypes.STRING },
|
||||
reason_code_2: { type: DataTypes.STRING },
|
||||
reason_code_3: { type: DataTypes.STRING },
|
||||
reason_code_4: { type: DataTypes.STRING },
|
||||
reason_code_5: { type: DataTypes.STRING },
|
||||
error_code: { type: DataTypes.STRING } //
|
||||
ScoreDetailsID: { type: DataTypes.INTEGER },
|
||||
MemberReferenceNumber: { type: DataTypes.INTEGER },
|
||||
ScoreName: { type: DataTypes.STRING },
|
||||
ScoreCardName: { type: DataTypes.STRING },
|
||||
ScoreCardVersion: { type: DataTypes.INTEGER },
|
||||
ScoreDate: { type: DataTypes.DATE },
|
||||
Score: { type: DataTypes.INTEGER },
|
||||
ExclusionCode1: { type: DataTypes.STRING },
|
||||
ExclusionCode2: { type: DataTypes.STRING },
|
||||
ExclusionCode3: { type: DataTypes.STRING },
|
||||
ExclusionCode4: { type: DataTypes.STRING },
|
||||
ExclusionCode5: { type: DataTypes.STRING },
|
||||
ExclusionCode6: { type: DataTypes.STRING },
|
||||
ExclusionCode7: { type: DataTypes.STRING },
|
||||
ExclusionCode8: { type: DataTypes.STRING },
|
||||
ExclusionCode9: { type: DataTypes.STRING },
|
||||
ExclusionCode10: { type: DataTypes.STRING },
|
||||
ReasonCode1: { type: DataTypes.STRING },
|
||||
ReasonCode2: { type: DataTypes.STRING },
|
||||
ReasonCode3: { type: DataTypes.STRING },
|
||||
ReasonCode4: { type: DataTypes.STRING },
|
||||
ReasonCode5: { type: DataTypes.STRING },
|
||||
ErrorCode: { type: DataTypes.STRING }
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -16,7 +16,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||
ConsumerNameField5 : { type: DataTypes.STRING },
|
||||
PAN : { type: DataTypes.STRING },
|
||||
cibil_type : { type: DataTypes.INTEGER },
|
||||
|
||||
cibil_data_status :{ type: DataTypes.INTEGER },
|
||||
entity_type : { type: DataTypes.STRING }
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@ -27,8 +27,9 @@ module.exports = (sequelize, DataTypes) => {
|
||||
CreditLimit : { type: DataTypes.INTEGER },
|
||||
RepaymentTenure : { type: DataTypes.INTEGER },
|
||||
EMIAmount : { type: DataTypes.INTEGER },
|
||||
WrittenOffAndSettledStatus : {type: DataTypes.STRING}
|
||||
|
||||
WrittenOffAndSettledStatus : {type: DataTypes.STRING},
|
||||
DateClosed : {type: DataTypes.DATE},
|
||||
grp_str : {type: DataTypes.STRING}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@ -15,6 +15,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
month_bucket_index : { type: DataTypes.INTEGER },
|
||||
EnquiryPurpose : { type: DataTypes.STRING },
|
||||
EnquiryAmount : { type: DataTypes.INTEGER },
|
||||
grp_str : {type: DataTypes.STRING}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@ -25,6 +25,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
highest_dpd_month_wise_bucket_or_count_07_to_12 : { type: DataTypes.STRING },
|
||||
highest_dpd_month_wise_bucket_or_count_13_to_24 : { type: DataTypes.STRING },
|
||||
highest_dpd_month_wise_bucket_or_count_25_to_36 : { type: DataTypes.STRING },
|
||||
DateClosed : {type: DataTypes.DATE},
|
||||
is_active : { type: DataTypes.INTEGER },
|
||||
createdAt : { type: DataTypes.DATE },
|
||||
createdby : { type: DataTypes.INTEGER },
|
||||
|
||||
@ -5,8 +5,9 @@ module.exports = app => {
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
var router = require("express").Router();
|
||||
|
||||
router.get("/test2", Cibilcontroller.test2);
|
||||
router.get("/test", Cibilcontroller.test);
|
||||
// router.get("/testone", Cibilcontroller.testone);
|
||||
// router.get("/starter", Cibilcontroller.starter);
|
||||
// router.get("/test2", Cibilcontroller.test2);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
//const { sequelize} = require('../models');
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
const request = require('request');
|
||||
|
||||
|
||||
|
||||
|
||||
function createSkeleton(statement_end_date)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
end_date = "'"+statement_end_date+"'";
|
||||
let date = new Date(end_date);
|
||||
date.setDate(01);
|
||||
@ -24,23 +27,11 @@ function createSkeleton(statement_end_date)
|
||||
obj = { months:new_date , period:new_period};
|
||||
// push skeleton object
|
||||
years_skeleton.push(obj);
|
||||
|
||||
|
||||
//Reset date here
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return years_skeleton;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return years_skeleton;
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
@ -73,8 +64,104 @@ function findBucketCount(sk_array,dpd_date)
|
||||
}
|
||||
|
||||
|
||||
function cibilInputDataApiCall(losid,pan_no,applicant_type) {
|
||||
try {
|
||||
CIBIL_URL = process.env.CIBIL_DATA_URL;
|
||||
token = process.env.CIBIL_URL_TOKEN;
|
||||
request_object = {
|
||||
"losid": losid,
|
||||
"panNo": pan_no,
|
||||
"applicantType": applicant_type
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: CIBIL_URL,
|
||||
method: "POST",
|
||||
headers: { Authorization: 'Bearer ' + token },
|
||||
json: true,
|
||||
body: request_object
|
||||
}, function (error, response, body){
|
||||
// let data = JSON.parse(response); console.log(response);
|
||||
// if(data.status == 'Successful')
|
||||
// {
|
||||
// resolve(data);
|
||||
// }
|
||||
resolve(body);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function cibilOutputGenerateApiCall(losid,ref_no,cibil_type) {
|
||||
try {
|
||||
var promises = new Promise(async(resolve, reject) => {
|
||||
ActionData = [1,2,3];
|
||||
ActionData.forEach((value,index,array) => {
|
||||
|
||||
let url = process.env.PYTHON_SCRIPT_API+"cibil?reference_number="+ref_no+"&los_id="+losid+"&cibil_type="+cibil_type+"&action="+value;
|
||||
|
||||
request({
|
||||
url: url,
|
||||
method: "GET"
|
||||
}, function (error, response, body){
|
||||
//logMsg
|
||||
})
|
||||
|
||||
if (index === array.length -1) { resolve(); }
|
||||
|
||||
});
|
||||
});
|
||||
promises.then(async()=>{
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function panListApiCall(losid) {
|
||||
try {
|
||||
|
||||
const MAIN_APP_URL = process.env.MAIN_APP_PAN_LIST_URL;
|
||||
url = MAIN_APP_URL+"?losid="+losid;
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: url,
|
||||
method: "GET"
|
||||
}, function (error, response, body){
|
||||
data = JSON.parse(body);
|
||||
if(data.status === 200)
|
||||
{
|
||||
resolve(data.data[0]);
|
||||
}
|
||||
else { resolve(false); }
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
createSkeleton : createSkeleton , findBucketCount : findBucketCount
|
||||
createSkeleton : createSkeleton ,
|
||||
findBucketCount : findBucketCount,
|
||||
cibilInputDataApiCall : cibilInputDataApiCall,
|
||||
cibilOutputGenerateApiCall : cibilOutputGenerateApiCall,
|
||||
panListApiCall : panListApiCall
|
||||
|
||||
}
|
||||
1287
app/services/cibil.datainsert.helper.js
Normal file
1287
app/services/cibil.datainsert.helper.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user