fin_summary:GWM

This commit is contained in:
sriramv 2021-10-20 12:16:24 +05:30
parent fd41194aee
commit 4b7767b3c4
4 changed files with 144 additions and 63 deletions

View File

@ -2,6 +2,7 @@ const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster ,
const { logMsg } = require('../services/logger.js');
const financialControllerHelper = require('../services/financial.controller.helper.js');
const camundaHelper = require('../services/camunda.helper.js');
const Sync = require('sync');
// all master data list for dropdown
exports.MasterDatas = async (req, res) => {
await Statementsmaster.findAll({
@ -124,15 +125,30 @@ exports.FinantialsSummary = async (req, res) => {
if(Year_4 == null)
{
const three_years_data = {"losid": data[0][0].losid,"entityid": data[0][0].entityid,"Y1": data[0][0].Y1,"Y2": data[0][0].Y2,"Y3": data[0][0].Y3,"Y1_st_type_id":data[0][0].Y1_st_type_id,"Y1_st_type_name": data[0][0].Y1_st_type_name,"Y2_st_type_id":data[0][0].Y2_st_type_id,"Y2_st_type_name": data[0][0].Y2_st_type_name,"Y3_st_type_id": data[0][0].Y3_st_type_id,"Y3_st_type_name": data[0][0].Y3_st_type_name}
sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc")
sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,e.is_summary,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc")
.then(summary => {
// is_summary filter from fin_summary data
let is_summary_item_array = [];
const fin_summary = summary[0];
fin_summary.forEach((value, key)=>{
if(value.is_summary == 1)
{
obj_data = value;
is_summary_item_array.push(obj_data);
}
});
// get camunda status
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); }
res.send({'status':200,'message':"success",'data':{"years" : three_years_data ,"add_new_finyear_flag" : add_new_FY_flag , status:camunda_status, "summary" : summary } });
setTimeout(function()
{
res.send({'status':200,'message':"success",'data':{"years" : three_years_data ,"add_new_finyear_flag" : add_new_FY_flag , status:camunda_status,"summary" : is_summary_item_array, "fin_summary" : summary } });
}, 3000);
});
});
//res.send({'status':200,'message':"success",'data':{"years" : three_years_data ,"add_new_finyear_flag" : add_new_FY_flag, "summary" : result } });
@ -144,17 +160,32 @@ exports.FinantialsSummary = async (req, res) => {
else
{
const four_years_data = {"losid": data[0][0].losid,"entityid": data[0][0].entityid,"Y1": data[0][0].Y1,"Y2": data[0][0].Y2,"Y3": data[0][0].Y3,"Y4": data[0][0].Y4,"Y1_st_type_id":data[0][0].Y1_st_type_id,"Y1_st_type_name": data[0][0].Y1_st_type_name,"Y2_st_type_id":data[0][0].Y2_st_type_id,"Y2_st_type_name": data[0][0].Y2_st_type_name,"Y3_st_type_id": data[0][0].Y3_st_type_id,"Y3_st_type_name": data[0][0].Y3_st_type_name,"Y4_st_type_id":data[0][0].Y4_st_type_id,"Y4_st_type_name":data[0][0].Y4_st_type_name,"additional_year_type":data[0][0].additional_year_type}
sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value ,d.st_type as Y4_st_type,d.fy as Y4,d.id as Y4_id ,d.value Y4_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_4+" and entity_id ="+id+" and is_active = 1) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc")
sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,e.is_summary,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value ,d.st_type as Y4_st_type,d.fy as Y4,d.id as Y4_id ,d.value Y4_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_4+" and entity_id ="+id+" and is_active = 1) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc")
.then(summary => {
// is_summary filter from fin_summary data
let is_summary_item_array = [];
const fin_summary = summary[0];
fin_summary.forEach((value, key)=>{
if(value.is_summary == 1)
{
obj_data = value;
is_summary_item_array.push(obj_data);
}
});
// get camunda status
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); }
res.send({'status':200,'message':"success",'data':{"years" : four_years_data ,"add_new_finyear_flag" : add_new_FY_flag , status:camunda_status, "summary" : summary } });
setTimeout(function()
{
res.send({'status':200,'message':"success",'data':{"years" : four_years_data ,"add_new_finyear_flag" : add_new_FY_flag , status:camunda_status,"summary" : is_summary_item_array , "fin_summary" : summary } });
}, 3000);
});
});
});
//res.send({'status':200,'message':"success",'data':{"years" : four_years_data ,"add_new_finyear_flag" : add_new_FY_flag, "summary" : result } });
}).catch(err => {
res.status(500).send({'status':404,
@ -490,6 +521,36 @@ exports.ConsolidatedSummary = async (req, res) => {
};
// testing api's
exports.test = async (req, res) => {
const losid = req.query.losid;
try
@ -748,65 +809,15 @@ exports.camunda = async (req, res) => {
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' ] })
.then(EntitiesData => {
console.log("Start");
let promiseone = new Promise.resolve();
EntitiesData.forEach((value, key)=>{
promisetwo = promiseone.then(() => {
console.log(value.dataValues.process_instance_id);
}).then(()=>{console.log("End");});
})
});
promisetwo.then(()=>{ console.log("End");});
})
// const losid = "fb37c1e4-271e-11ec-a4f4-42010a800002";
// const cin = "test";
// const user = "test";
// var camunda_status;
// instancesid = "33f6a13d-272f-11ec-a4f4-42010a800002";
// const taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
// taskid.then(function(result){
// const formVariable = camundaHelper.financialsFormVariables(result);
// formVariable.then(function(form_result){ camunda_status = form_result });
// });
// setTimeout(function(){
// console.log(camunda_status);
// res.send(camunda_status);
// },5000);
//console.log(camunda_status);
// function one(){
// console.log("one")
// instancesid = "33f6a13d-272f-11ec-a4f4-42010a800002";
// taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
// return taskid;
// console.log(taskid);
// }
// one().then(function(taskid){ console.log(taskid); });
//let promise = Promise.resolve();
// promiseA = new Promise((resolve, reject) => {
// instancesid = "33f6a13d-272f-11ec-a4f4-42010a800002";
// taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
// taskid.then(function(taskid){
// console.log(taskid);
// })
// });
// setTimeout(function(){
// promiseB = promiseA.then(function(taskid){
// console.log(taskid);
// camunda_status = camundaHelper.financialsFormVariables(taskid);
// return camunda_status;
// })
// },2000);
// setTimeout(function(){
// promiseB.then(function(camunda_status){
// Promise.resolve(res.send({'status':200,'camunda': camunda_status }))
// })
// },2000);
} catch(err) {
res.status(500).send({'status':404,
@ -814,3 +825,56 @@ exports.camunda = async (req, res) => {
}); }
};
exports.syncTest = async (req, res) => {
const losid = req.query.losid;
try
{
} catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }
};
exports.testthree = async (req, res) => {
Sync(function()
{
try
{
const losid = req.query.losid;
console.log("start");
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' ] })
.then(EntitiesData => {
Sync(function(){
EntitiesData.forEach((value, key)=>{
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);
console.log(formVariableResult);
});
});
});
}); // end of EntitiesData foreach
console.log("end");
});
} catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }
});// end of sync
};

