try,catch:gwm

This commit is contained in:
sriramv 2021-09-16 11:31:45 +05:30
parent 418b06a97e
commit d4a82caac4
3 changed files with 49 additions and 18 deletions

View File

@ -1,6 +1,6 @@
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models')
const { logMsg } = require('../services/logger.js');
const financialControllerHelper = require('../services/financial.controller.helper.js');
// all master data list for dropdown
exports.MasterDatas = async (req, res) => {
await Statementsmaster.findAll({
@ -98,17 +98,18 @@ 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};
}
// 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};
// }
add_new_FY_flag = financialControllerHelper.addNewFyFlag(Year_1);
//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 => {

View File

@ -244,17 +244,18 @@ exports.Deletesubsection = (req, res) => {
//itemsmaster
// Retrieve all itemsmaster from the database.
exports.ItemList = (req, res) => {
try
{
//Itemsmaster.findAll()
sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection,subsectionsmaster.itemtext as subsection_itemtext ,itemsmaster.itemtext,itemsmaster.is_active,pvtltd,llp,others,formula,is_calculated,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id")
.then(data => {
res.send({'status':200,'message':"success",'data':data});
logMsg.info("Success :"(data));
//logMsg.info("Success :"(data));
})
.catch(err => {
res.send({'status':404,
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
});
}catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }
};
exports.Insertitem = (req, res) => {

View File

@ -0,0 +1,29 @@
function addNewFyFlag(Y1)
{
try
{
const Year_1 = Y1;
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};
}
return add_new_FY_flag;
}
catch (error)
{
console.log(error);
}
}
module.exports = {
addNewFyFlag : addNewFyFlag
}