GWM
This commit is contained in:
parent
b7b9c59aaf
commit
1df1809fd6
@ -1,4 +1,4 @@
|
|||||||
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models')
|
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears , Entityfinyear } = require('../models')
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
const financialControllerHelper = require('../services/financial.controller.helper.js');
|
const financialControllerHelper = require('../services/financial.controller.helper.js');
|
||||||
const camundaHelper = require('../services/camunda.helper.js');
|
const camundaHelper = require('../services/camunda.helper.js');
|
||||||
@ -830,22 +830,44 @@ promise.then(() => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.camunda = async (req, res) => {
|
exports.demo = (req, res) => {
|
||||||
const losid = "MW112233";
|
const losid = "MW112233";
|
||||||
|
const entityid = 7;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const myPromise = new Promise((resolve, reject) => {
|
|
||||||
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' ] })
|
Entityfinyear.findAll({where : { losid , entityid } , attributes: [ 'id', 'losid' , 'entityid' , 'FY' , 'st_type' , 'additional_year_type' ] , order: [['FY', 'DESC']] })
|
||||||
.then(EntitiesData => {
|
.then(EntityfinyearData => {
|
||||||
console.log("Start");
|
const year_1 = EntityfinyearData[0].FY;
|
||||||
EntitiesData.forEach(value => {
|
var select_items = "";
|
||||||
console.log(value.dataValues.process_instance_id);
|
var sub_query = "";
|
||||||
});
|
EntityfinyearData.forEach((value, key)=>{
|
||||||
})
|
const words = ['','one','two','three','four', 'five','six','seven','eight','nine','ten'];
|
||||||
|
if(key != 0)
|
||||||
|
{
|
||||||
|
console.log(key+"--"+value.FY);
|
||||||
|
key_addition = key + 1;
|
||||||
|
alisename = words[key_addition];
|
||||||
|
select_items += ","+alisename+".st_type as Y"+key_addition+"_st_type,"+alisename+".fy as Y"+key_addition+","+alisename+".id Y"+key_addition+"_id ,"+alisename+".value Y"+key_addition+"_value";
|
||||||
|
sub_query += "LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = '"+value.FY+"' and entity_id = "+entityid+" and is_active = 1) "+alisename+" ON a.entity_id = "+alisename+".entity_id and a.itemid = "+alisename+".itemid ";
|
||||||
|
}
|
||||||
|
}); // end of foreach
|
||||||
|
var query = "Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,w.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,w.itemtext as items,w.formula,w.is_calculated,w.is_summary,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value "+ select_items +",v.remarks , v.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) v ON a.entity_id = v.entity_id and a.itemid = v.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary FROM itemsmaster ) w ON a.itemid = w.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON w.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON w.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON w.subsection = z.id "+ sub_query +"WHERE a.fy = '"+year_1+"' and a.entity_id = "+entityid+" and a.is_active = 1 order by w.statement asc , w.section asc , w.subsection asc";
|
||||||
|
setTimeout(function(){
|
||||||
|
console.log(query);
|
||||||
|
sequelize.query(query)
|
||||||
|
.then(summary => {
|
||||||
|
|
||||||
|
res.send({'status':200,'message':"success",'fin_summary' : summary } );
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||||
});
|
});
|
||||||
|
|
||||||
myPromise.then( console.log("End"))
|
}, 1000);// end of set time out
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
res.status(500).send({'status':404,
|
res.status(500).send({'status':404,
|
||||||
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
@ -878,6 +900,7 @@ Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin
|
|||||||
.then(EntitiesData => {
|
.then(EntitiesData => {
|
||||||
Sync(function(){
|
Sync(function(){
|
||||||
EntitiesData.forEach((value, key)=>{
|
EntitiesData.forEach((value, key)=>{
|
||||||
|
console.log(key);
|
||||||
instancesid = value.dataValues.process_instance_id;
|
instancesid = value.dataValues.process_instance_id;
|
||||||
taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
|
taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
|
||||||
taskid.then(function(result){
|
taskid.then(function(result){
|
||||||
@ -887,8 +910,8 @@ Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin
|
|||||||
console.log(formVariableResult);
|
console.log(formVariableResult);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}); // end of EntitiesData foreach
|
}); // end of EntitiesData foreach
|
||||||
|
}); // end of sync function
|
||||||
|
|
||||||
console.log("end");
|
console.log("end");
|
||||||
|
|
||||||
|
|||||||
@ -34,12 +34,16 @@ function giveresponse(value) {
|
|||||||
// menu list api
|
// menu list api
|
||||||
function MenuList (value,giveresponse) {
|
function MenuList (value,giveresponse) {
|
||||||
|
|
||||||
console.log(value)
|
|
||||||
console.log('3')
|
|
||||||
const losid = value.losid
|
|
||||||
try {
|
try {
|
||||||
|
const losid = req.query.losid
|
||||||
|
// call starter function here
|
||||||
|
|
||||||
if(value.status == 200)
|
req_obj ={"losid":losid}
|
||||||
|
|
||||||
|
starter_response = starter(req_obj);
|
||||||
|
|
||||||
|
setTimeout(()=>{
|
||||||
|
if(starter_response.status == 200)
|
||||||
{
|
{
|
||||||
Statementsmaster.findAll({
|
Statementsmaster.findAll({
|
||||||
where :{is_active : 1} ,
|
where :{is_active : 1} ,
|
||||||
@ -59,26 +63,39 @@ function MenuList (value,giveresponse) {
|
|||||||
required :false
|
required :false
|
||||||
})
|
})
|
||||||
.then(MasterData => {
|
.then(MasterData => {
|
||||||
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
|
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' ] })
|
||||||
.then(EntitiesData => {
|
.then(EntitiesData => {
|
||||||
let data = [];
|
let data = [];
|
||||||
EntitiesData.forEach((value, key)=>{
|
EntitiesData.forEach((value, key)=>{
|
||||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
|
||||||
|
|
||||||
|
instancesid = value.dataValues.process_instance_id;
|
||||||
|
taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
|
||||||
|
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);
|
data.push(obj_data);
|
||||||
}) // end of EntitiesData foreach
|
});
|
||||||
console.log(data)
|
});
|
||||||
console.log('4')
|
// obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
||||||
logMsg.info("MenuList api working");
|
// data.push(obj_data);
|
||||||
|
|
||||||
giveresponse({'status':200,'message':"success",'data':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 EntitiesData
|
||||||
}); // end of findall masters datas
|
}); // end of findall masters datas
|
||||||
} // end of starter function if condition
|
} // end of starter function if condition
|
||||||
//return {'status':200,'message':"success",'data':data};
|
},5000)
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch (err) {
|
|
||||||
console.log(err)
|
console.log(err)
|
||||||
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
||||||
}
|
}
|
||||||
@ -89,9 +106,10 @@ function MenuList (value,giveresponse) {
|
|||||||
//testing
|
//testing
|
||||||
function starter(value, MenuList)
|
function starter(value, MenuList)
|
||||||
{
|
{
|
||||||
const losid = value
|
|
||||||
console.log(value)
|
const losid = req.losid;
|
||||||
console.log('2')
|
try
|
||||||
|
{
|
||||||
|
|
||||||
//pro 42 api call using losid
|
//pro 42 api call using losid
|
||||||
const Pro42Data = [
|
const Pro42Data = [
|
||||||
@ -111,6 +129,14 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
|
|||||||
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})
|
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 => {
|
.then(Entitydata => {
|
||||||
|
|
||||||
|
//process instance Id update
|
||||||
|
const primeryId = 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: primeryId }});
|
||||||
|
});
|
||||||
|
|
||||||
//create Entityfinyears data
|
//create Entityfinyears data
|
||||||
const Y1 = new Date().getFullYear();
|
const Y1 = new Date().getFullYear();
|
||||||
const Y2 = Y1-1;
|
const Y2 = Y1-1;
|
||||||
@ -138,7 +164,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
|
|||||||
{
|
{
|
||||||
fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":fy,"value":0,"is_active":1,"createdby":4}
|
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);
|
fin_data_array.push(fin_data_obj);
|
||||||
}
|
} //console.log("------"+entity_id +"---"+ fy)
|
||||||
//bulk financials data create
|
//bulk financials data create
|
||||||
Financials.bulkCreate(fin_data_array);
|
Financials.bulkCreate(fin_data_array);
|
||||||
//console.log(fin_data_array)
|
//console.log(fin_data_array)
|
||||||
@ -164,6 +190,14 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
|
|||||||
MenuList({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
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 try catch
|
//end of try catch
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
29
app/models/Entityfinyear.js
Normal file
29
app/models/Entityfinyear.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Entityfinyear extends Model {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Entityfinyear.init(
|
||||||
|
{
|
||||||
|
losid: { type: DataTypes.STRING },
|
||||||
|
entityid: { type: DataTypes.INTEGER },
|
||||||
|
FY: { type: DataTypes.INTEGER },
|
||||||
|
st_type: { type: DataTypes.INTEGER },
|
||||||
|
additional_year_type: { type: DataTypes.INTEGER },
|
||||||
|
createdby: { type: DataTypes.INTEGER },
|
||||||
|
updatedby: { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'entity_fin_year',
|
||||||
|
modelName: 'Entityfinyear',
|
||||||
|
createdAt: 'createdon',
|
||||||
|
updatedAt: 'updatedon',
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return Entityfinyear
|
||||||
|
}
|
||||||
@ -8,8 +8,8 @@ module.exports = app => {
|
|||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
// router.get("/camunda", financials.camunda);
|
router.get("/demo", financials.demo);
|
||||||
// router.get("/test", financials.test);
|
router.get("/testthree", financials.testthree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user