View File

@ -8,7 +8,8 @@ module.exports = app => {
var router = require("express").Router();
router.get("/camunda", financials.camunda);
// router.get("/camunda", financials.camunda);
// router.get("/test", financials.test);
/**
* @swagger

19
package-lock.json generated
View File

@ -1176,8 +1176,7 @@
"detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=",
"optional": true
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
},
"doctrine": {
"version": "3.0.0",
@ -1362,6 +1361,14 @@
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.1.tgz",
"integrity": "sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q=="
},
"fibers": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.0.tgz",
"integrity": "sha512-UpGv/YAZp7mhKHxDvC1tColrroGRX90sSvh8RMZV9leo+e5+EkRVgCEZPlmXeo3BUNQTZxUaVdLskq1Q2FyCPg==",
"requires": {
"detect-libc": "^1.0.3"
}
},
"file-stream-rotator": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.5.7.tgz",
@ -3029,6 +3036,14 @@
"swagger-ui-dist": "^3.18.1"
}
},
"sync": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/sync/-/sync-0.2.5.tgz",
"integrity": "sha1-ORC7m2ar7lZULi5w8M5UkDElLfY=",
"requires": {
"fibers": ">=0.6"
}
},
"tar-fs": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",

View File

@ -20,6 +20,7 @@
"sequelize": "^6.6.5",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.1.6",
"sync": "^0.2.5",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.5"
},