merge:GWM
This commit is contained in:
commit
2499a93228
@ -36,54 +36,71 @@ function giveresponse(value) {
|
|||||||
// menu list api
|
// menu list api
|
||||||
function MenuList (value,giveresponse) {
|
function MenuList (value,giveresponse) {
|
||||||
|
|
||||||
console.log(value)
|
try {
|
||||||
console.log('3')
|
const losid = req.query.losid
|
||||||
const losid = value.losid
|
// call starter function here
|
||||||
try {
|
|
||||||
|
|
||||||
if(value.status == 200)
|
req_obj ={"losid":losid}
|
||||||
{
|
|
||||||
Statementsmaster.findAll({
|
|
||||||
where :{is_active : 1} ,
|
|
||||||
attributes: ['id', 'statement', 'is_active'],
|
|
||||||
include :[{
|
|
||||||
association: 'sectionsmasterData' ,
|
|
||||||
where :{is_active : 1} ,
|
|
||||||
attributes: ['id', 'section', 'is_active'],
|
|
||||||
include :[{
|
|
||||||
association: 'subsectionsmasterData' ,
|
|
||||||
where :{is_active : 1} ,
|
|
||||||
attributes: ['id', 'subsection','itemtext', 'is_active'],
|
|
||||||
required :false
|
|
||||||
}],
|
|
||||||
required :false
|
|
||||||
}],
|
|
||||||
required :false
|
|
||||||
})
|
|
||||||
.then(MasterData => {
|
|
||||||
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
|
|
||||||
.then(EntitiesData => {
|
|
||||||
let data = [];
|
|
||||||
EntitiesData.forEach((value, key)=>{
|
|
||||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
|
||||||
|
|
||||||
data.push(obj_data);
|
starter_response = starter(req_obj);
|
||||||
}) // end of EntitiesData foreach
|
|
||||||
console.log(data)
|
|
||||||
console.log('4')
|
|
||||||
logMsg.info("MenuList api working");
|
|
||||||
|
|
||||||
giveresponse({'status':200,'message':"success",'data':data});
|
setTimeout(()=>{
|
||||||
}); // end of findall EntitiesData
|
if(starter_response.status == 200)
|
||||||
}); // end of findall masters datas
|
{
|
||||||
} // end of starter function if condition
|
Statementsmaster.findAll({
|
||||||
//return {'status':200,'message':"success",'data':data};
|
where :{is_active : 1} ,
|
||||||
}
|
attributes: ['id', 'statement', 'is_active'],
|
||||||
|
include :[{
|
||||||
|
association: 'sectionsmasterData' ,
|
||||||
|
where :{is_active : 1} ,
|
||||||
|
attributes: ['id', 'section', 'is_active'],
|
||||||
|
include :[{
|
||||||
|
association: 'subsectionsmasterData' ,
|
||||||
|
where :{is_active : 1} ,
|
||||||
|
attributes: ['id', 'subsection','itemtext', 'is_active'],
|
||||||
|
required :false
|
||||||
|
}],
|
||||||
|
required :false
|
||||||
|
}],
|
||||||
|
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 data = [];
|
||||||
|
EntitiesData.forEach((value, key)=>{
|
||||||
|
|
||||||
catch (err) {
|
instancesid = value.dataValues.process_instance_id;
|
||||||
console.log(err)
|
taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
|
||||||
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
taskid.then(function(result){
|
||||||
}
|
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});
|
||||||
|
},5000)
|
||||||
|
}); // end of findall EntitiesData
|
||||||
|
}); // end of findall masters datas
|
||||||
|
} // end of starter function if condition
|
||||||
|
},5000)
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,79 +108,96 @@ function MenuList (value,giveresponse) {
|
|||||||
//testing
|
//testing
|
||||||
function starter(value, MenuList)
|
function starter(value, MenuList)
|
||||||
{
|
{
|
||||||
const losid = value
|
|
||||||
console.log(value)
|
|
||||||
console.log('2')
|
|
||||||
|
|
||||||
//pro 42 api call using losid
|
const losid = req.losid;
|
||||||
const Pro42Data = [
|
try
|
||||||
{"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 => {
|
|
||||||
|
|
||||||
//create Entityfinyears data
|
//pro 42 api call using losid
|
||||||
const Y1 = new Date().getFullYear();
|
const Pro42Data = [
|
||||||
const Y2 = Y1-1;
|
{"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
|
||||||
const Y3 = Y2-1;
|
{"losid":losid,"pan":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
|
||||||
Entityfinyears.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"Y1":Y1,"Y2":Y2,"Y3":Y3,"Y1_st_type":2,"Y2_st_type":2,"Y3_st_type":2})
|
];
|
||||||
.then(Entityfinyearsdata => {
|
// 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 => {
|
||||||
|
|
||||||
//create financials data based on Entityfinyears
|
//process instance Id update
|
||||||
let fin_years_array = [];
|
const primeryId = Entitydata.dataValues.id;
|
||||||
fin_years_array = [
|
const user = "SMC";
|
||||||
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y1,"st_type":Entityfinyearsdata.dataValues.Y1_st_type},
|
processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
|
||||||
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y2,"st_type":Entityfinyearsdata.dataValues.Y2_st_type},
|
processInstanceId.then(function(InstanceId){
|
||||||
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y3,"st_type":Entityfinyearsdata.dataValues.Y3_st_type}
|
Entities.update({ "process_instance_id":InstanceId },{ where: { id: primeryId }});
|
||||||
];
|
});
|
||||||
|
|
||||||
// create skeletion
|
//create Entityfinyears data
|
||||||
fin_years_array.forEach((value, key)=>{
|
const Y1 = new Date().getFullYear();
|
||||||
const entity_id = value.entity_id;
|
const Y2 = Y1-1;
|
||||||
const fy = value.fy;
|
const Y3 = Y2-1;
|
||||||
const st_type = value.st_type;
|
Entityfinyears.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"Y1":Y1,"Y2":Y2,"Y3":Y3,"Y1_st_type":2,"Y2_st_type":2,"Y3_st_type":2})
|
||||||
|
.then(Entityfinyearsdata => {
|
||||||
|
|
||||||
// generate financials data array
|
//create financials data based on Entityfinyears
|
||||||
let fin_data_array = [];
|
let fin_years_array = [];
|
||||||
for (let i = 1; i < 120; i++)
|
fin_years_array = [
|
||||||
{
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y1,"st_type":Entityfinyearsdata.dataValues.Y1_st_type},
|
||||||
fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":fy,"value":0,"is_active":1,"createdby":4}
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y2,"st_type":Entityfinyearsdata.dataValues.Y2_st_type},
|
||||||
fin_data_array.push(fin_data_obj);
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y3,"st_type":Entityfinyearsdata.dataValues.Y3_st_type}
|
||||||
}
|
];
|
||||||
//bulk financials data create
|
|
||||||
Financials.bulkCreate(fin_data_array);
|
// create skeletion
|
||||||
//console.log(fin_data_array)
|
fin_years_array.forEach((value, key)=>{
|
||||||
});
|
const entity_id = value.entity_id;
|
||||||
|
const fy = value.fy;
|
||||||
|
const st_type = value.st_type;
|
||||||
|
|
||||||
|
// generate financials data array
|
||||||
|
let fin_data_array = [];
|
||||||
|
for (let i = 1; i < 120; i++)
|
||||||
|
{
|
||||||
|
fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":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);
|
||||||
|
//console.log(fin_data_array)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
res.status(404).send({'status':404,
|
res.status(404).send({'status':404,
|
||||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
}); // end of entity fin year table data insert
|
}); // end of entity fin year table data insert
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
res.status(404).send({'status':404,
|
res.status(404).send({'status':404,
|
||||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
}); // end of entity insert
|
}); // end of entity insert
|
||||||
|
|
||||||
} //end of else condition
|
} //end of else condition
|
||||||
|
|
||||||
}); // end of (losid,pan,cin) combination checking entity data exist or not
|
}); // end of (losid,pan,cin) combination checking entity data exist or not
|
||||||
|
|
||||||
|
}); // end of pro42 data foreach
|
||||||
|
|
||||||
|
MenuList({'losid':losid,'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
|
||||||
|
|
||||||
}); // end of pro42 data foreach
|
|
||||||
|
|
||||||
MenuList({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
|
||||||
|
|
||||||
|
|
||||||
//end of try catch
|
//end of try catch
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user