fin_yr_flag

This commit is contained in:
sriramv 2021-09-15 12:01:56 +05:30
commit e5d92fc793
5 changed files with 922 additions and 801 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/node_modules
/storage
.env
/app/controllers/test.controller.js

View File

@ -1,4 +1,3 @@
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models')
const { logMsg } = require('../services/logger.js');
@ -39,42 +38,46 @@ exports.MenuList = (req, res) => {
try {
const losid = req.query.losid
// call starter function here
// req_obj ={"losid":losid}
// starter_response = starter(req_obj);
// if(starter_response.status == 200)
// {
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} ,
attributes: ['id', 'subsection','itemtext', 'is_active'],
required :false
}],
required :false
}],
required :false
})
.then(MasterData => {
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
.then(EntitiesData => {
let data = [];
EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data);
}); // end of EntitiesData foreach
res.send({'status':200,'message':"success",'data':data});
logMsg.info("MenuList api working");
}); // end of findall EntitiesData
}); // end of findall masters datas
//} // end of starter function if condition
console.log(losid)
req_obj ={"losid":losid}
starter_response = starter(req_obj);
setTimeout(()=>{
if(starter_response.status == 200)
{
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} ,
attributes: ['id', 'subsection','itemtext', 'is_active'],
required :false
}],
required :false
}],
required :false
})
.then(MasterData => {
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
.then(EntitiesData => {
let data = [];
EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data);
}); // end of EntitiesData foreach
res.send({'status':200,'message':"success",'data':data});
logMsg.info("MenuList api working");
}); // end of findall EntitiesData
}); // end of findall masters datas
} // end of starter function if condition
},5000)
} catch (err) {
console.log(err)
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
@ -95,22 +98,11 @@ 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 ,"add_new_finyear_flag" : add_new_FY_flag, "summary" : result } });
res.send({'status':200,'message':"success",'data':{"years" : years_data , "summary" : result } });
}).catch(err => {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" });
@ -306,6 +298,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
Financials.bulkCreate(fin_data_array);
//console.log(fin_data_array)
});
}).catch(err => {
res.status(404).send({'status':404,
@ -322,10 +315,10 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
}); // end of (losid,pan,cin) combination checking entity data exist or not
}); // end of pro42 data foreach
return {'status':200,'message':"success",'data':"No data"}; // success message
} catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
@ -376,36 +369,7 @@ 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) => {
@ -416,10 +380,6 @@ exports.testwo = async (req, res) => {
};
function testhree(req , res) {
console.log( new Date().getFullYear())
console.log("first")
for(let i=0 ; i < 5 ; i++){console.log(i)}
console.log("last")
return {'status':200,'message':"success from "};
}
console.log( req.losid)
return {'status':200,'message':"success"};
}

View File

@ -4,7 +4,7 @@
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history} = require('../models')
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type,Entityfinyears} = require('../models')
const { logMsg } = require('../services/logger.js');
@ -265,7 +265,7 @@ exports.Insertitem = (req, res) => {
subsection: req.body.subsection,
itemtext: req.body.itemtext,
is_active: req.body.is_active,
pvt_ltd: req.body.pvt_ltd,
pvtltd: req.body.pvtltd,
llp: req.body.llp,
others: req.body.others,
formula: req.body.formula,
@ -431,9 +431,39 @@ exports.Historyapi = (req, res) => {
};
// Retrieve all statement types from the database.
exports.Statementtype_list = (req, res) => {
Statement_type.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.Statementtype_insert = (req, res) => {
const req_array_data = req.body;
try
{
// const losid = req_array_data.losid;
//const entityid = req_array_data.entityid;
Entityfinyears.update({ "Y1_st_type":req_array_data.Y1_st_type,"Y2_st_type":req_array_data.Y2_st_type,"Y3_st_type":req_array_data.Y3_st_type,"updatedby":req_array_data.updatedby },{ where: { entityid:req_array_data.entityid}})
res.send({'status':200,'message':"success",'data':"No data"});
logMsg.info("Statementtype_insert Success");
}catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting Statementtype_insert." ,'data': "No data"
}); }
};

View File

@ -0,0 +1,39 @@
'use strict'
const { Model } = require('sequelize')
const { logMsg } = require('../services/logger.js')
module.exports = (sequelize, DataTypes) => {
class Statement_type extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
// define association here
// static associate({ Sectionsmaster }) {
// this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' })
// }
//Sectionsmaster.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmaster' })
}
Statement_type.init(
{
statement_name: { type: DataTypes.STRING },
is_active: { type: DataTypes.INTEGER },
createdby: { type: DataTypes.INTEGER },
updatedby: { type: DataTypes.INTEGER },
},
{
sequelize,
tableName: 'statement_type',
modelName: 'Statement_type',
}
)
// logMsg.info("Success-model ")
return Statement_type
}

File diff suppressed because it is too large Load Diff