financialsSummary:GWM
This commit is contained in:
parent
8c406641a2
commit
c537fbf997
@ -1,6 +1,6 @@
|
|||||||
//const db = require("../models");
|
//const db = require("../models");
|
||||||
//const Entities = db.tutorials;
|
//const Entities = db.tutorials;
|
||||||
//const Op = db.Sequelize.Op;
|
const { Op } = require("sequelize");
|
||||||
|
|
||||||
const { sequelize, Entities , Financials , Statementsmaster ,Sectionsmaster , Subsectionsmaster } = require('../models')
|
const { sequelize, Entities , Financials , Statementsmaster ,Sectionsmaster , Subsectionsmaster } = require('../models')
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
@ -14,18 +14,21 @@ exports.MenuList = async (req, res) => {
|
|||||||
const losid = req.params.losid
|
const losid = req.params.losid
|
||||||
const MasterData = await Statementsmaster.findAll({
|
const MasterData = await Statementsmaster.findAll({
|
||||||
where :{is_active : 1} ,
|
where :{is_active : 1} ,
|
||||||
|
attributes: ['id', 'statement', 'is_active'],
|
||||||
include :[{
|
include :[{
|
||||||
association: 'sectionsmasterData' ,
|
association: 'sectionsmasterData' ,
|
||||||
where :{is_active : 1} ,
|
where :{is_active : 1} ,
|
||||||
|
attributes: ['id', 'section', 'is_active'],
|
||||||
include :[{
|
include :[{
|
||||||
association: 'subsectionsmasterData' ,
|
association: 'subsectionsmasterData' ,
|
||||||
//where :{is_active : 1}
|
//where :{is_active : 1} ,
|
||||||
}]
|
attributes: ['id', 'subsection', 'is_active'],
|
||||||
}]
|
}],
|
||||||
|
required :true
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
// const count = MasterData.length;
|
|
||||||
// console.log(count)
|
const EntitiesData = await Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname'] });
|
||||||
const EntitiesData = await Entities.findAll({where : { losid } });
|
|
||||||
let data = [];
|
let data = [];
|
||||||
EntitiesData.forEach((value, key)=>{
|
EntitiesData.forEach((value, key)=>{
|
||||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
|
obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
|
||||||
@ -57,13 +60,27 @@ exports.findAllEntities = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Retrieve all Statment from the database.
|
// FinantialsSummary
|
||||||
exports.StatmentList = (req, res) => {
|
exports.FinantialsSummary = async (req, res) => {
|
||||||
|
const id = req.params.id
|
||||||
Statementsmaster.findAll({include: 'sectionsmasterData' })
|
|
||||||
|
Financials.findAll({where : { entity_id : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'ASC']] })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
// console.log(data.length)
|
||||||
logMsg.info("Success :"(data));
|
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
|
||||||
|
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 => {
|
||||||
|
res.send({'status':200,'message':"success",'data':result});
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||||
|
});
|
||||||
|
} else { res.send({'status':404,'message':"failed",'data':"No data"}); }
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
res.status(500).send({'status':404,
|
res.status(500).send({'status':404,
|
||||||
@ -71,6 +88,9 @@ exports.StatmentList = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.test = (req, res) => {
|
exports.test = (req, res) => {
|
||||||
sequelize.query("select * from statementsmaster")
|
sequelize.query("select * from statementsmaster")
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|||||||
@ -430,19 +430,7 @@ exports.Deleteitem = (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.test = (req, res) => {
|
|
||||||
sequelize.query("select * from statementsmaster")
|
|
||||||
.then(data => {
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
logMsg.info("Success :"(data));
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
res.status(500).send({
|
|
||||||
message:
|
|
||||||
err.message || "Some error occurred while retrieving tutorials."
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = app => {
|
|||||||
// Retrieve all Tutorials
|
// Retrieve all Tutorials
|
||||||
router.get("/EntitiesList", financials.findAllEntities);
|
router.get("/EntitiesList", financials.findAllEntities);
|
||||||
// get statment master data
|
// get statment master data
|
||||||
router.get("/StatmentList", financials.StatmentList);
|
router.get("/FinantialsSummary/:id/", financials.FinantialsSummary);
|
||||||
// get statment master data
|
// get statment master data
|
||||||
router.get("/MenuList/:losid", financials.MenuList);
|
router.get("/MenuList/:losid", financials.MenuList);
|
||||||
|
|
||||||
@ -22,18 +22,18 @@ module.exports = app => {
|
|||||||
|
|
||||||
router.get("/SectionList", master.SectionList);
|
router.get("/SectionList", master.SectionList);
|
||||||
router.post("/Insertsection", master.Insertsection);
|
router.post("/Insertsection", master.Insertsection);
|
||||||
router.put("/Updatesection/:id", master.Updatesection);
|
router.put("/Updatesection/:id", master.Updatesection);
|
||||||
router.put("/Deletesection/:id", master.Deletesection);
|
router.put("/Deletesection/:id", master.Deletesection);
|
||||||
|
|
||||||
router.get("/SubsectionList", master.SubsectionList);
|
router.get("/SubsectionList", master.SubsectionList);
|
||||||
router.post("/Insertsubsection", master.Insertsubsection);
|
router.post("/Insertsubsection", master.Insertsubsection);
|
||||||
router.put("/Updatesubsection/:id", master.Updatesubsection);
|
router.put("/Updatesubsection/:id", master.Updatesubsection);
|
||||||
router.put("/Deletesubsection/:id", master.Deletesubsection);
|
router.put("/Deletesubsection/:id", master.Deletesubsection);
|
||||||
|
|
||||||
router.get("/ItemList", master.ItemList);
|
router.get("/ItemList", master.ItemList);
|
||||||
router.post("/Insertitem", master.Insertitem);
|
router.post("/Insertitem", master.Insertitem);
|
||||||
router.put("/Updateitem/:id", master.Updateitem);
|
router.put("/Updateitem/:id", master.Updateitem);
|
||||||
router.put("/Deleteitem/:id", master.Deleteitem);
|
router.put("/Deleteitem/:id", master.Deleteitem);
|
||||||
|
|
||||||
//sample
|
//sample
|
||||||
//router.put("/:id", tutorials.update);
|
//router.put("/:id", tutorials.update);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user