This commit is contained in:
sriramv 2021-08-31 18:22:20 +05:30
parent 64e8d2fd06
commit 1210f84343
2 changed files with 43 additions and 14 deletions

View File

@ -48,7 +48,7 @@ exports.MenuList = async (req, res) => {
include :[{ include :[{
association: 'subsectionsmasterData' , association: 'subsectionsmasterData' ,
where :{is_active : 1} , where :{is_active : 1} ,
attributes: ['id', 'subsection', 'is_active'], attributes: ['id', 'subsection','itemtext', 'is_active'],
required :false required :false
}], }],
required :false required :false
@ -56,11 +56,15 @@ exports.MenuList = async (req, res) => {
required :false required :false
}); });
//*******
// const bk = { id:"brokenperiod",statement : "Broken Periods" }
// MasterData.push(bk);
//*******
const EntitiesData = await Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] }); const EntitiesData = await Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] });
let data = []; let data = [];
EntitiesData.forEach((value, key)=>{ EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData} obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data); data.push(obj_data);
}); });
@ -79,7 +83,7 @@ exports.MenuList = async (req, res) => {
exports.FinantialsSummary = async (req, res) => { exports.FinantialsSummary = async (req, res) => {
const id = req.params.id const id = req.params.id
Financials.findAll({where : { entity_id : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'ASC']] }) Financials.findAll({where : { entity_id : id } ,attributes: ['fy'], group: ['fy'] , order: [['fy', 'DESC']] })
.then(data => { .then(data => {
// console.log(data.length) // console.log(data.length)
if(data.length == 3) if(data.length == 3)
@ -110,15 +114,18 @@ exports.FinantialsSummary = async (req, res) => {
// Broken period list api // Broken period list api
exports.BrokenPeriodsList = (req, res) => { exports.BrokenPeriodsList = (req, res) => {
const entityid = req.params.entityid const entityid = req.params.entityid
Brokenperiods.findAll({where : { entity_id : entityid } }) try {
Brokenperiods.findOne({where : { entity_id : entityid } })
.then(data => { .then(data => {
res.send({'status':200,'message':"success",'data':data}); console.log(data);
logMsg.info("Success :"(data)); if(data)
{res.send({'status':200,'message':"success",'data':data});}
else{res.send({'status':404,'message':"failed",'data':"nodata"});}
}) })
.catch(err => { }catch(err) {
res.status(404).send({'status':404, res.status(500).send({'status':404,
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }); }
}; };
// Broken period Insert OR Update // Broken period Insert OR Update
@ -192,7 +199,7 @@ exports.createFinancials = (req, res) => {
{ {
Financials.update({ is_active : 0 },{ where: { id: value.id }}); Financials.update({ is_active : 0 },{ where: { id: value.id }});
logMsg.info("updated is_active = 0 for primary key : "+value.id); logMsg.info("updated is_active = 0 for primary key : "+value.id);
Financials.create({ "entity_id":value.entity_id,"st_type":value.st_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"createdby":value.createdby }) Financials.create({ "entity_id":value.entity_id,"st_type":value.st_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"createdby":value.createdby })
logMsg.info("Created new financials data - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid); logMsg.info("Created new financials data - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid);
} }
}) })
@ -212,7 +219,7 @@ exports.updateFinancials = (req, res) => {
{ {
req_array_data.forEach((value, key)=>{ req_array_data.forEach((value, key)=>{
const id = value.id; const id = value.id;
Financials.update({ "entity_id":value.entity_id,"sy_type":value.sy_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"updatedby":value.updatedby },{ where: { id:id }}) Financials.update({ "entity_id":value.entity_id,"st_type":value.sy_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"updatedby":value.updatedby },{ where: { id:id }})
}); });
res.send({'status':200,'message':"success",'data':"No data"}); res.send({'status':200,'message':"success",'data':"No data"});
logMsg.info("multiple financials update Success"); logMsg.info("multiple financials update Success");
@ -221,4 +228,26 @@ exports.updateFinancials = (req, res) => {
message: err.message || "Some error occurred while inserting statements." ,'data': "No data" message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); } }); }
};
//testing
exports.test = (req, res) => {
try
{
for (let i = 1; i < 121; i++) {
Financials.create({ "entity_id":7,"st_type":2,"itemid":i,"fy":2020,"value": Math.floor(50000 + Math.random() * 150000),"is_active":1,"createdby":2 })
}
res.send({'status':200,'message':"success",'data':"No data"});
}catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }
}; };

View File

@ -36,7 +36,7 @@ module.exports = app => {
// update financials data // update financials data
router.post("/updateFinancials", financials.updateFinancials); router.post("/updateFinancials", financials.updateFinancials);
//router.get("/test", financials.test);