From 8f14e2d97662c512bd3e4cd27de47c1c949f6576 Mon Sep 17 00:00:00 2001 From: sriramv Date: Tue, 17 Aug 2021 10:50:00 +0530 Subject: [PATCH] finsummary:GWM --- app/controllers/financial.controller.js | 5 +++-- app/routes/routes.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 6cc2386..2f6065e 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -72,8 +72,9 @@ exports.FinantialsSummary = async (req, res) => { const Year_1 = data[0].dataValues.fy 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) - .then(result => { + //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 ") + .then(result => { res.send({'status':200,'message':"success",'data':result}); }).catch(err => { res.status(500).send({'status':404, diff --git a/app/routes/routes.js b/app/routes/routes.js index b3fd066..3d0d78f 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -15,8 +15,17 @@ module.exports = app => { */ // Retrieve all Tutorials router.get("/EntitiesList", financials.findAllEntities); + /** + * @openapi + * /FinantialsSummary/:id: + * get: + * description: Welcome to swagger-jsdoc! + * responses: + * 200: + * description: Returns a mysterious string. + */ // get statment master data - router.get("/FinantialsSummary/:id/", financials.FinantialsSummary); + router.get("/FinantialsSummary/:id", financials.FinantialsSummary); // get statment master data router.get("/MenuList/:losid", financials.MenuList);