surya 2021-08-23 17:29:38 +05:30
commit e2d2114a77

View File

@ -87,7 +87,8 @@ exports.FinantialsSummary = async (req, res) => {
const Year_2 = data[1].dataValues.fy
const Year_3 = data[2].dataValues.fy
//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,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,a.itemid,e.itemtext as items,e.formula,e.is_calculated,f.statement_name as st_type,a.id as id_"+Year_1+" ,a.value as fy_"+Year_1+" , b.id id_"+Year_2+" ,b.value fy_"+Year_2+" ,c.id as id_"+Year_3+" ,c.value fy_"+Year_3+" FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id 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 JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_3+" and is_active = 1) 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) 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 ")
.then(result => {
res.send({'status':200,'message':"success",'data':result});
}).catch(err => {