fin_summary:GWM
This commit is contained in:
parent
dc4c343ecd
commit
0042c574e0
@ -1,5 +1,5 @@
|
||||
|
||||
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods } = require('../models')
|
||||
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
// all master data list for dropdown
|
||||
@ -83,18 +83,17 @@ exports.MenuList = async (req, res) => {
|
||||
exports.FinantialsSummary = async (req, res) => {
|
||||
const id = req.query.entityid
|
||||
|
||||
Financials.findAll({where : { entity_id : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'DESC']] })
|
||||
Entityfinyears.findAll({where : { entityid : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'DESC']] })
|
||||
.then(data => {
|
||||
// console.log(data.length)
|
||||
if(data.length == 3)
|
||||
if(data.length >= 3)
|
||||
{
|
||||
const Year_1 = data[0].dataValues.fy
|
||||
const Year_2 = data[1].dataValues.fy
|
||||
const Year_3 = data[2].dataValues.fy
|
||||
const years_data = {'Y1':Year_1 , 'Y2':Year_2 , 'Y3':Year_3}
|
||||
//sequelize.query("Select a.entity_id,a.itemid,e.statement as statement_id ,e.section as section_id ,e.itemtext as items , a.value as fy_"+Year_1+" , b.value fy_"+Year_2+" , c.value fy_"+Year_3+" FROM financials a JOIN ( SELECT id,statement,section, itemtext FROM itemsmaster) e ON a.itemid = e.id JOIN ( SELECT entity_id, itemid, value, fy FROM financials WHERE fy = "+Year_3+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT entity_id, itemid, value, fy FROM financials WHERE fy = "+Year_2+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id)
|
||||
//sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,a.itemid,e.itemtext as items,a.value as fy_"+Year_1+",b.value fy_"+Year_2+",c.value fy_"+Year_3+" FROM financials a JOIN ( SELECT id, itemtext ,statement 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.statement = y.id JOIN ( SELECT entity_id, itemid, value, fy FROM financials WHERE fy = "+Year_3+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT entity_id, itemid, value, fy FROM financials WHERE fy = "+Year_2+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id+" order by x.id asc , y.id asc , a.itemid 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,a.st_type,f.statement_name as st_name,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.fy as Y3,c.id as Y3_id ,c.value Y3_value FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) f ON a.st_type = f.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 JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_3+" and is_active = 1 and entity_id = "+id+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_2+" and is_active = 1 and entity_id = "+id+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id+" and a.is_active = 1 order by x.id asc , y.id asc , a.itemid 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,a.st_type,f.statement_name as st_name,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) f ON a.st_type = f.id LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks ) g ON a.entity_id = g.entity_id and a.itemid = g.itemid 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 JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_3+" and is_active = 1 and entity_id = "+id+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_2+" and is_active = 1 and entity_id = "+id+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id+" and a.is_active = 1 order by x.id asc , y.id asc , a.itemid 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,a.fy as Y1,i.id as Y1_st_type_id,i.statement_name as Y1_st_type,a.id as Y1_id ,a.value as Y1_value ,b.fy as Y2,j.id as Y2_st_type_id,j.statement_name as Y2_st_type, b.id Y2_id ,b.value Y2_value ,c.fy as Y3,k.id as Y3_st_type_id,k.statement_name as Y3_st_type,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 LEFT JOIN ( SELECT id, statement_name FROM statement_type ) i ON a.st_type = i.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) j ON b.st_type = j.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) k ON c.st_type = k.id 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(result => {
|
||||
const arr = {"years" : years_data , "summary" : result }
|
||||
res.send({'status':200,'message':"success",'data':{"years" : years_data , "summary" : result } });
|
||||
|
||||
28
app/models/Entityfinyears.js
Normal file
28
app/models/Entityfinyears.js
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict'
|
||||
const { Model } = require('sequelize')
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
class Entityfinyears extends Model {
|
||||
|
||||
|
||||
}
|
||||
Entityfinyears.init(
|
||||
{
|
||||
losid: { type: DataTypes.STRING },
|
||||
entityid: { type: DataTypes.INTEGER },
|
||||
fy: { type: DataTypes.INTEGER },
|
||||
st_type: { type: DataTypes.INTEGER },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'entity_fin_years',
|
||||
modelName: 'Entityfinyears',
|
||||
createdAt: 'createdon',
|
||||
updatedAt: 'updatedon',
|
||||
|
||||
}
|
||||
)
|
||||
return Entityfinyears
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user