probe42ApiEndpointChanges:GWM

This commit is contained in:
sriramv 2023-09-29 10:29:36 +05:30
parent 5104638810
commit aca57a7fd7
3 changed files with 121 additions and 112 deletions

View File

@ -94,105 +94,125 @@ 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 cin = Entitydata.dataValues.cin;
if(cin != "")
if(Entitydata.dataValues.entity_type == 'COMPANY' || (Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP'))
{
const entityid = Entitydata.dataValues.id;
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,entityid);
}
// processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
// processInstanceId.then(function(InstanceId){
// console.log("startFinancialsProcessInstance data");
// console.log(InstanceId);
// Entities.update({ "process_instance_id":InstanceId },{ where: { id: entityid }}).then(processInstanceIdData =>{
// // resolve here
// if (key === array.length -1) { resolve(); } }).catch(err=>{ logMsg.info("camunda process_instance_id creation for entity_id= "+entityid); });
// });
// call and get financial year wise data for entity (probe42 api call)
financials_data_api_response = ApiCallHelper.probe42ApiCall(cin);
financials_data_api_response.then(function(result){
if(result == false)
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,entityid);
}
else
{
//filter lineitems from api responce and construct to needed format
lineItem_data = Probe42DataMappingHelper.lineItemFetching(result);
lineItem_data.then(function(lineItem_result){
//create financial table and entityfinyear table record here
lineItem_result.forEach((value, key)=>{
Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.year,"st_type": 0 })
.then(Entityfinyearsdata => {
// create skeletion with itemmaster data (itemmaster(id) == financial(itemid))
Itemsmaster.findAll({ where :{pvtltd:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['pvtltd_itemorder', 'ASC']] })
.then(ItemsmasterData => {
//construct lineitem array for bulk insert using itemmaster primarykey (id)
var SkeletonInsert = new Promise((resolve, reject) => {
let fin_data_array = [];
ItemsmasterData.forEach( (itemvalue , index , itemvaluearray) => {
fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":itemvalue.dataValues.id,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1,"createdby":4}
fin_data_array.push(fin_data_obj);
if (index === itemvaluearray.length -1) { resolve(fin_data_array); }
})
});
SkeletonInsert.then((Query_data)=>{
Financials.bulkCreate(Query_data).then(data=>{
//line item data update
// mapping of probe42 api lineItem with itemMaster primary key
final_array = Probe42DataMappingHelper.lineItemMapping(value,entityid);
final_array.then(function(update_array_data){
// update mapped lineitem value here
Probe42DataMappingHelper.lineItemUpdate(update_array_data);
});//end of lineItemUpdate helper call
}).catch(err=>(console.log(err))); //skeleton bulk create query
});
}).catch(err=>(console.log(err))); //itemmaster query
}).catch(err => {
res.status(404).send({'status':404,
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
}); // end of entity fin year table data insert
});//end of line item foreach
});//end of lineItem filter from api response helper call
} // end of probe42 api responce success else condition
});//end of probe42 api call
} else {
console.log(Entitydata.dataValues.bizname.slice(-3));
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
const cin = Entitydata.dataValues.cin;
if(cin == "" || cin == null)
{
entity_identify_number = Entitydata.dataValues.pan;
entity_identify_number_type = 'pan';
}
else
{
entity_identify_number = Entitydata.dataValues.cin;
if(Entitydata.dataValues.entity_type == 'COMPANY')
{
entity_identify_number_type = 'cin';
}else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP')
{
entity_identify_number_type = 'llp';
}
}
// call and get financial year wise data for entity (probe42 api call)
financials_data_api_response = ApiCallHelper.probe42ApiCall(entity_identify_number,entity_identify_number_type);
financials_data_api_response.then(function(result){
if(result == false)
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
}else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) != 'LLP'){
// create skeleton here
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
}
// resolve here
if (key === array.length -1) { resolve(); }
logMsg.info("CIN no not exist for losid = "+losid+" and entity name ="+Entitydata.dataValues.bizname);
}
financialControllerHelper.createSkeleton(losid,entityid);
}
else
{
if(result.financials.length > 0)
{
//filter lineitems from api responce and construct to needed format
lineItem_data = Probe42DataMappingHelper.lineItemFetching(result.financials);
lineItem_data.then(function(lineItem_result){
//create financial table and entityfinyear table record here
lineItem_result.forEach((value, key)=>{
Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.year,"st_type": 0 })
.then(Entityfinyearsdata => {
// create skeletion with itemmaster data (itemmaster(id) == financial(itemid))
Itemsmaster.findAll({ where :{pvtltd:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['pvtltd_itemorder', 'ASC']] })
.then(ItemsmasterData => {
//construct lineitem array for bulk insert using itemmaster primarykey (id)
var SkeletonInsert = new Promise((resolve, reject) => {
let fin_data_array = [];
ItemsmasterData.forEach( (itemvalue , index , itemvaluearray) => {
fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":itemvalue.dataValues.id,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1}
fin_data_array.push(fin_data_obj);
if (index === itemvaluearray.length -1) { resolve(fin_data_array); }
})
});
SkeletonInsert.then((Query_data)=>{
Financials.bulkCreate(Query_data).then(data=>{
//line item data update
// mapping of probe42 api lineItem with itemMaster primary key
final_array = Probe42DataMappingHelper.lineItemMapping(value,entityid);
final_array.then(function(update_array_data){
// update mapped lineitem value here
Probe42DataMappingHelper.lineItemUpdate(update_array_data);
});//end of lineItemUpdate helper call
}).catch(err=>(console.log(err))); //skeleton bulk create query
});
}).catch(err=>(console.log(err))); //itemmaster query
}).catch(err => {
res.status(404).send({'status':404,
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
}); // end of entity fin year table data insert
});//end of line item foreach
});//end of lineItem filter from api response helper call
}
else
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,entityid);
// resolve here
if (key === array.length -1) { resolve(); }
}
} // end of probe42 api responce success else condition
});//end of probe42 api call
} else {
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
}else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) != 'LLP'){
// create skeleton here
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
}
// resolve here
if (key === array.length -1) { resolve(); }
}
}).catch(err => {
res.status(404).send({'status':404,
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
}); // end of entity insert
}).catch(err => {
res.status(404).send({'status':404,
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
}); // end of entity insert
} //end of else condition
@ -221,21 +241,7 @@ exports.MenuList = async (req, res) => {
let Time = 2000;
let data = [];
//EntitiesData.forEach((value, key)=>{
// Time = Time + 500;
// instancesid = value.dataValues.process_instance_id;
// taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
// taskid.then(function(result){
// Time = Time + 500;
// formVariable = camundaHelper.financialsFormVariables(result);
// formVariable.then(function(form_result){
// formVariableResult = JSON.parse(form_result);
// if(formVariableResult.type){ camunda_status = {"process_status":"NULL"}; } else { camunda_status =JSON.parse(form_result); }
// obj_data = { ...value.dataValues ,status:camunda_status , statementsmasterrData:MasterData }
// data.push(obj_data);
// });
// });
//}); // end of EntitiesData foreach
for(const value of EntitiesData)
{

View File

@ -11,14 +11,17 @@ REDIRECTION_PASSWORD = process.env.REDIRECTION_PASSWORD
REDIRECTION_APPLICATION_NAME = process.env.REDIRECTION_APPLICATION_NAME
function probe42ApiCall(cin) {
function probe42ApiCall(entity_identify_number,entity_identify_number_type) {
try {
const probe_url = PROBE42_URL + "companycomprehensivedetails";
var type ="";
const probe_url = PROBE42_URL + "GetCompanyLlpComprehensiveDetailshttps";
const myJSONObject = {
"UserId": PROBE42_USER_ID,
"Password": PROBE42_PASSWORD,
"ApplicationName": PROBE42_APPLICATION_NAME,
"Cin": cin
"Cin_Llpin_Or_Pan": entity_identify_number,
"Identifier_type" : entity_identify_number_type
};
return new Promise((resolve, reject) => {
request({
@ -29,7 +32,7 @@ function probe42ApiCall(cin) {
}, function (error, response, body) {
if (body != undefined) {
if (response.statusCode == 200 && body.hasOwnProperty("data") && body.data.financials.length != 0) {
financial_data = body.data.financials;
financial_data = body.data;
resolve(financial_data);
} else { resolve(false); }
} else { resolve(false); }

View File

@ -110,7 +110,7 @@ const { logMsg } = require('../services/logger.js');
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:300},rew:true})
Entityfinyear.findAll({where : {entityid:entityid},rew:true})
.then(async (EntityfinyearData) =>{
let count = 0;
for(const value of EntityfinyearData)
@ -127,7 +127,7 @@ const { logMsg } = require('../services/logger.js');
}
});
}).catch(err => { logMsg.info("Probe42 data update failed for EntityId = "+entityid+" Year = "+fy); });
});
});
}
catch (error)
{