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 { 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
exports.MasterDatas = async (req, res) => {
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})
.then(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'))
{
const cin = Entitydata.dataValues.cin;
let cin = Entitydata.dataValues.cin;
if(cin == "" || cin == null)
{
entity_identify_number = Entitydata.dataValues.pan;

View File

@ -8,6 +8,8 @@ module.exports = app => {
const { logMsg } = require('../services/logger.js');
var router = require("express").Router();
router.get("/checkProbeApi", financials.checkProbeApi);
/**
* @swagger

View File

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

View File

@ -87,7 +87,7 @@ const { logMsg } = require('../services/logger.js');
{
entityid = update_array_data[0].entityid;
fy = update_array_data[0].year;
var LineItemUpdate = new Promise((resolve, reject) => {
@ -101,31 +101,33 @@ const { logMsg } = require('../services/logger.js');
.then(data => { logMsg.info("update success : "+ data); })
.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 }});
Entityfinyear.update({ probe42_data_status : 1 } , {where : {entityid:entityid , FY :fy}})
.then(async (data) => {
logMsg.info("Probe42 data updated for EntityId = "+entityid+" Year = "+fy);
Entityfinyear.findAll({where : {entityid:entityid},rew:true})
.then(async (EntityfinyearData) =>{
let count = 0;
for(const value of EntityfinyearData)
{
count = count + value.probe42_data_status;
}
if(EntityfinyearData.length == count)
{
Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
}
else if(count >=1)
{
Entities.update({ "probe42_data_status": 3 },{ where: { id: entityid }});
}
});
// Entityfinyear.findAll({where : {entityid:entityid},rew:true})
// .then(async (EntityfinyearData) =>{
// let count = 0;
// for(const value of EntityfinyearData)
// {
// count = count + value.probe42_data_status;
// }
// if(EntityfinyearData.length == count)
// {
// Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
// }
// else if(count >=1)
// {
// 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); });
});
}