Compare commits

..

10 Commits

Author SHA1 Message Date
sriramv
bc944ee2dd GWM 2023-09-29 16:17:57 +05:30
sriramv
8052e2c519 gwm:probe42 2023-09-29 14:27:12 +05:30
sriramv
aca57a7fd7 probe42ApiEndpointChanges:GWM 2023-09-29 10:29:36 +05:30
sriramv
5104638810 susee:excel upload cin no chnge 2023-08-19 11:30:25 +05:30
sriramv
db085003d4 excel:GWM 2023-08-10 14:17:25 +05:30
sriramv
e2dab11335 excel:GWM 2023-08-10 14:12:27 +05:30
sriramv
74f3459e65 excel:GWM 2023-08-10 13:29:51 +05:30
sriramv
5a998b32d4 excel:GWM 2023-08-10 12:45:39 +05:30
sriramv
473ca2f44a excel:GWM 2023-08-10 12:37:12 +05:30
sriramv
dff610f8df GWM 2023-08-09 12:34:10 +05:30
6 changed files with 189 additions and 141 deletions

View File

@ -22,15 +22,17 @@ exports.ImportExcelData = async (req, res , filename) =>
for(let i = 0; i < sheets.length; i++)
{
const sheetName = sheets[i];
const sheetName = req.body.cin;
const SheetLevelData = reader.utils.sheet_to_json(file.Sheets[file.SheetNames[i]]);
const resultArray = [];
if(SheetLevelData.length != 0)
{
if(sheetName.toUpperCase() == 'PROPRIETORSHIP'){
where_Condition = { losid : losid , entity_type : 'PROPRIETORSHIP' }
where_Condition = { losid : losid , entity_type : 'PROPRIETORSHIP', probe42_data_status: 2 }
}else if(sheetName.toUpperCase() == 'PARTNERSHIP'){
where_Condition = { losid : losid , entity_type : 'PARTNERSHIP', probe42_data_status: 2 }
}else{
where_Condition = { losid : losid , cin : sheetName }
where_Condition = { losid : losid , cin : sheetName , probe42_data_status: 2 }
}
EntityData = await Entities.findOne({raw:true, where: where_Condition }).catch(err => {});
@ -87,11 +89,16 @@ exports.ImportExcelData = async (req, res , filename) =>
logMsg.info("Value not updated for - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid);
}
if (key === array.length -1) { resolve(); }
if (key === array.length -1) { resolve(DataArray); }
});
});
FinancialsDataUpdate.then(async(data)=>
{
{
const filteredData = data.filter(subArray => subArray.length > 0);
filteredData.forEach(async(value, key , array)=>{
var entity_id = value[0]['entity_id'];
await Entities.update( {manual_data_status:1},{where:{id:entity_id}} ).then(data=>{}).catch(err=>{ logMsg.info(err); });
});
res.send({'status':200,'message':"success",'data':"No data"});
});

View File

@ -6,10 +6,15 @@ const ApiCallHelper = require('../services/financials.apicall.helper.js');
const Probe42DataMappingHelper = require('../services/probe42lineitem.mapping.helper.js');
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({
@ -94,105 +99,142 @@ 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 != "")
let entityid = Entitydata.dataValues.id;
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);
}else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) != 'LLP'){
// 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 {
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
let cin = Entitydata.dataValues.cin;
if(cin == "" || cin == null)
{
// create skeleton here
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
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';
}
}
console.log("entity_identify_number = "+entity_identify_number);
console.log("entity_identify_number_type = "+entity_identify_number_type);
// 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)
{
console.log("probe42ApiCall failed");
// create skeleton here
financialControllerHelper.createSkeleton(losid,entityid);
}
else
{
// update cin/llp (if not get from redirection api)
if(cin == "" || cin == null)
{
if(Entitydata.dataValues.entity_type == 'COMPANY')
{
Entities.update({ "cin":result.company.cin}, {where : { id: entityid }});
}else if(Entitydata.dataValues.entity_type == 'PARTNERSHIP' && Entitydata.dataValues.bizname.slice(-3) == 'LLP')
{
Entities.update({ "cin":result.llp.llpin}, {where : { id: entityid }});
}
}
if(result.financials.length > 0)
{
console.log("probe42ApiCall success");
//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(); }
}
// resolve here
if (key === array.length -1) { resolve(); }
logMsg.info("CIN no not exist for losid = "+losid+" and entity name ="+Entitydata.dataValues.bizname);
}
}).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
@ -215,27 +257,13 @@ exports.MenuList = async (req, res) => {
Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}})
.then(MasterData => {
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' , 'probe42_data_status' ,'is_verified' ], order: [['id', 'ASC']] })
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' , 'probe42_data_status' ,'is_verified','manual_data_status' ], order: [['id', 'ASC']] })
.then(async(EntitiesData) => {
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

@ -25,6 +25,7 @@ module.exports = (sequelize, DataTypes) => {
activity_group: { type: DataTypes.STRING },
biz_act_desc: { type: DataTypes.STRING },
probe42_data_status : {type : DataTypes.INTEGER},
manual_data_status : {type : DataTypes.INTEGER},
is_verified : {type : DataTypes.INTEGER},
createdby: { type: DataTypes.INTEGER },
updatedby: { type: DataTypes.INTEGER },

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

@ -11,25 +11,33 @@ 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";
const probe_url = PROBE42_URL + "GetCompanyLlpComprehensiveDetails";
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
};
// 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) {
}, function (error, response, body) {
if (body != undefined) {
if (response.statusCode == 200 && body.hasOwnProperty("data") && body.data.financials.length != 0) {
financial_data = body.data.financials;
// 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,33 +101,35 @@ 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:300},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); });
});
});
}
catch (error)
{