This commit is contained in:
sriramv 2023-09-29 16:17:57 +05:30
parent 8052e2c519
commit bc944ee2dd
4 changed files with 42 additions and 30 deletions

View File

@ -8,9 +8,13 @@ const Sync = require('sync');
const { Op } = require("sequelize"); const { Op } = require("sequelize");
const { Console } = require('winston/lib/winston/transports'); const { Console } = require('winston/lib/winston/transports');
exports.checkProbeApi = async (req, res) => {
// call and get financial year wise data for entity (probe42 api call)
entity_identify_number = 'U72300DL2006PTC151811';
entity_identify_number_type = 'cin';
financials_data_api_response = ApiCallHelper.probe42ApiCall(entity_identify_number,entity_identify_number_type);
res.send({financials_data_api_response});
}
// all master data list for dropdown // all master data list for dropdown
exports.MasterDatas = async (req, res) => { exports.MasterDatas = async (req, res) => {
await Statementsmaster.findAll({ await Statementsmaster.findAll({
@ -95,14 +99,14 @@ exports.MenuList = async (req, res) => {
Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":cin_number,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"probe42_data_status":1,"is_verified":0,"createdby":Pro42Datavalue.createdby}) Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":cin_number,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"probe42_data_status":1,"is_verified":0,"createdby":Pro42Datavalue.createdby})
.then(Entitydata => { .then(Entitydata => {
logMsg.info("entity created , data:"+Entitydata); logMsg.info("entity created , data:"+Entitydata);
const entityid = Entitydata.dataValues.id; let entityid = Entitydata.dataValues.id;
if(Entitydata.dataValues.entity_type == 'COMPANY' || (Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP')) if(Entitydata.dataValues.entity_type == 'COMPANY' || (Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP'))
{ {
const cin = Entitydata.dataValues.cin; let cin = Entitydata.dataValues.cin;
if(cin == "" || cin == null) if(cin == "" || cin == null)
{ {
entity_identify_number = Entitydata.dataValues.pan; entity_identify_number = Entitydata.dataValues.pan;

View File

@ -9,6 +9,8 @@ module.exports = app => {
var router = require("express").Router(); var router = require("express").Router();
router.get("/checkProbeApi", financials.checkProbeApi);
/** /**
* @swagger * @swagger
* /api/checkProbeStatus: * /api/checkProbeStatus:

View File

@ -14,8 +14,8 @@ REDIRECTION_APPLICATION_NAME = process.env.REDIRECTION_APPLICATION_NAME
function probe42ApiCall(entity_identify_number,entity_identify_number_type) { function probe42ApiCall(entity_identify_number,entity_identify_number_type) {
try { try {
var type ="";
const probe_url = PROBE42_URL + "GetCompanyLlpComprehensiveDetailshttps"; const probe_url = PROBE42_URL + "GetCompanyLlpComprehensiveDetails";
const myJSONObject = { const myJSONObject = {
"UserId": PROBE42_USER_ID, "UserId": PROBE42_USER_ID,
"Password": PROBE42_PASSWORD, "Password": PROBE42_PASSWORD,
@ -23,17 +23,21 @@ function probe42ApiCall(entity_identify_number,entity_identify_number_type) {
"Cin_Llpin_Or_Pan": entity_identify_number, "Cin_Llpin_Or_Pan": entity_identify_number,
"Identifier_type" : entity_identify_number_type "Identifier_type" : entity_identify_number_type
}; };
console.log(myJSONObject) // console.log(probe_url)
// console.log(myJSONObject)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request({ request({
url: probe_url, url: probe_url,
method: "POST", method: "POST",
json: true, json: true,
body: myJSONObject body: myJSONObject
}, function (error, response, body) { console.log(body); }, function (error, response, body) {
if (body != undefined) { if (body != undefined) {
if (response.statusCode == 200 && body.hasOwnProperty("data") ) { // console.log(response.statusCode);
financial_data = body.data; res = JSON.parse(body);
// console.log(res.data.company);
if (response.statusCode == 200 && res.hasOwnProperty("data") ) {
financial_data = res.data;
resolve(financial_data); resolve(financial_data);
} else { resolve(false); } } else { resolve(false); }
} else { resolve(false); } } else { resolve(false); }

View File

@ -101,31 +101,33 @@ const { logMsg } = require('../services/logger.js');
.then(data => { logMsg.info("update success : "+ data); }) .then(data => { logMsg.info("update success : "+ data); })
.catch(err => { logMsg.info("update failed : " + err); }); .catch(err => { logMsg.info("update failed : " + err); });
} }
if (index === update_array_data.length -1) { resolve(); } if (index === update_array_data.length -1) { resolve(value.entityid); }
}); });
}); });
LineItemUpdate.then((Query_data)=>{ LineItemUpdate.then((entityid)=>{
//Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }}); //Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
Entityfinyear.update({ probe42_data_status : 1 } , {where : {entityid:entityid , FY :fy}}) Entityfinyear.update({ probe42_data_status : 1 } , {where : {entityid:entityid , FY :fy}})
.then(async (data) => { .then(async (data) => {
logMsg.info("Probe42 data updated for EntityId = "+entityid+" Year = "+fy); logMsg.info("Probe42 data updated for EntityId = "+entityid+" Year = "+fy);
Entityfinyear.findAll({where : {entityid:entityid},rew:true}) // Entityfinyear.findAll({where : {entityid:entityid},rew:true})
.then(async (EntityfinyearData) =>{ // .then(async (EntityfinyearData) =>{
let count = 0; // let count = 0;
for(const value of EntityfinyearData) // for(const value of EntityfinyearData)
{ // {
count = count + value.probe42_data_status; // count = count + value.probe42_data_status;
} // }
if(EntityfinyearData.length == count) // if(EntityfinyearData.length == count)
{ // {
Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }}); // Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
} // }
else if(count >=1) // else if(count >=1)
{ // {
Entities.update({ "probe42_data_status": 3 },{ where: { id: entityid }}); // Entities.update({ "probe42_data_status": 3 },{ where: { id: entityid }});
} // }
}); // });
await Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
}).catch(err => { logMsg.info("Probe42 data update failed for EntityId = "+entityid+" Year = "+fy); }); }).catch(err => { logMsg.info("Probe42 data update failed for EntityId = "+entityid+" Year = "+fy); });
}); });
} }