sum_api_swagger:GWM
This commit is contained in:
commit
ed72838587
@ -455,7 +455,7 @@ exports.Statementtype_insert = (req, res) => {
|
|||||||
{
|
{
|
||||||
// const losid = req_array_data.losid;
|
// const losid = req_array_data.losid;
|
||||||
//const entityid = req_array_data.entityid;
|
//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}})
|
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,"Y4_st_type":req_array_data.Y4_st_type,"updatedby":req_array_data.updatedby },{ where: { entityid:req_array_data.entityid}})
|
||||||
|
|
||||||
res.send({'status':200,'message':"success",'data':"No data"});
|
res.send({'status':200,'message':"success",'data':"No data"});
|
||||||
logMsg.info("Statementtype_insert Success");
|
logMsg.info("Statementtype_insert Success");
|
||||||
|
|||||||
@ -3,27 +3,14 @@ const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster ,
|
|||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// new promise((resolve,reject) =>{
|
|
||||||
// resolve('');
|
|
||||||
// })
|
|
||||||
|
|
||||||
exports.intiator = (req, res) => {
|
exports.intiator = (req, res) => {
|
||||||
const losid = req.query.losid
|
const losid = req.query.losid
|
||||||
console.log(losid)
|
console.log(losid)
|
||||||
console.log('1')
|
console.log('1')
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// const data = starter(losid,MenuList)
|
starter(losid,MenuList)
|
||||||
const data = starter(losid,MenuList)
|
|
||||||
setTimeout(()=>{
|
|
||||||
console.log(data)
|
|
||||||
console.log('5')
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
},10000);
|
|
||||||
|
|
||||||
// res.send(data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
res.status(500).send({'status':404,
|
res.status(500).send({'status':404,
|
||||||
@ -31,8 +18,20 @@ exports.intiator = (req, res) => {
|
|||||||
}); }
|
}); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function giveresponse(value) {
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
res.status({value});
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); }
|
||||||
|
}
|
||||||
// menu list api
|
// menu list api
|
||||||
MenuList = (value) => {
|
function MenuList (value,giveresponse) {
|
||||||
|
|
||||||
console.log(value)
|
console.log(value)
|
||||||
console.log('3')
|
console.log('3')
|
||||||
@ -68,11 +67,10 @@ exports.intiator = (req, res) => {
|
|||||||
data.push(obj_data);
|
data.push(obj_data);
|
||||||
}) // end of EntitiesData foreach
|
}) // end of EntitiesData foreach
|
||||||
console.log(data)
|
console.log(data)
|
||||||
console.log('4')
|
console.log('4')
|
||||||
//return (data);
|
logMsg.info("MenuList api working");
|
||||||
// return intiator({'losid':losid,'status':200,'message':"success",'data':data}); // success message
|
|
||||||
// res.send({'losid':losid,'status':200,'message':"success",'data':"No data"});
|
giveresponse({'status':200,'message':"success",'data':data});
|
||||||
// logMsg.info("MenuList api working");
|
|
||||||
}); // end of findall EntitiesData
|
}); // end of findall EntitiesData
|
||||||
}); // end of findall masters datas
|
}); // end of findall masters datas
|
||||||
} // end of starter function if condition
|
} // end of starter function if condition
|
||||||
@ -93,9 +91,7 @@ exports.intiator = (req, res) => {
|
|||||||
const losid = value
|
const losid = value
|
||||||
console.log(value)
|
console.log(value)
|
||||||
console.log('2')
|
console.log('2')
|
||||||
//const losid = req.losid;
|
|
||||||
|
|
||||||
|
|
||||||
//pro 42 api call using losid
|
//pro 42 api call using losid
|
||||||
const Pro42Data = [
|
const Pro42Data = [
|
||||||
{"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
|
{"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
|
||||||
@ -164,7 +160,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
|
|||||||
|
|
||||||
}); // end of pro42 data foreach
|
}); // end of pro42 data foreach
|
||||||
|
|
||||||
return MenuList({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
MenuList({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
||||||
|
|
||||||
|
|
||||||
//end of try catch
|
//end of try catch
|
||||||
@ -173,6 +169,229 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// exports.printAll = () => {
|
||||||
|
|
||||||
|
// .then(() => {
|
||||||
|
// return console.log("B")
|
||||||
|
// })
|
||||||
|
// .then(() => {
|
||||||
|
// return console.log("C")
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//printAll()
|
||||||
|
|
||||||
|
// function doSomething(){
|
||||||
|
// return doAnotherThing(parameter).then(function(other){
|
||||||
|
// // Do more stuff
|
||||||
|
// return "xxxxx"
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Usage
|
||||||
|
// doSomething().then(function(other){
|
||||||
|
// console.log (other)
|
||||||
|
// });
|
||||||
|
|
||||||
|
exports.test = (req, res) => {
|
||||||
|
const losid = req.query.losid;
|
||||||
|
|
||||||
|
const promise = Promise.resolve(res.send({'losid':losid,'status':200,'message':"success","data":data}));
|
||||||
|
const promise1 = new Promise((resolve, reject) => {
|
||||||
|
console.log(losid)
|
||||||
|
const data = losid
|
||||||
|
console.log('1')
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
//to call starter here
|
||||||
|
promise.then(val => console.log(val));
|
||||||
|
|
||||||
|
})
|
||||||
|
.then(losid => {
|
||||||
|
//call menulist
|
||||||
|
console.log(losid);
|
||||||
|
console.log('2')
|
||||||
|
});
|
||||||
|
// const promise = Promise.resolve(res.send({'losid':losid,'status':200,'message':"success","data":data}));
|
||||||
|
};
|
||||||
|
exports.test1 = (req, res) => {
|
||||||
|
const v = doSomething(function(x) {
|
||||||
|
console.log(x);
|
||||||
|
doSomethingMore(x, function(y) {
|
||||||
|
console.log(y);
|
||||||
|
doRestOfTheThings(y, function(z) {
|
||||||
|
console.log(z);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
doSomething();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.test2 = (req, res) => {
|
||||||
|
const losid = req.query.losid
|
||||||
|
const promise = Promise.resolve(res.send({'losid':losid,'status':200,'message':"success"}));
|
||||||
|
const p1 = losid => new Promise((resolve,reject) =>{
|
||||||
|
//console.log(losid)
|
||||||
|
resolve(losid)
|
||||||
|
})
|
||||||
|
p1(1).then((losid) => {
|
||||||
|
|
||||||
|
//pro 42 api call using losid
|
||||||
|
const Pro42Data = [
|
||||||
|
{"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
|
||||||
|
{"losid":losid,"pan":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
|
||||||
|
];
|
||||||
|
// insert pro42data into entities table using using foreach
|
||||||
|
Pro42Data.forEach((Pro42Datavalue, key)=>{
|
||||||
|
// check if the Pro42Data (entity) already inserted
|
||||||
|
Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
|
||||||
|
if(Entity)
|
||||||
|
{
|
||||||
|
// skip inserting
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Entities.create({ "losid":Pro42Datavalue.losid,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.cin,"bizname":Pro42Datavalue.bizname,"entity_type":Pro42Datavalue.entity_type,"activity_group":Pro42Datavalue.activity_group,"biz_act_desc":Pro42Datavalue.biz_act_desc,"createdby":Pro42Datavalue.createdby})
|
||||||
|
.then(Entitydata => {
|
||||||
|
|
||||||
|
//create Entityfinyears data
|
||||||
|
const Y1 = new Date().getFullYear();
|
||||||
|
const Y2 = Y1-1;
|
||||||
|
const Y3 = Y2-1;
|
||||||
|
Entityfinyears.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"Y1":Y1,"Y2":Y2,"Y3":Y3,"Y1_st_type":2,"Y2_st_type":2,"Y3_st_type":2})
|
||||||
|
.then(Entityfinyearsdata => {
|
||||||
|
|
||||||
|
//create financials data based on Entityfinyears
|
||||||
|
let fin_years_array = [];
|
||||||
|
fin_years_array = [
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y1,"st_type":Entityfinyearsdata.dataValues.Y1_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y2,"st_type":Entityfinyearsdata.dataValues.Y2_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y3,"st_type":Entityfinyearsdata.dataValues.Y3_st_type}
|
||||||
|
];
|
||||||
|
|
||||||
|
// create skeletion
|
||||||
|
fin_years_array.forEach((value, key)=>{
|
||||||
|
const entity_id = value.entity_id;
|
||||||
|
const fy = value.fy;
|
||||||
|
const st_type = value.st_type;
|
||||||
|
|
||||||
|
// generate financials data array
|
||||||
|
let fin_data_array = [];
|
||||||
|
for (let i = 1; i < 120; i++)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
//bulk financials data create
|
||||||
|
Financials.bulkCreate(fin_data_array);
|
||||||
|
//console.log(fin_data_array)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity fin year table data insert
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity insert
|
||||||
|
|
||||||
|
} //end of else condition
|
||||||
|
|
||||||
|
}); // end of (losid,pan,cin) combination checking entity data exist or not
|
||||||
|
|
||||||
|
}); // end of pro42 data foreach
|
||||||
|
|
||||||
|
return ({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
||||||
|
//end of try catch
|
||||||
|
|
||||||
|
})
|
||||||
|
.then((value) => {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(value.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
|
||||||
|
console.log(data)
|
||||||
|
console.log('4')
|
||||||
|
logMsg.info("MenuList api working");
|
||||||
|
|
||||||
|
return ({'status':200,'message':"success",'data':data});
|
||||||
|
}); // end of findall EntitiesData
|
||||||
|
}); // end of findall masters datas
|
||||||
|
} // end of starter function if condition
|
||||||
|
//return {'status':200,'message':"success",'data':data};
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch(console.log)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.testwo = async (req, res) => {
|
exports.testwo = async (req, res) => {
|
||||||
console.log( "testtwo")
|
console.log( "testtwo")
|
||||||
req_obj ={"losid":"TEST123"}
|
req_obj ={"losid":"TEST123"}
|
||||||
@ -189,3 +408,4 @@ function testhree(req , res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ module.exports = app => {
|
|||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/ConsolidatedSummary:
|
* /api/ConsolidatedSummary:
|
||||||
@ -28,6 +29,7 @@ module.exports = app => {
|
|||||||
*/
|
*/
|
||||||
// get financials summary
|
// get financials summary
|
||||||
router.get("/ConsolidatedSummary", financials.ConsolidatedSummary);
|
router.get("/ConsolidatedSummary", financials.ConsolidatedSummary);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/FinantialsSummary:
|
* /api/FinantialsSummary:
|
||||||
@ -198,10 +200,6 @@ module.exports = app => {
|
|||||||
* type: integer
|
* type: integer
|
||||||
* description: statement type
|
* description: statement type
|
||||||
* example: 2
|
* example: 2
|
||||||
* additional_year_type:
|
|
||||||
* type: integer
|
|
||||||
* description: additional year type(1=Quarterly , 2=Halfyearly , 3=Full)
|
|
||||||
* example: 3
|
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@ -836,6 +834,12 @@ module.exports = app => {
|
|||||||
* description: success
|
* description: success
|
||||||
*/
|
*/
|
||||||
router.get("/Historyapi", master.Historyapi);
|
router.get("/Historyapi", master.Historyapi);
|
||||||
|
|
||||||
|
// router.get("/printAll", test.printAll);
|
||||||
|
router.get("/test", test.test);
|
||||||
|
router.get("/test1", test.test1);
|
||||||
|
router.get("/test2", test.test2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user