fin_yr_flag

This commit is contained in:
sriramv 2021-09-15 11:39:59 +05:30
parent fb042292b2
commit 3fc997a91a
2 changed files with 47 additions and 4 deletions

View File

@ -75,7 +75,6 @@ exports.MenuList = (req, res) => {
}); // end of findall EntitiesData
}); // end of findall masters datas
//} // end of starter function if condition
} catch (err) {
console.log(err)
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
@ -96,11 +95,22 @@ exports.FinantialsSummary = async (req, res) => {
const Year_2 = data[0][0].Y2;
const Year_3 = data[0][0].Y3;
const years_data = data[0][0];
const current_year = new Date().getFullYear();
const current_month = new Date().getMonth() + 1;
let add_new_FY_flag;
if(Year_1 == current_year && 3 < current_month)
{
add_new_FY_flag = {show_add_finyear_button:0};
}
else
{
add_new_FY_flag = {show_add_finyear_button:1,FY:current_year};
}
//sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type,f.statement_name as st_name,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) f ON a.st_type = f.id LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks ) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_3+" and is_active = 1 and entity_id = "+id+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_2+" and is_active = 1 and entity_id = "+id+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id+" and a.is_active = 1 order by x.id asc , y.id asc , a.itemid asc ")
sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated 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.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc")
.then(result => {
const arr = {"years" : years_data , "summary" : result }
res.send({'status':200,'message':"success",'data':{"years" : years_data , "summary" : result } });
res.send({'status':200,'message':"success",'data':{"years" : years_data ,"add_new_finyear_flag" : add_new_FY_flag, "summary" : result } });
}).catch(err => {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
@ -366,7 +376,36 @@ exports.createFinancialYear = async (req, res) => {
};
exports.test = (req , res)=>{
// let promise = new Promise(function(resolve, reject) {
// setTimeout(() => resolve({msg: 'To do some more job'}), 1000);
// });
// promise.then(function(result) {
// return {data: 'some data'};
// });
// promise.then(function(result) {
// return {data: 'some other data'};
// });
// promise.then(function(result) {
// return {data: 'some more data'};
// });
let promise = new Promise((resolve, reject) => {
fn_call = testhree();
resolve({ status: 200,message: 'success', data:fn_call })
})
promise.then(messages => {
console.log(messages.data)
})
};
exports.testwo = async (req, res) => {
@ -377,8 +416,10 @@ exports.testwo = async (req, res) => {
};
function testhree(req , res) {
console.log( new Date().getFullYear())
console.log( req.losid)
return {'status':200,'message':"success"};
console.log("first")
for(let i=0 ; i < 5 ; i++){console.log(i)}
console.log("last")
return {'status':200,'message':"success from "};
}

View File

@ -157,6 +157,8 @@ module.exports = app => {
//post_object = {"losid":"MW12233","entityid":6,"fy":2022,"st_type":2}
router.post("/createFinancialYear", financials.createFinancialYear);
router.get("/test", financials.test);