Surya:statement master crud apis & models changes
This commit is contained in:
commit
206b713bbb
@ -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,16 +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 EntitiesData = await Entities.findAll({where : { losid } });
|
|
||||||
|
const EntitiesData = await Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname'] });
|
||||||
let data = [];
|
let data = [];
|
||||||
EntitiesData.forEach((value, key)=>{
|
EntitiesData.forEach((value, key)=>{
|
||||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
|
obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
|
||||||
@ -55,13 +60,27 @@ exports.findAllEntities = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Retrieve all Entities 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,
|
||||||
@ -69,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."
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,11 +4,24 @@ module.exports = app => {
|
|||||||
const master = require("../controllers/master.controller.js");
|
const master = require("../controllers/master.controller.js");
|
||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
// Retrieve all Entites
|
// Retrieve all Entites
|
||||||
|
=======
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /api/EntitiesList:
|
||||||
|
* get:
|
||||||
|
* description: Welcome to swagger-jsdoc!
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Returns a mysterious string.
|
||||||
|
*/
|
||||||
|
// Retrieve all Tutorials
|
||||||
|
>>>>>>> 6d54380f49bd9aa3c3e623eccdd3eb6bb98da170
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
399
package-lock.json
generated
399
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,10 +15,14 @@
|
|||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"mssql": "^7.2.0",
|
"mssql": "^7.2.0",
|
||||||
"nodemon": "^2.0.12",
|
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"sequelize": "^6.6.5",
|
"sequelize": "^6.6.5",
|
||||||
|
"swagger-jsdoc": "^6.1.0",
|
||||||
|
"swagger-ui-express": "^4.1.6",
|
||||||
"winston": "^3.3.3",
|
"winston": "^3.3.3",
|
||||||
"winston-daily-rotate-file": "^4.5.5"
|
"winston-daily-rotate-file": "^4.5.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^2.0.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
server.js
38
server.js
@ -1,12 +1,46 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use(express.json())
|
|
||||||
|
const swaggerJsdoc = require('swagger-jsdoc');
|
||||||
|
const swaggerUi = require('swagger-ui-express');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
definition: {
|
||||||
|
openapi: '3.0.0',
|
||||||
|
info: {
|
||||||
|
title: 'Smc_cet_financials',
|
||||||
|
version: '1.0.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
apis: ['./app/routes/routes.js'], // files containing annotations as above
|
||||||
|
};
|
||||||
|
|
||||||
|
const swaggerDocument = swaggerJsdoc(options);
|
||||||
|
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /:
|
||||||
|
* get:
|
||||||
|
* description: Welcome to swagger-jsdoc!
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Returns a mysterious string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
res.json({ message: "Welcome to the application." });
|
res.json({ message: "Welcome to the application." });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use(express.json())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require("./app/routes/routes.js")(app);
|
require("./app/routes/routes.js")(app);
|
||||||
|
|
||||||
const PORT_NUMBER = process.env.SERVER_PORT
|
const PORT_NUMBER = process.env.SERVER_PORT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user