itemMaster:GWM

This commit is contained in:
sriramv 2022-03-19 18:46:27 +05:30
parent 99f4ab4d90
commit bb8a343e04
6 changed files with 106 additions and 31 deletions

View File

@ -275,10 +275,11 @@ exports.FinantialsSummary = async (req, res) => {
try
{
const id = req.query.entityid
Entities.findOne({where : { id } , attributes: [ 'id','losid','process_instance_id' , 'entity_type' ] })
Entities.findOne({where : { id } , attributes: [ 'id','losid','process_instance_id' , 'entity_type' , 'probe42_data_status' ] })
.then(EntitiesData => {
const instancesid = EntitiesData.dataValues.process_instance_id;
sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.statement_name as st_type_name,a.additional_year_type FROM entity_fin_year a LEFT JOIN (SELECT id,statement_name FROM statement_type) b ON a.st_type = b.id WHERE entityid ="+id+" order by a.fy desc")
const probe42_data_status = EntitiesData.dataValues.probe42_data_status;
sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.statement_name as st_type_name,a.additional_year_type, a.probe42_data_status FROM entity_fin_year a LEFT JOIN (SELECT id,statement_name FROM statement_type) b ON a.st_type = b.id WHERE entityid ="+id+" order by a.fy desc")
.then(EntityfinyearData => {
if(EntityfinyearData[0].length != 0)
{
@ -286,7 +287,7 @@ sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.state
const year_1 = EntityfinyearData[0][0].FY;
const additional_year_type = EntityfinyearData[0][0].additional_year_type;
if(EntitiesData.dataValues.entity_type == "COMPANY"){entity_type_key = "pvtltd"} else if(EntitiesData.dataValues.entity_type == "INDIVIDUAL"){entity_type_key = "llp"} else {entity_type_key = "others"}
const years = {losid:EntitiesData.dataValues.losid,entityid:EntitiesData.dataValues.id,entity_type_key:entity_type_key,additional_year_type:additional_year_type};
const years = {losid:EntitiesData.dataValues.losid,entityid:EntitiesData.dataValues.id,entity_type_key:entity_type_key,probe42_data_status:probe42_data_status,additional_year_type:additional_year_type};
// below function call is for calculation of additional new year flag generation
add_new_FY_flag = financialControllerHelper.addNewFyFlag(year_1);
// below code for constructing query for dynamic financial years
@ -299,6 +300,7 @@ sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.state
years["Y"+year_count] = value.FY;
years["Y"+year_count+"_st_type_id"] = value.st_type_id;
years["Y"+year_count+"_st_type_name"] = value.st_type_name;
years["Y"+year_count+"_probe42_data_fetched"] = value.probe42_data_status;
// fin_query construction
if(key != 0)
{
@ -309,7 +311,7 @@ sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.state
}
}); // end of foreach
var query = "Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,w.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,w.itemtext as items,w.formula,w.is_calculated,w.is_summary,w.pvtltd,w.llp,w.others,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.is_editable as Y1_is_editable,a.value as Y1_value "+ select_items +",v.remarks , v.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) v ON a.entity_id = v.entity_id and a.itemid = v.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary,pvtltd,llp,others FROM itemsmaster ) w ON a.itemid = w.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON w.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON w.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON w.subsection = z.id "+ sub_query +"WHERE a.fy = '"+year_1+"' and a.entity_id = "+id+" and a.is_active = 1 order by w.statement asc , w.section asc , w.subsection asc";
var query = "Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,w.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,w.itemtext as items,w.formula,w.is_calculated,w.is_summary,w.pvtltd,w.pvtltd_is_calculated,w.pvtltd_formula,w.llp,w.others,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.is_editable as Y1_is_editable,a.value as Y1_value "+ select_items +",v.remarks , v.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) v ON a.entity_id = v.entity_id and a.itemid = v.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary,pvtltd,llp,others,pvtltd_is_calculated,pvtltd_formula FROM itemsmaster ) w ON a.itemid = w.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON w.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON w.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON w.subsection = z.id "+ sub_query +"WHERE a.fy = '"+year_1+"' and a.entity_id = "+id+" and a.is_active = 1 order by w.statement asc , w.section asc , w.subsection asc";
setTimeout(function(){
sequelize.query(query).then(summary => {
// is_summary filter from fin_summary data
@ -752,7 +754,29 @@ exports.refreshApi = (req, res) => {
// check ProbeStatus changed or not
exports.checkProbeStatus = (req, res) => {
const entityid = req.query.entityid;
const probe42_data_status = req.query.probe42_data_status;
try
{
Entities.findOne({ where: { id: entityid } , raw:true}).then(EntitiesData=>{
if(EntitiesData.probe42_data_status == probe42_data_status)
{
res.send({'status':200,'message':"success",'data':{MenuListApicall : false}});
}
else{
res.send({'status':200,'message':"success",'data':{MenuListApicall : true}});
}
}).catch(err => { logMsg.info("Probe42 data status checking failed EntityId = "+entityid); });
logMsg.info("multiple financials update Success");
}catch(err) {
res.send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); }
};
@ -864,31 +888,32 @@ exports.refreshApi = (req, res) => {
try
{
start_date = "'2019-08-12'";
let starting_date = new Date(start_date);
end_date = "'2021-05-12'";
let date = new Date(end_date);
// start_date = "'2019-08-12'";
// let starting_date = new Date(start_date);
// end_date = "'2021-05-12'";
// let date = new Date(end_date);
years_skeleton = [];
for(let i=0;i<12;i++)
{
//store on fly month number
month_count = date.getMonth() + 1;
//create on fly month data
new_date = date.toLocaleString('default', { month: 'short' })+"-"+date.getFullYear();
//create on fly period data
new_period = date.getFullYear()+"-"+month_count+"-01";
obj = {month:new_date,period:new_period};
// push skeleton object
years_skeleton.push(obj);
//Reset date here
date.setMonth(date.getMonth() - 1);
//check if loop meets starting date or not
if(starting_date.getFullYear() == date.getFullYear() && starting_date.getMonth() + 1 == month_count) { break; }
}
// years_skeleton = [];
// for(let i=0;i<12;i++)
// {
// //store on fly month number
// month_count = date.getMonth() + 1;
// //create on fly month data
// new_date = date.toLocaleString('default', { month: 'short' })+"-"+date.getFullYear();
// //create on fly period data
// new_period = date.getFullYear()+"-"+month_count+"-01";
// obj = {month:new_date,period:new_period};
// // push skeleton object
// years_skeleton.push(obj);
// //Reset date here
// date.setMonth(date.getMonth() - 1);
// //check if loop meets starting date or not
// if(starting_date.getFullYear() == date.getFullYear() && starting_date.getMonth() + 1 == month_count) { break; }
// }
console.log(years_skeleton);
// console.log(years_skeleton);

View File

@ -12,6 +12,7 @@ module.exports = (sequelize, DataTypes) => {
FY: { type: DataTypes.INTEGER },
st_type: { type: DataTypes.INTEGER },
additional_year_type: { type: DataTypes.INTEGER },
probe42_data_status: { type: DataTypes.INTEGER },
createdby: { type: DataTypes.INTEGER },
updatedby: { type: DataTypes.INTEGER },

View File

@ -30,6 +30,8 @@ module.exports = (sequelize, DataTypes) => {
subsection: { type: DataTypes.INTEGER },
itemtext: { type: DataTypes.STRING },
pvtltditemkey: { type: DataTypes.STRING },
pvtltd_is_calculated: { type: DataTypes.INTEGER },
pvtltd_formula: { type: DataTypes.INTEGER },
is_active: { type: DataTypes.INTEGER },
pvtltd: { type: DataTypes.INTEGER },
llp: { type: DataTypes.INTEGER },

View File

@ -8,7 +8,33 @@ module.exports = app => {
var router = require("express").Router();
router.get("/demo", financials.demo);
/**
* @swagger
* /api/checkProbeStatus:
* get:
* summary: check Probe42 Data Status
* description: checking probe42 data status changed or not for recall menulist api (call this api id probe42_data_status = 1 -> Data Fetching in progress)
* parameters:
* - in: query
* name: entityid
* schema:
* type: integer
* required: true
* description: primary id of entity object
* example: 304
* - in: query
* name: probe42_data_status
* schema:
* type: integer
* required: true
* description: probe42 data undate status
* example: 1
* responses:
* 200:
* description: success
*/
// get financials summary
router.get("/checkProbeStatus", financials.checkProbeStatus);
/**
* @swagger
* definitions:

View File

@ -1,4 +1,4 @@
const { sequelize, Financials , Itemsmaster , Entities} = require('../models')
const { sequelize, Financials , Itemsmaster , Entities , Entityfinyear} = require('../models')
const { Op } = require("sequelize");
const { logMsg } = require('../services/logger.js');
@ -86,6 +86,7 @@ const { logMsg } = require('../services/logger.js');
try
{
entityid = update_array_data[0].entityid;
fy = update_array_data[0].year;
var LineItemUpdate = new Promise((resolve, reject) => {
@ -102,7 +103,27 @@ const { logMsg } = require('../services/logger.js');
});
LineItemUpdate.then((Query_data)=>{
Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
//Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
Entityfinyear.update({ probe42_data_status : 1 } , {where : {entityid:entityid , FY :fy}})
.then(async (data) => {
logMsg.info("Probe42 data updated for EntityId = "+entityid+" Year = "+fy);
Entityfinyear.findAll({where : {entityid:300},rew:true})
.then(async (EntityfinyearData) =>{
let count = 0;
for(const value of EntityfinyearData)
{
count = count + value.probe42_data_status;
}
if(EntityfinyearData.length == count)
{
Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
}
else if(count >=1)
{
Entities.update({ "probe42_data_status": 3 },{ where: { id: entityid }});
}
});
}).catch(err => { logMsg.info("Probe42 data update failed for EntityId = "+entityid+" Year = "+fy); });
});
}
catch (error)

View File

@ -56,7 +56,7 @@ require("./app/routes/routes.js")(app);
const PORT_NUMBER = process.env.SERVER_PORT
app.listen({ port: PORT_NUMBER }, async () => {
console.log('Server up on http://localhost:8000')
console.log('Server up on http://localhost:'+PORT_NUMBER)
//await sequelize.authenticate()
})