loanApiIntegration:GWM

This commit is contained in:
sriramv 2023-07-27 17:12:51 +05:30
parent f46482e510
commit 7a7d82ebbe
3 changed files with 59 additions and 17 deletions

View File

@ -5,7 +5,7 @@ const DataInsertHelper = require('../services/cibil.datainsert.helper.js');
const { Op } = require('sequelize');
const moment = require('moment');
// landing page list of all pan number and reference number from commercial & consumer against losid
// exports.LandingPageDetailsList =async (req, res) =>
// {
@ -730,25 +730,33 @@ exports.LandingPageDetailsList = async (req, res) =>
{
try
{
ResData = await Helper.loanDetailsDataApiCall(req.query.losid);
PanList = [];
if (ResData.status == "Successful" && ResData.lstLoanApplication.length != 0)
{
ResData.lstApplicantKYCDetail.forEach(async(value,index,array) => {
if (value.kycType.trim() == "Non-Individual")
{
lstEntityKYCDetailObj = { pan_no : value.panNo,entity_type : value.kycType.trim() }
await PanList.push(lstEntityKYCDetailObj);
} else if (value.kycType.trim() == "Individual")
{
lstApplicantKYCDetailObj = { pan_no : value.panNo,entity_type : value.kycType.trim(),}
await PanList.push(lstApplicantKYCDetailObj);
}
});
} // end of if lstLoanApplication
PanList = await Helper.panListApiCall(req.query.losid);
// PanList = [
// {
// "losid": "MW00045413",
// "PAN": "AAACR4282J",
// "entity_type": "Individual"
// }
// ];
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})
if(PanListValue.entity_type == "Individual"){ CibilType = 1; }else if(PanListValue.entity_type == "Non-Individual"){CibilType = 2;}
await Object.assign(PanListValue, {cibil_type:CibilType})
BorrowerDetailData = await InBorrowerDetail.findOne({where:{losid:PanListValue.losid , PAN:PanListValue.PAN ,cibil_type:CibilType}});
if(BorrowerDetailData)
@ -821,8 +829,6 @@ exports.LandingPageDetailsList = async (req, res) =>
{
res.send({'status':404 , message:"Failed." ,'data':"Applicant Details not found from MainApp"});
}
} catch(err) {
res.send({'status':404,

View File

@ -11,7 +11,8 @@ function createSkeleton(statement_end_date)
{
end_date = "'"+statement_end_date+"'";
let date = new Date(end_date);
date.setDate(01);
let day = '01';
date.setDate(parseInt(day));
years_skeleton = [];
for(let i=0;i<36;i++)
@ -97,6 +98,37 @@ try {
}
}
async function loanDetailsDataApiCall(losid) {
try {
LOAN_URL = process.env.LOS_DATA_URL;
token = await getLoginToken();
request_object = {
"losid": losid
};
return new Promise((resolve, reject) => {
request({
url: LOAN_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,ActionDataArray,output_type) {
try {
@ -205,6 +237,7 @@ module.exports = {
cibilOutputGenerateApiCall : cibilOutputGenerateApiCall,
panListApiCall : panListApiCall ,
getLoginToken : getLoginToken,
convertDateFormat : convertDateFormat
convertDateFormat : convertDateFormat,
loanDetailsDataApiCall:loanDetailsDataApiCall
}

View File

@ -1,6 +1,9 @@
require('dotenv').config();
const express = require('express')
const app = express()
// Enable CORS for all routes
const cors = require('cors');
app.use(cors());
//it is used to clear cache
app.use(function(req, res, next) {
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")