MergeUnmerge:GWM

This commit is contained in:
sriramv 2022-07-20 08:58:31 +05:30
parent 766284b011
commit 441521fd4f
3 changed files with 23 additions and 18 deletions

View File

@ -562,7 +562,7 @@ exports.ConsolidatedActiveAndClosedLoansReviewAction =async (req, res) =>
try
{
LoanData = await sequelize.query("SELECT [losid],STRING_AGG(ref_no,',')as ref_no,STRING_AGG(consumer_name, ',') as consumer_name, [account_type],count(*) as loan_count, [ownership], [reported_and_certified_date], [opened_date], [sanctioned_amount], [current_balance], [repayment_tenure], [emi_amount], [overdue_amount], [status], [current_dpd], [highest_dpd_month_wise_bucket_or_count_0_to_6], [highest_dpd_month_wise_bucket_or_count_07_to_12], [highest_dpd_month_wise_bucket_or_count_13_to_24], [highest_dpd_month_wise_bucket_or_count_25_to_36], [DateClosed], [grp_str] FROM [out_active_and_closed_loans_details] AS [OutputActiveAndClosedLoans] WHERE [OutputActiveAndClosedLoans].[losid] = '"+req.query.losid+"' GROUP BY [grp_str], [losid], [account_type], [ownership], [reported_and_certified_date], [opened_date], [sanctioned_amount], [current_balance], [repayment_tenure], [emi_amount], [overdue_amount], [status], [current_dpd], [highest_dpd_month_wise_bucket_or_count_0_to_6], [highest_dpd_month_wise_bucket_or_count_07_to_12], [highest_dpd_month_wise_bucket_or_count_13_to_24], [highest_dpd_month_wise_bucket_or_count_25_to_36], [DateClosed]");
LoanData = await sequelize.query("SELECT [losid],STRING_AGG(ref_no,',')as ref_no,STRING_AGG(consumer_name, ',') as consumer_name,MAX(account_type) as account_type,count(*) as loan_count, MAX(ownership) as ownership,MAX(reported_and_certified_date) as reported_and_certified_date,MAX(opened_date) as opened_date,MAX(sanctioned_amount) assanctioned_amount,MAX(current_balance) as current_balance,MAX(repayment_tenure) asrepayment_tenure,MAX(emi_amount) as emi_amount, MAX(overdue_amount) as overdue_amount,MAX(status) as status, MAX(current_dpd) as current_dpd, MAX(highest_dpd_month_wise_bucket_or_count_0_to_6) as highest_dpd_month_wise_bucket_or_count_0_to_6,MAX(highest_dpd_month_wise_bucket_or_count_07_to_12) as highest_dpd_month_wise_bucket_or_count_07_to_12,MAX(highest_dpd_month_wise_bucket_or_count_13_to_24) as highest_dpd_month_wise_bucket_or_count_13_to_24,MAX(highest_dpd_month_wise_bucket_or_count_25_to_36) as highest_dpd_month_wise_bucket_or_count_25_to_36,MAX(DateClosed) as DateClosed, [grp_str] FROM [out_active_and_closed_loans_details] AS [OutputActiveAndClosedLoans] WHERE [OutputActiveAndClosedLoans].[losid] = '"+req.query.losid+"' GROUP BY [grp_str], [losid]");
if(LoanData.length != 0)
{
@ -587,7 +587,7 @@ exports.ConsolidatedActiveAndClosedLoansReviewAction =async (req, res) =>
LoanDataPromises.then(async(FinalLoanData)=>{
setTimeout(() => {
res.send({'status':200 , message:"Success." ,'data': FinalLoanData});
}, 1000);
}, 3000);
});
@ -608,6 +608,10 @@ exports.ConsolidatedActiveAndClosedLoansReviewAction =async (req, res) =>
// merge unmerge api
exports.LoansDetailsMergeUnmergeApi =async (req, res) =>
{
try
@ -621,8 +625,8 @@ exports.LoansDetailsMergeUnmergeApi =async (req, res) =>
//unmerge loans
request_object.unmergeData.forEach(async(unmergeValue,unmergeIndex,unmergeArray) => {
let Unique_Group_string = Math.random().toString(36).slice(2, 10).toUpperCase();
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:unmergeValue.refno,grp_str:unmergeValue.grp_str}});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:unmergeValue.refno,grp_str:unmergeValue.grp_str}});
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:unmergeValue.refno,grp_str:unmergeValue.grp_str}}).catch(err=>{});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:unmergeValue.refno,grp_str:unmergeValue.grp_str}}).catch(err=>{});
console.log(unmergeValue.refno);
});
}else { logMsg.info("There is no any unmerge data selected for losid= "+request_object.losid); }
@ -635,8 +639,8 @@ exports.LoansDetailsMergeUnmergeApi =async (req, res) =>
{
let Unique_Group_string = mergeValue.mergeable_grp_str;
mergeValue.data.forEach(async(Value,Index,Array) => {
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:Value.refno,grp_str:Value.grp_str}});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:Value.refno,grp_str:Value.grp_str}});
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:Value.refno,grp_str:Value.grp_str}}).catch(err=>{});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:Value.refno,grp_str:Value.grp_str}}).catch(err=>{});
console.log(Value.refno);
});
}
@ -644,8 +648,8 @@ exports.LoansDetailsMergeUnmergeApi =async (req, res) =>
{
let Unique_Group_string = Math.random().toString(36).slice(2, 10).toUpperCase()+"-"+Math.random().toString(36).slice(2, 6)+"-"+Math.random().toString(36).slice(2, 6)+"-"+Math.random().toString(36).slice(2, 12).toUpperCase();
mergeValue.data.forEach(async(Value,Index,Array) => {
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:Value.refno,grp_str:Value.grp_str}});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:Value.refno,grp_str:Value.grp_str}});
await InCreditFacility.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ReferenceNumber:Value.refno,grp_str:Value.grp_str}}).catch(err=>{});
await OutputActiveAndClosedLoans.update({grp_str:Unique_Group_string},{where:{losid:request_object.losid,ref_no:Value.refno,grp_str:Value.grp_str}}).catch(err=>{});
console.log(Value.refno);
});
}
@ -669,7 +673,7 @@ exports.LoansDetailsMergeUnmergeApi =async (req, res) =>
});
DataPromises.then(async()=>{
setTimeout(async() => {
await Helper.cibilOutputGenerateApiCall(request_object.losid,'Test-ReferenceNumber',cibil_type,[2],2);
await Helper.cibilOutputGenerateApiCall(request_object.losid,'Test-ReferenceNumber',1,[2],2);
res.send({'status':200 , message:"Success." ,'data': "No data"});
}, 1500);
});
@ -778,7 +782,7 @@ exports.starter = async (req, res) =>
});
OutputDataGenerator.then(async(losid)=>{
ProcCall = await sequelize.query("DECLARE @uniuqe_loans_found int,@row_updated int EXEC IdentifyUniqueLoans '"+losid+"',@uniuqe_loans_found OUTPUT,@row_updated OUTPUT SELECT @uniuqe_loans_found as uniuqe_loans_found,@row_updated as row_updated ");
await Helper.cibilOutputGenerateApiCall(value.losid,value.ReferenceNumber,value.cibil_type,[2,3],2);
await Helper.cibilOutputGenerateApiCall(losid,'Test-ReferenceNumber',1,[2,3],2);
BorrowerData = await InBorrowerDetail.findAll({where:{losid:losid}});
res.send({'status':200 , message:"Success." ,'data':BorrowerData});
});
@ -820,7 +824,8 @@ exports.test = async (req, res) =>
{
try
{
// date = '04-AUG-2017';
// data = moment(new Date(date)).format("YYYY-MM-DD");
// console.log(data);

View File

@ -24,7 +24,7 @@ module.exports = (sequelize, DataTypes) => {
DateofEntryforErrorCode: { type: DataTypes.DATE }, //
ErrorSegmentTag: { type: DataTypes.STRING }, //
ErrorCode: { type: DataTypes.STRING }, //
DateofEntryforCIBILRemarksCode: { type: DataTypes.STRING },//
DateofEntryforCIBILRemarksCode: { type: DataTypes.DATE },//
CIBILRemarks: { type: DataTypes.STRING }, //
DateofEntryforErrorDisputeRemarksCode: { type: DataTypes.STRING }, //
ErrorDisputeRemarksCode: { type: DataTypes.STRING }, //

View File

@ -21,24 +21,24 @@ function consumerDataInsert(data)
EnquiryMemberUserID: value.enquiryMemberUserID,
SubjectReturnCode: value.subjectReturnCode,
EnquiryControlNumber: value.enquiryControlNumber,
DateTimeProcessed: value.dateTimeProcessed,
DateTimeProcessed: moment(new Date( value.dateTimeProcessed)).format("YYYY-MM-DD"),
ConsumerNameField1: value.consumerNameField1,
ConsumerNameField2: value.consumerNameField2,
ConsumerNameField3: value.consumerNameField3,
ConsumerNameField4: value.consumerNameField4,
ConsumerNameField5: value.consumerNameField5,
DateofBirth: value.dateofBirth,
DateofBirth: moment(new Date( value.dateofBirth)).format("YYYY-MM-DD"),
Gender: value.gender,
DateofEntryforErrorCode: value.dateofEntryforErrorCode,
DateofEntryforErrorCode: moment(new Date( value.dateofEntryforErrorCode)).format("YYYY-MM-DD"),
ErrorSegmentTag: value.errorSegmentTag,
ErrorCode: value.errorCode,
DateofEntryforCIBILRemarksCode: value.dateofEntryforCIBILRemarksCode,
DateofEntryforCIBILRemarksCode: moment(new Date( value.dateofEntryforCIBILRemarksCode)).format("YYYY-MM-DD"),
CIBILRemarks: value.cibilRemarks,
DateofEntryforErrorDisputeRemarksCode: value.dateofEntryforErrorDisputeRemarksCode,
ErrorDisputeRemarksCode: value.errorDisputeRemarksCode,
ErrorDisputeRemarksCode2: value.errorDisputeRemarksCode2,
AccountType: value.accountType,
DateReportedAndCertified: value.dateReportedAndCertified,
DateReportedAndCertified: moment(new Date( value.dateReportedAndCertified)).format("YYYY-MM-DD"),
Occupation: value.occupation,
Income: value.income,
NetGrossIncomeIndicator: value.netGrossIncomeIndicator,
@ -51,7 +51,7 @@ function consumerDataInsert(data)
ErrorDisputeRemarksCode1: value.errorDisputeRemarksCode1,
ATErrorDisputeRemarksCode1: value.atErrorDisputeRemarksCode1,
ATErrorDisputeRemarksCode2: value.atErrorDisputeRemarksCode2,
DateOfEntry: value.dateOfEntry,
DateOfEntry: moment(new Date( value.dateOfEntry)).format("YYYY-MM-DD"),
DisputeRemarksLine: value.disputeRemarksLine,
EMailID: value.eMailID,
AccountNumber: value.accountNumber