From 181905749c8c4729c2a75453d7ab2f10253b0d34 Mon Sep 17 00:00:00 2001 From: sriramv Date: Thu, 23 Sep 2021 13:14:41 +0530 Subject: [PATCH 1/3] sum_api_swagger:GWM --- app/controllers/financial.controller.js | 14 ++++++++++++-- app/routes/routes.js | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 0109ec4..ddfb5b6 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -317,7 +317,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{ { fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":fy,"value":0,"is_active":1,"createdby":4} fin_data_array.push(fin_data_obj); - } console.log("------"+entity_id +"---"+ fy) + } //console.log("------"+entity_id +"---"+ fy) //bulk financials data create Financials.bulkCreate(fin_data_array); //console.log(fin_data_array) @@ -368,9 +368,16 @@ exports.createFinancialYear = async (req, res) => { const Y3_st_type = Entityfinyearsdata.dataValues.Y2_st_type; const Y4_st_type = Entityfinyearsdata.dataValues.Y3_st_type; const additional_year_type = req.body.additional_year_type; + if(req.body.fy > new Date().getFullYear() && req.body.fy == Entityfinyearsdata.dataValues.Y1) + { + // not allowing any process + res.status(500).send({'status':500, 'message': "The year creation not allowed" ,'data': "No data" }); + } + else + { Entityfinyears.update({ Y1:Y1,Y2:Y2,Y3:Y3,Y4:Y4,Y1_st_type:Y1_st_type,Y2_st_type:Y2_st_type,Y3_st_type:Y3_st_type,Y4_st_type:Y4_st_type,additional_year_type:additional_year_type },{ where: { id: id }}) .then(UpdatedEntityfinyearsdata => { - + // generate new financials data array for given FY with entity_id let fin_data_array = []; for (let i = 1; i < 120; i++) @@ -386,6 +393,9 @@ exports.createFinancialYear = async (req, res) => { res.status(404).send({'status':404, message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); }); // end of update Entityfinyears + + } // end of else part + }).catch(err => { res.status(404).send({'status':404, message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); diff --git a/app/routes/routes.js b/app/routes/routes.js index 8c5f0b5..290794f 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -8,7 +8,25 @@ module.exports = app => { var router = require("express").Router(); - +/** +* @swagger +* /api/ConsolidatedSummary: +* get: +* summary: Consolidated Summary +* description: Get consolidated Financials Summary data by sending losid +* parameters: +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: LOSID +* example: MW112233 +* responses: +* 200: +* description: success +*/ + // get financials summary router.get("/ConsolidatedSummary", financials.ConsolidatedSummary); /** * @swagger From d4f6c75cedbf06678b9441d6f4a74df773418470 Mon Sep 17 00:00:00 2001 From: sriramv Date: Fri, 24 Sep 2021 15:51:29 +0530 Subject: [PATCH 2/3] sum_api_changes:GWM --- app/controllers/financial.controller.js | 85 +++++++++++++------------ app/routes/routes.js | 4 ++ 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index ddfb5b6..fe6cbf0 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -368,12 +368,8 @@ exports.createFinancialYear = async (req, res) => { const Y3_st_type = Entityfinyearsdata.dataValues.Y2_st_type; const Y4_st_type = Entityfinyearsdata.dataValues.Y3_st_type; const additional_year_type = req.body.additional_year_type; - if(req.body.fy > new Date().getFullYear() && req.body.fy == Entityfinyearsdata.dataValues.Y1) - { - // not allowing any process - res.status(500).send({'status':500, 'message': "The year creation not allowed" ,'data': "No data" }); - } - else + const crnt_yr = new Date().getFullYear(); + if(req.body.fy <= crnt_yr && req.body.fy != Y2) { Entityfinyears.update({ Y1:Y1,Y2:Y2,Y3:Y3,Y4:Y4,Y1_st_type:Y1_st_type,Y2_st_type:Y2_st_type,Y3_st_type:Y3_st_type,Y4_st_type:Y4_st_type,additional_year_type:additional_year_type },{ where: { id: id }}) .then(UpdatedEntityfinyearsdata => { @@ -388,13 +384,16 @@ exports.createFinancialYear = async (req, res) => { //bulk financials data create Financials.bulkCreate(fin_data_array); //response - res.send({'status':200,'message':"success",'data':"No data"}); + res.status(200).send({'status':200,'message':"success",'data':"No data"}); }).catch(err => { res.status(404).send({'status':404, message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); }); // end of update Entityfinyears - - } // end of else part + } + else + { + res.status(405).send({'status':405, 'message': "The year creation not allowed" ,'data': "No data" }); + } // end of else part }).catch(err => { res.status(404).send({'status':404, @@ -411,45 +410,47 @@ exports.createFinancialYear = async (req, res) => { exports.ConsolidatedSummary = async (req, res) => { const losid = req.query.losid; - const years_data = await sequelize.query("select distinct (Y4) as years from entity_fin_years where losid = '"+losid+"' union select distinct (Y3) from entity_fin_years where losid = '"+losid+"' union select distinct (Y2) from entity_fin_years where losid = '"+losid+"' union select distinct (Y1) from entity_fin_years where losid = '"+losid+"'"); - const years_count = years_data[0].length; - const Year_1 = years_data[0][years_count - 1].years; - const Year_2 = years_data[0][years_count - 2].years; - const Year_3 = years_data[0][years_count - 3].years; - //const Year_4 = years_data[0][years_count - 4].years; - - Entityfinyears.findAll({where : { losid } , attributes: ['entityid','Y1','Y2','Y3','Y4'] }) - .then(EntityfinyearsData =>{ - let data=[]; - EntityfinyearsData.forEach((value, key)=>{ - obj_data = value.dataValues.entityid; - data.push(obj_data); - }); // end of EntityfinyearsData foreach - const IN = data.join(); - sequelize.query("SELECT 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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id order by e.statement asc , e.section asc , e.id asc") - //sequelize.query("SELECT 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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value,d.fy as Y4,SUM(d.value) as Y4_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_4+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id,d.fy order by e.statement asc , e.section asc , e.id asc") - .then(sum_data =>{ - res.send({'status':200,message: "success" ,'data': sum_data }); + sequelize.query("select distinct (Y4) as years from entity_fin_years where losid = '"+losid+"' union select distinct (Y3) from entity_fin_years where losid = '"+losid+"' union select distinct (Y2) from entity_fin_years where losid = '"+losid+"' union select distinct (Y1) from entity_fin_years where losid = '"+losid+"'") + .then(EntityfinyearsData =>{ + const years_count = EntityfinyearsData[0].length; + const Year_1 = EntityfinyearsData[0][years_count - 1].years; + const Year_2 = EntityfinyearsData[0][years_count - 2].years; + const Year_3 = EntityfinyearsData[0][years_count - 3].years; + const Year_4 = EntityfinyearsData[0][years_count - 4].years; + if(Year_4 == null) + { + sequelize.query("select x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,g.subsection as subsection , g.itemtext as subsection_itemtext,a.itemid,e.itemtext as items,a.fy as Y1 , SUM(a.value) as Y1_value,b.fy as Y2 , SUM(b.value) as Y2_value,c.fy as Y3 , SUM(c.value) as Y3_value from entities z JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_1+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) a ON z.id = a.entity_id JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON z.id = b.entity_id and a.itemid = b.itemid JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON z.id = c.entity_id and a.itemid = c.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 ) g ON e.subsection = g.id where losid = '"+losid+"' GROUP BY a.itemid,x.id,x.statement,y.id,y.section,e.subsection,g.subsection,g.itemtext,e.itemtext,e.statement,e.section,e.id,a.fy,b.fy,c.fy ORDER BY e.statement asc , e.section asc , e.id asc") + .then(sum_data =>{ + res.send({'status':200,message: "success" ,'data': sum_data }); + }) + .catch(err => { + res.status(404).send({'status':404, + message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); + }); + } + else + { + sequelize.query("select x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,g.subsection as subsection , g.itemtext as subsection_itemtext,a.itemid,e.itemtext as items,a.fy as Y1 , SUM(a.value) as Y1_value,b.fy as Y2 , SUM(b.value) as Y2_value,c.fy as Y3 , SUM(c.value) as Y3_value,d.fy as Y4 , SUM(d.value) as Y4_value from entities z JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_1+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) a ON z.id = a.entity_id JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON z.id = b.entity_id and a.itemid = b.itemid JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON z.id = c.entity_id and a.itemid = c.itemid JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_4+"' and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) d ON z.id = d.entity_id and a.itemid = d.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 ) g ON e.subsection = g.id where losid = '"+losid+"' GROUP BY a.itemid,x.id,x.statement,y.id,y.section,e.subsection,g.subsection,g.itemtext,e.itemtext,e.statement,e.section,e.id,a.fy,b.fy,c.fy,d.fy ORDER BY e.statement asc , e.section asc , e.id asc") + .then(sum_data =>{ + res.send({'status':200,message: "success" ,'data': sum_data }); + }) + .catch(err => { + res.status(404).send({'status':404, + message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); + }); + }//end of else part }) .catch(err => { - res.status(404).send({'status':404, - message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); - }); - - }) - .catch(err => { - res.status(404).send({'status':404, - message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); - }); + res.status(404).send({'status':404, + message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); + }); }; exports.testwo = async (req, res) => { -// 3 years sum -//sequelize.query("SELECT 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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id order by e.statement asc , e.section asc , e.id asc") -// 4 year sum -//sequelize.query("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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value,d.fy as Y4,SUM(d.value) as Y4_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_4+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id,d.fy order by e.statement asc , e.section asc , e.id asc") - + //sequelize.query("SELECT 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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id order by e.statement asc , e.section asc , e.id asc") + //sequelize.query("SELECT 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,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value,d.fy as Y4,SUM(d.value) as Y4_value FROM financials a 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 entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_4+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id,d.fy order by e.statement asc , e.section asc , e.id asc") + }; function testhree(req , res) { diff --git a/app/routes/routes.js b/app/routes/routes.js index ef48032..b514227 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -200,6 +200,10 @@ module.exports = app => { * type: integer * description: statement type * example: 2 +* additional_year_type: +* type: integer +* description: additional year type +* example: 2 */ /** * @swagger From 451a3d112b55c3544890e5787a282edf4e0fac61 Mon Sep 17 00:00:00 2001 From: sriramv Date: Fri, 24 Sep 2021 16:09:29 +0530 Subject: [PATCH 3/3] sum_api_changes:GWM --- app/controllers/financial.controller.js | 2 +- app/services/financial.controller.helper.js.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index fe6cbf0..7eb8680 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -369,7 +369,7 @@ exports.createFinancialYear = async (req, res) => { const Y4_st_type = Entityfinyearsdata.dataValues.Y3_st_type; const additional_year_type = req.body.additional_year_type; const crnt_yr = new Date().getFullYear(); - if(req.body.fy <= crnt_yr && req.body.fy != Y2) + if(req.body.fy != 0) { Entityfinyears.update({ Y1:Y1,Y2:Y2,Y3:Y3,Y4:Y4,Y1_st_type:Y1_st_type,Y2_st_type:Y2_st_type,Y3_st_type:Y3_st_type,Y4_st_type:Y4_st_type,additional_year_type:additional_year_type },{ where: { id: id }}) .then(UpdatedEntityfinyearsdata => { diff --git a/app/services/financial.controller.helper.js.js b/app/services/financial.controller.helper.js.js index d6a9283..c3bd118 100644 --- a/app/services/financial.controller.helper.js.js +++ b/app/services/financial.controller.helper.js.js @@ -9,11 +9,11 @@ let add_new_FY_flag; if(Year_1 >= current_year && 3 < current_month) { - add_new_FY_flag = {show_add_finyear_button:0}; + add_new_FY_flag = {show_add_finyear_button:0,FY:0}; } else { - add_new_FY_flag = {show_add_finyear_button:1,FY:current_year}; + add_new_FY_flag = {show_add_finyear_button:1,FY:Year_1 + 1}; } return add_new_FY_flag; }