merge:GWM

This commit is contained in:
sriramv 2022-02-02 11:56:53 +05:30
parent 7e12025250
commit d45a09df2b
2 changed files with 51 additions and 282 deletions

View File

@ -283,97 +283,6 @@ exports.MenuList = (req, res) => {
// //starter function
// function starter(req, res)
// {
// const losid = req.losid;
// try
// {
// //pro 42 api call using losid
// const Pro42Data = [
// {"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
// {"losid":losid,"pan":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
// ];
// // insert pro42data into entities table using using foreach
// Pro42Data.forEach((Pro42Datavalue, key)=>{
// // check if the Pro42Data (entity) already inserted
// Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
// if(Entity)
// {
// // skip inserting
// }
// else
// {
// Entities.create({ "losid":Pro42Datavalue.losid,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.cin,"bizname":Pro42Datavalue.bizname,"entity_type":Pro42Datavalue.entity_type,"activity_group":Pro42Datavalue.activity_group,"biz_act_desc":Pro42Datavalue.biz_act_desc,"createdby":Pro42Datavalue.createdby})
// .then(Entitydata => {
// //process instance Id update
// const entityid = Entitydata.dataValues.id;
// const user = "SMC";
// processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
// processInstanceId.then(function(InstanceId){
// Entities.update({ "process_instance_id":InstanceId },{ where: { id: entityid }});
// });
// // call and get financial year wise data for entity
// const crnt_year = new Date().getFullYear();
// const Y1 = crnt_year - 1;
// const Y2 = Y1-1;
// const Y3 = Y2-1;
// const financial_years_api_reaponce_data =[{'fy':Y1,'st_type':2},{'fy':Y2,'st_type':2},{'fy':Y3,'st_type':2}];
// //create financial table and entityfinyear table record here
// financial_years_api_reaponce_data.forEach((value, key)=>{
// //create Entityfinyears data
// Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.fy,"st_type":value.st_type})
// .then(Entityfinyearsdata => {
// // create skeletion
// // generate financials data array
// let fin_data_array = [];
// for (let i = 1; i < 120; i++)
// {
// fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":i,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1,"createdby":4}
// fin_data_array.push(fin_data_obj);
// } //console.log("------"+entity_id +"---"+ fy)
// //bulk financials data create
// Financials.bulkCreate(fin_data_array);
// }).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 foreach
// }).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
// }); // end of (losid,pan,cin) combination checking entity data exist or not
// }); // end of pro42 data foreach
// return {'status':200,'message':"success",'data':"No data"}; // success message
// } catch(err) {
// res.status(500).send({'status':404,
// message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
// }); } //end of try catch
// };
@ -749,7 +658,57 @@ exports.createFinancialYear = async (req, res) => {
exports.refreshApi = (req, res) => {
try
{
const cin = req.body.cin;
const losid = req.body.losid;
const entityid = req.body.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){
console.log(lineItem_result)
//create financial table and entityfinyear table record here
lineItem_result.forEach((value, key)=>{
//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){
console.log(update_array_data)
// update mapped lineitem value here
//Probe42DataMappingHelper.lineItemUpdate(update_array_data);
});//end of lineItemUpdate helper call
});//end of line item foreach
setTimeout(() => {
res.status(200).send({'status':200,message: "success" ,'data': "No data" });
}, 5000);
});//end of lineItem filter from api response helper call
} // end of probe42 api responce success else condition
});//end of probe42 api call
}//try
catch (error)
{
}
}
@ -818,194 +777,4 @@ exports.createFinancialYear = async (req, res) => {
// menulist before api implementation
// exports.MenuList = (req, res) => {
// Sync(function()
// {
// try
// {
// const losid = req.query.losid;
// //pro 42 api call using losid
// const Pro42Data = [
// {"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
// {"losid":losid,"pan":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
// ];
// var EntityInsert = new Promise((resolve, reject) => {
// // insert pro42data into entities table using using foreach
// Pro42Data.forEach((Pro42Datavalue, key,array)=>{
// // check if the Pro42Data (entity) already inserted
// Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
// if(Entity)
// {
// // skip inserting
// if (key === array.length -1) {resolve();}
// }
// else
// {
// Entities.create({ "losid":Pro42Datavalue.losid,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.cin,"bizname":Pro42Datavalue.bizname,"entity_type":Pro42Datavalue.entity_type,"activity_group":Pro42Datavalue.activity_group,"biz_act_desc":Pro42Datavalue.biz_act_desc,"createdby":Pro42Datavalue.createdby})
// .then(Entitydata => {
// //process instance Id update
// const entityid = Entitydata.dataValues.id;
// const user = "SMC";
// processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
// processInstanceId.then(function(InstanceId){
// Entities.update({ "process_instance_id":InstanceId },{ where: { id: entityid }});
// });
// // call and get financial year wise data for entity
// const crnt_year = new Date().getFullYear();
// const Y1 = crnt_year - 1;
// const Y2 = Y1-1;
// const Y3 = Y2-1;
// const financial_years_api_response_data =[{'fy':Y1,'st_type':2},{'fy':Y2,'st_type':2},{'fy':Y3,'st_type':2}];
// //create financial table and entityfinyear table record here
// financial_years_api_response_data.forEach((value, key)=>{
// //create Entityfinyears data
// Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.fy,"st_type":value.st_type})
// .then(Entityfinyearsdata => {
// // create skeletion
// // generate financials data array
// let fin_data_array = [];
// for (let i = 1; i < 120; i++)
// {
// fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":i,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1,"createdby":4}
// fin_data_array.push(fin_data_obj);
// } //console.log("------"+entity_id +"---"+ fy)
// //bulk financials data create
// Financials.bulkCreate(fin_data_array);
// }).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 foreach
// 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
// } //end of else condition
// }); // end of (losid,pan,cin) combination checking entity data exist or not
// }); // end of pro42 data foreach
// }); // end of promise
// EntityInsert.then(() => {
// setTimeout(()=>{
// 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' ] })
// .then(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);
// });
// });
// // obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
// // data.push(obj_data);
// }); // end of EntitiesData foreach
// setTimeout(()=>{
// // below code for overall sum object push process
// sum_data = { ...{'losid':losid,'bizname':"Consolidated Financials Summary",'is_consolidated_api_call':1} , statementsmasterrData:MasterData };
// data.push(sum_data);
// // send respose to FE
// res.send({'status':200,'message':"success",'data':data});
// },Time)
// }); // end of findall EntitiesData
// }); // end of findall masters datas
// },2000)
// });
// } catch(err) {
// res.status(500).send({'status':404,
// message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
// }); } // end of try catch
// }); // end of sync function
// };
exports.ReInitiateApi = (req, res) => {
try
{
const cin = req.body.cin;
const losid = req.body.losid;
const entityid = req.body.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){
console.log(lineItem_result)
//create financial table and entityfinyear table record here
lineItem_result.forEach((value, key)=>{
//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){
console.log(update_array_data)
// update mapped lineitem value here
//Probe42DataMappingHelper.lineItemUpdate(update_array_data);
});//end of lineItemUpdate helper call
});//end of line item foreach
setTimeout(() => {
res.status(200).send({'status':200,message: "success" ,'data': "No data" });
}, 5000);
});//end of lineItem filter from api response helper call
} // end of probe42 api responce success else condition
});//end of probe42 api call
}//try
catch (error)
{
}
}

View File

@ -8,7 +8,7 @@ module.exports = app => {
var router = require("express").Router();
router.post("/ReInitiateApi", financials.ReInitiateApi);
router.post("/refreshApi", financials.refreshApi);
/**
* @swagger
* /api/ConsolidatedSummary: