gopi:log
This commit is contained in:
commit
4101400533
@ -1,8 +1,8 @@
|
||||
//const db = require("../models");
|
||||
//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 , Brokenperiods } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
|
||||
@ -14,18 +14,24 @@ exports.MenuList = async (req, res) => {
|
||||
const losid = req.params.losid
|
||||
const MasterData = await Statementsmaster.findAll({
|
||||
where :{is_active : 1} ,
|
||||
attributes: ['id', 'statement', 'is_active'],
|
||||
include :[{
|
||||
association: 'sectionsmasterData' ,
|
||||
where :{is_active : 1} ,
|
||||
attributes: ['id', 'section', 'is_active'],
|
||||
include :[{
|
||||
association: 'subsectionsmasterData' ,
|
||||
//where :{is_active : 1}
|
||||
}]
|
||||
}]
|
||||
where :{is_active : 1} ,
|
||||
attributes: ['id', 'subsection', 'is_active'],
|
||||
required :false
|
||||
}],
|
||||
required :false
|
||||
}],
|
||||
required :false
|
||||
|
||||
});
|
||||
// const count = MasterData.length;
|
||||
// console.log(count)
|
||||
const EntitiesData = await Entities.findAll({where : { losid } });
|
||||
|
||||
const EntitiesData = await Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname'] });
|
||||
let data = [];
|
||||
EntitiesData.forEach((value, key)=>{
|
||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData}
|
||||
@ -40,30 +46,29 @@ exports.MenuList = async (req, res) => {
|
||||
};
|
||||
|
||||
|
||||
// Retrieve all Entities from the database.
|
||||
exports.findAllEntities = (req, res) => {
|
||||
|
||||
Entities.findAll()
|
||||
.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."
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Retrieve all Statment from the database.
|
||||
exports.StatmentList = (req, res) => {
|
||||
|
||||
Statementsmaster.findAll({include: 'sectionsmasterData' })
|
||||
// FinantialsSummary
|
||||
exports.FinantialsSummary = async (req, res) => {
|
||||
const id = req.params.id
|
||||
|
||||
Financials.findAll({where : { entity_id : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'ASC']] })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
// console.log(data.length)
|
||||
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)
|
||||
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,
|
||||
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||
});
|
||||
} else { res.send({'status':404,'message':"failed",'data':"No data"}); }
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
@ -71,19 +76,73 @@ exports.StatmentList = (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
exports.test = (req, res) => {
|
||||
sequelize.query("select * from statementsmaster")
|
||||
// Broken period list api
|
||||
exports.BrokenPeriodsList = (req, res) => {
|
||||
const entityid = req.params.entityid
|
||||
Brokenperiods.findAll({where : { entity_id : entityid } })
|
||||
.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."
|
||||
});
|
||||
res.status(404).send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
// Broken period Insert OR Update
|
||||
exports.BrokenPeriods = (req, res) => {
|
||||
const obj = req.body
|
||||
if (obj.hasOwnProperty("id"))
|
||||
{
|
||||
// update broken periods
|
||||
const Id = req.body.id
|
||||
Brokenperiods.update( {
|
||||
entity_id: req.body.entity_id,
|
||||
from: req.body.from,
|
||||
to: req.body.to,
|
||||
months: req.body.months,
|
||||
cy: req.body.cy,
|
||||
py: req.body.py,
|
||||
variation: req.body.variation,
|
||||
updatedby: req.body.updatedby,
|
||||
} , { where: { id: Id } })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(404).send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// create broken period
|
||||
Brokenperiods.create({
|
||||
entity_id: req.body.entity_id,
|
||||
from: req.body.from,
|
||||
to: req.body.to,
|
||||
months: req.body.months,
|
||||
cy: req.body.cy,
|
||||
py: req.body.py,
|
||||
variation: req.body.variation,
|
||||
createdby: req.body.createdby,
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(404).send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3,24 +3,22 @@
|
||||
//const Op = db.Sequelize.Op;
|
||||
|
||||
const { sequelize, Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster } = require('../models')
|
||||
|
||||
const { logMsg } = require('../services/logger');
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
|
||||
//statementmaster
|
||||
|
||||
// Retrieve all statementmaster from the database.
|
||||
exports.StatmentList = (req, res) => {
|
||||
|
||||
// Retrieve all statements from the database.
|
||||
exports.StatementsList = (req, res) => {
|
||||
|
||||
Statementsmaster.findAll({where : { is_active : 1 } })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
@ -36,35 +34,16 @@ exports.Insertstatement = (req, res) => {
|
||||
|
||||
// Save Tutorial in the database
|
||||
Statementsmaster.create(statement)
|
||||
.then(data => {
|
||||
res.send(data);
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message:
|
||||
err.message || "Some error occurred while creating the statement."
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
// Post a statement
|
||||
// insert datas into statementmaster table.
|
||||
// exports.Insertstatement = (req, res) => {
|
||||
|
||||
// Statementsmaster.create({
|
||||
// statement: req.body.statement,
|
||||
// is_active: req.body.is_active,
|
||||
// createdby: req.body.createdby,
|
||||
// updatedby: req.body.updatedby,
|
||||
// })
|
||||
// .then(data => {
|
||||
// res.send({'status':200,'message':"success",'data':data});
|
||||
// logMsg.info("Success :"(data));
|
||||
// })
|
||||
// .catch(err => {
|
||||
// res.status(500).send({'status':404,
|
||||
// message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
|
||||
// });
|
||||
// };
|
||||
|
||||
// updates datas into statementmaster table.
|
||||
exports.Updatestatement = (req, res) => {
|
||||
@ -73,21 +52,14 @@ exports.Updatestatement = (req, res) => {
|
||||
Statementsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "statement was updated successfully."
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot update statement with id=${id}. Maybe statement was not found or req.body is empty!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Error updating statement with id=" + id
|
||||
});
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -98,22 +70,15 @@ exports.Deletestatement = (req, res) => {
|
||||
Statementsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "statement was deleted successfully!"
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete statement with id=${id}. Maybe statement was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Could not delete statement with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -128,7 +93,7 @@ exports.SectionList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving sections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -145,15 +110,15 @@ exports.Insertsection = (req, res) => {
|
||||
|
||||
// Save section in the database
|
||||
Sectionsmaster.create(section)
|
||||
.then(data => {
|
||||
res.send(data);
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message:
|
||||
err.message || "Some error occurred while creating the section."
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging sectino." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updatesection = (req, res) => {
|
||||
@ -162,22 +127,15 @@ exports.Updatesection = (req, res) => {
|
||||
Sectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "section was updated successfully."
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot update section with id=${id}. Maybe section was not found or req.body is empty!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Error updating section with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -187,22 +145,17 @@ exports.Deletesection = (req, res) => {
|
||||
Sectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "section was deleted successfully!"
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete section with id=${id}. Maybe section was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Could not delete section with id=" + id
|
||||
});
|
||||
});
|
||||
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -217,7 +170,7 @@ exports.SubsectionList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving subsections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -235,15 +188,15 @@ exports.Insertsubsection = (req, res) => {
|
||||
|
||||
// Save Tutorial in the database
|
||||
Subsectionsmaster.create(subsection)
|
||||
.then(data => {
|
||||
res.send(data);
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message:
|
||||
err.message || "Some error occurred while creating the subsection."
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging subsection." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updatesubsection = (req, res) => {
|
||||
@ -252,22 +205,16 @@ exports.Updatesubsection = (req, res) => {
|
||||
Subsectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "subsection was updated successfully."
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot update subsection with id=${id}. Maybe subsection was not found or req.body is empty!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Error updating subsection with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -277,22 +224,15 @@ exports.Deletesubsection = (req, res) => {
|
||||
Subsectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "subsection was deleted successfully!"
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete subsection with id=${id}. Maybe subsection was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Could not delete subsection with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -306,7 +246,7 @@ exports.ItemList = (req, res) => {
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
@ -330,15 +270,15 @@ exports.Insertitem = (req, res) => {
|
||||
|
||||
// Save Tutorial in the database
|
||||
Itemsmaster.create(item)
|
||||
.then(data => {
|
||||
res.send(data);
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message:
|
||||
err.message || "Some error occurred while creating the item."
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging items." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updateitem = (req, res) => {
|
||||
@ -347,22 +287,15 @@ exports.Updateitem = (req, res) => {
|
||||
Itemsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "item was updated successfully."
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot update item with id=${id}. Maybe item was not found or req.body is empty!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Error updating item with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
@ -372,22 +305,15 @@ exports.Deleteitem = (req, res) => {
|
||||
Itemsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(num => {
|
||||
if (num == 1) {
|
||||
res.send({
|
||||
message: "item was deleted successfully!"
|
||||
});
|
||||
} else {
|
||||
res.send({
|
||||
message: `Cannot delete item with id=${id}. Maybe statement was not found!`
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
message: "Could not delete item with id=" + id
|
||||
});
|
||||
});
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -432,19 +358,371 @@ exports.Deleteitem = (req, res) => {
|
||||
|
||||
|
||||
|
||||
exports.test = (req, res) => {
|
||||
sequelize.query("select * from statementsmaster")
|
||||
|
||||
|
||||
|
||||
|
||||
//const db = require("../models");
|
||||
//const Entities = db.tutorials;
|
||||
//const Op = db.Sequelize.Op;
|
||||
|
||||
const { sequelize, Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster } = require('../models')
|
||||
const { logMsg } = require('../services/logger.js');
|
||||
|
||||
|
||||
//statementmaster
|
||||
|
||||
// Retrieve all statements from the database.
|
||||
exports.StatementsList = (req, res) => {
|
||||
|
||||
Statementsmaster.findAll({where : { is_active : 1 } })
|
||||
.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."
|
||||
});
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports.Insertstatement = (req, res) => {
|
||||
// Create a statement
|
||||
const statement = {
|
||||
statement: req.body.statement,
|
||||
is_active: req.body.is_active,
|
||||
createdby: req.body.createdby,
|
||||
updatedby: req.body.updatedby,
|
||||
};
|
||||
|
||||
// Save Tutorial in the database
|
||||
Statementsmaster.create(statement)
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// updates datas into statementmaster table.
|
||||
exports.Updatestatement = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Statementsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
exports.Deletestatement = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Statementsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
//Sectionsmaster
|
||||
|
||||
// Retrieve all Sectionsmaster from the database.
|
||||
exports.SectionList = (req, res) => {
|
||||
|
||||
Sectionsmaster.findAll({where : { is_active : 1 } })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving sections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
exports.Insertsection = (req, res) => {
|
||||
// Create a section
|
||||
const section = {
|
||||
statement: req.body.statement,
|
||||
section: req.body.section,
|
||||
is_active: req.body.is_active,
|
||||
createdby: req.body.createdby,
|
||||
updatedby: req.body.updatedby,
|
||||
};
|
||||
|
||||
// Save section in the database
|
||||
Sectionsmaster.create(section)
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging sectino." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updatesection = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Sectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
exports.Deletesection = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Sectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
//Subsectionsmaster
|
||||
// Retrieve all Subsectionsmaster from the database.
|
||||
exports.SubsectionList = (req, res) => {
|
||||
|
||||
Subsectionsmaster.findAll({where : { is_active : 1 } })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving subsections." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
exports.Insertsubsection = (req, res) => {
|
||||
// Create a statement
|
||||
const subsection = {
|
||||
section: req.body.section,
|
||||
subsection: req.body.subsection,
|
||||
itemtext: req.body.itemtext,
|
||||
is_active: req.body.is_active,
|
||||
createdby: req.body.createdby,
|
||||
updatedby: req.body.updatedby,
|
||||
};
|
||||
|
||||
// Save Tutorial in the database
|
||||
Subsectionsmaster.create(subsection)
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging subsection." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updatesubsection = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Subsectionsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
//delete
|
||||
exports.Deletesubsection = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Subsectionsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
//itemsmaster
|
||||
// Retrieve all itemsmaster from the database.
|
||||
exports.ItemList = (req, res) => {
|
||||
|
||||
Itemsmaster.findAll({where : { is_active : 1 } })
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
|
||||
});
|
||||
};
|
||||
|
||||
exports.Insertitem = (req, res) => {
|
||||
// Create a item
|
||||
const item = {
|
||||
statement: req.body.statement,
|
||||
section: req.body.section,
|
||||
subsection: req.body.subsection,
|
||||
itemtext: req.body.itemtext,
|
||||
is_active: req.body.is_active,
|
||||
pvt_ltd: req.body.pvt_ltd,
|
||||
llp: req.body.llp,
|
||||
others: req.body.others,
|
||||
formula: req.body.formula,
|
||||
is_calculated: req.body.is_calculated,
|
||||
createdby: req.body.createdby,
|
||||
updatedby: req.body.updatedby,
|
||||
};
|
||||
|
||||
// Save Tutorial in the database
|
||||
Itemsmaster.create(item)
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while insertinging items." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.Updateitem = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Itemsmaster.update(req.body, {
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//delete
|
||||
exports.Deleteitem = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
Itemsmaster.update({ is_active : 0 },{
|
||||
where: { id: id }
|
||||
})
|
||||
.then(data => {
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
logMsg.info("Success :"(data));
|
||||
})
|
||||
.catch(err => {
|
||||
res.send({'status':404,
|
||||
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||
Brokenperiods.init(
|
||||
{
|
||||
entity_id: { type: DataTypes.INTEGER },
|
||||
from: { type: DataTypes.DATE },
|
||||
to: { type: DataTypes.DATE },
|
||||
months: { type: DataTypes.INTEGER },
|
||||
cy: { type: DataTypes.INTEGER },
|
||||
py: { type: DataTypes.INTEGER },
|
||||
@ -31,6 +33,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
modelName: 'Brokenperiods',
|
||||
createdAt: 'createdon',
|
||||
updatedAt: 'updatedon',
|
||||
|
||||
}
|
||||
)
|
||||
return Brokenperiods
|
||||
|
||||
@ -25,7 +25,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
biz_act_desc: { type: DataTypes.STRING },
|
||||
createdby: { type: DataTypes.INTEGER },
|
||||
updatedby: { type: DataTypes.INTEGER },
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@ -4,6 +4,7 @@ module.exports = app => {
|
||||
const master = require("../controllers/master.controller.js");
|
||||
var router = require("express").Router();
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/EntitiesList:
|
||||
@ -13,35 +14,193 @@ module.exports = app => {
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
// Retrieve all Tutorials
|
||||
router.get("/EntitiesList", financials.findAllEntities);
|
||||
// get statment master data
|
||||
router.get("/StatmentList", financials.StatmentList);
|
||||
// get statment master data
|
||||
// insert or update broken periods
|
||||
router.post("/BrokenPeriods", financials.BrokenPeriods);
|
||||
|
||||
// get financials summary
|
||||
router.get("/FinantialsSummary/:id", financials.FinantialsSummary);
|
||||
|
||||
// get menu list
|
||||
router.get("/MenuList/:losid", financials.MenuList);
|
||||
|
||||
// Retrieve all Broken periods
|
||||
router.get("/BrokenPeriodsList/:entityid", financials.BrokenPeriodsList);
|
||||
|
||||
|
||||
//master.controller api's
|
||||
// get statment master data
|
||||
router.get("/StatmentsList", master.StatmentList);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/StatementsList:
|
||||
* get:
|
||||
* description: This is List api statement!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
|
||||
router.get("/StatementsList", master.StatementsList);
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Insertstatement:
|
||||
* get:
|
||||
* description: This is Insert api statement!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
|
||||
router.post("/Insertstatement", master.Insertstatement);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Updatestatement/:id:
|
||||
* get:
|
||||
* description: This is update api statement!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Updatestatement/:id", master.Updatestatement);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Deletestatement/:id:
|
||||
* get:
|
||||
* description: This is Delete api statement!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Deletestatement/:id", master.Deletestatement);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/SectionList:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
|
||||
router.get("/SectionList", master.SectionList);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Insertsection:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.post("/Insertsection", master.Insertsection);
|
||||
router.put("/Updatesection/:id", master.Updatesection);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Updatesection/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Updatesection/:id", master.Updatesection);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Deletesection/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Deletesection/:id", master.Deletesection);
|
||||
|
||||
router.get("/SubsectionList", master.SubsectionList);
|
||||
router.post("/Insertsubsection", master.Insertsubsection);
|
||||
router.put("/Updatesubsection/:id", master.Updatesubsection);
|
||||
router.put("/Deletesubsection/:id", master.Deletesubsection);
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/SubsectionList:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.get("/SubsectionList", master.SubsectionList);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Insertsubsection:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.post("/Insertsubsection", master.Insertsubsection);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Updatesubsection/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Updatesubsection/:id", master.Updatesubsection);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Deletesubsection/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Deletesubsection/:id", master.Deletesubsection);
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/ItemList:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.get("/ItemList", master.ItemList);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Insertitem:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.post("/Insertitem", master.Insertitem);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Updateitem/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Updateitem/:id", master.Updateitem);
|
||||
router.put("/Deleteitem/:id", master.Deleteitem);
|
||||
/**
|
||||
* @openapi
|
||||
* /api/Deleteitem/:id:
|
||||
* get:
|
||||
* description: Welcome to swagger-jsdoc!
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Returns a mysterious string.
|
||||
*/
|
||||
router.put("/Deleteitem/:id", master.Deleteitem);
|
||||
|
||||
//sample
|
||||
//router.put("/:id", tutorials.update);
|
||||
@ -51,8 +210,7 @@ module.exports = app => {
|
||||
|
||||
|
||||
|
||||
// query execution test
|
||||
router.get("/test", financials.test);
|
||||
|
||||
|
||||
// third party api call example
|
||||
router.get('/third_party_api', (req, res) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user