reinitiateApi:GWM
This commit is contained in:
parent
2aab778ffe
commit
7e12025250
@ -80,7 +80,7 @@ exports.MenuList = (req, res) => {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.ciN_LLPIN,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"createdby":Pro42Datavalue.createdby})
|
Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.ciN_LLPIN,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"probe42_data_status":1,"createdby":Pro42Datavalue.createdby})
|
||||||
.then(Entitydata => {
|
.then(Entitydata => {
|
||||||
|
|
||||||
const cin = Entitydata.dataValues.cin;
|
const cin = Entitydata.dataValues.cin;
|
||||||
@ -177,7 +177,7 @@ exports.MenuList = (req, res) => {
|
|||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}})
|
Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}})
|
||||||
.then(MasterData => {
|
.then(MasterData => {
|
||||||
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' ] })
|
Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' , 'probe42_data_status' ] })
|
||||||
.then(EntitiesData => {
|
.then(EntitiesData => {
|
||||||
|
|
||||||
let Time = 2000;
|
let Time = 2000;
|
||||||
@ -699,16 +699,33 @@ exports.createFinancialYear = async (req, res) => {
|
|||||||
.then(Entityfinyearsdata => {
|
.then(Entityfinyearsdata => {
|
||||||
|
|
||||||
// generate new financials data array for given FY with entity_id
|
// generate new financials data array for given FY with entity_id
|
||||||
|
Itemsmaster.findAll({ where :{is_active : 1},attributes: ['id'] , order: [['id', 'ASC']] })
|
||||||
|
.then(ItemsmasterData => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//construct lineitem array for bulk insert using itemmaster primarykey (id)
|
||||||
|
var SkeletonInsert = new Promise((resolve, reject) => {
|
||||||
let fin_data_array = [];
|
let fin_data_array = [];
|
||||||
for (let i = 1; i <= 120; i++)
|
ItemsmasterData.forEach( (itemvalue , index , itemvaluearray) => {
|
||||||
{
|
fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":itemvalue.dataValues.id,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1,"createdby":4}
|
||||||
fin_data_obj = { "entity_id":req.body.entityid,"st_type":req.body.st_type,"itemid":i,"fy":req.body.fy,"value":0,"is_active":1,"createdby":4}
|
|
||||||
fin_data_array.push(fin_data_obj);
|
fin_data_array.push(fin_data_obj);
|
||||||
}
|
if (index === itemvaluearray.length -1) { resolve(fin_data_array); }
|
||||||
//bulk financials data create
|
})
|
||||||
Financials.bulkCreate(fin_data_array);
|
});
|
||||||
|
SkeletonInsert.then((Query_data)=>{
|
||||||
|
Financials.bulkCreate(Query_data).then(data=>{
|
||||||
|
logMsg.info("Skeleton created for LosId ="+losid+" - EntityId = "+entityid);
|
||||||
|
|
||||||
//response
|
//response
|
||||||
res.status(200).send({'status':200,'message':"success",'data':"No data"});
|
res.status(200).send({'status':200,'message':"success",'data':"No data"});
|
||||||
|
}).catch(err=>(console.log(err))); //skeleton bulk create query
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}).catch(err=>(console.log(err))); //itemmaster query
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
res.status(404).send({'status':404,
|
res.status(404).send({'status':404,
|
||||||
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
@ -941,27 +958,47 @@ exports.createFinancialYear = async (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.demoone = (req, res) => {
|
exports.ReInitiateApi = (req, res) => {
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
console.log("inside function");
|
const cin = req.body.cin;
|
||||||
losid = "MW00075486";
|
const losid = req.body.losid;
|
||||||
redirectionApi = ApiCallHelper.redirectionApiCall(losid);
|
const entityid = req.body.entityid;
|
||||||
redirectionApi.then(function(redirectionApiData){
|
|
||||||
res.send(redirectionApiData)
|
// call and get financial year wise data for entity (probe42 api call)
|
||||||
redirectionApiData.forEach(element => {
|
financials_data_api_response = ApiCallHelper.probe42ApiCall(cin);
|
||||||
cin = element.ciN_LLPIN;
|
financials_data_api_response.then(function(result){
|
||||||
if(cin != "")
|
if(result == false)
|
||||||
{
|
{
|
||||||
prob42 = ApiCallHelper.probe42ApiCall(cin)
|
// create skeleton here
|
||||||
prob42.then(function(prob42Date){
|
//financialControllerHelper.createSkeleton(losid,entityid);
|
||||||
console.log(prob42Date)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
})
|
{
|
||||||
|
//filter lineitems from api responce and construct to needed format
|
||||||
|
lineItem_data = Probe42DataMappingHelper.lineItemFetching(result);
|
||||||
|
lineItem_data.then(function(lineItem_result){
|
||||||
|
console.log(lineItem_result)
|
||||||
|
//create financial table and entityfinyear table record here
|
||||||
|
lineItem_result.forEach((value, key)=>{
|
||||||
|
//line item data update
|
||||||
|
// mapping of probe42 api lineItem with itemMaster primary key
|
||||||
|
final_array = Probe42DataMappingHelper.lineItemMapping(value,entityid);
|
||||||
|
final_array.then(function(update_array_data){
|
||||||
|
console.log(update_array_data)
|
||||||
|
// update mapped lineitem value here
|
||||||
|
//Probe42DataMappingHelper.lineItemUpdate(update_array_data);
|
||||||
|
});//end of lineItemUpdate helper call
|
||||||
|
|
||||||
|
});//end of line item foreach
|
||||||
|
setTimeout(() => {
|
||||||
|
res.status(200).send({'status':200,message: "success" ,'data': "No data" });
|
||||||
|
}, 5000);
|
||||||
|
});//end of lineItem filter from api response helper call
|
||||||
|
} // end of probe42 api responce success else condition
|
||||||
|
});//end of probe42 api call
|
||||||
|
|
||||||
|
|
||||||
}//try
|
}//try
|
||||||
|
|||||||
@ -24,6 +24,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
entity_type: { type: DataTypes.STRING },
|
entity_type: { type: DataTypes.STRING },
|
||||||
activity_group: { type: DataTypes.STRING },
|
activity_group: { type: DataTypes.STRING },
|
||||||
biz_act_desc: { type: DataTypes.STRING },
|
biz_act_desc: { type: DataTypes.STRING },
|
||||||
|
probe42_data_status : {type : DataTypes.INTEGER},
|
||||||
createdby: { type: DataTypes.INTEGER },
|
createdby: { type: DataTypes.INTEGER },
|
||||||
updatedby: { type: DataTypes.INTEGER },
|
updatedby: { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = app => {
|
|||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
router.get("/demoone", financials.demoone);
|
router.post("/ReInitiateApi", financials.ReInitiateApi);
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/ConsolidatedSummary:
|
* /api/ConsolidatedSummary:
|
||||||
|
|||||||
@ -54,6 +54,7 @@ function createSkeleton(losid,entityid)
|
|||||||
SkeletonInsert.then((Query_data)=>{
|
SkeletonInsert.then((Query_data)=>{
|
||||||
Financials.bulkCreate(Query_data).then(data=>{
|
Financials.bulkCreate(Query_data).then(data=>{
|
||||||
logMsg.info("Skeleton created for LosId ="+losid+" - EntityId = "+entityid);
|
logMsg.info("Skeleton created for LosId ="+losid+" - EntityId = "+entityid);
|
||||||
|
Entities.update({ "probe42_data_status": 2 },{ where: { id: entityid }});
|
||||||
}).catch(err=>(console.log(err))); //skeleton bulk create query
|
}).catch(err=>(console.log(err))); //skeleton bulk create query
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const { sequelize, Financials , Itemsmaster } = require('../models')
|
const { sequelize, Financials , Itemsmaster , Entities} = require('../models')
|
||||||
const { Op } = require("sequelize");
|
const { Op } = require("sequelize");
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
function lineItemFetching(financials_data)
|
function lineItemFetching(financials_data)
|
||||||
@ -84,6 +84,11 @@ const { logMsg } = require('../services/logger.js');
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
entityid = update_array_data[0].entityid;
|
||||||
|
|
||||||
|
|
||||||
|
var LineItemUpdate = new Promise((resolve, reject) => {
|
||||||
|
|
||||||
update_array_data.forEach((value,index) => {
|
update_array_data.forEach((value,index) => {
|
||||||
if(value.value != null)
|
if(value.value != null)
|
||||||
{
|
{
|
||||||
@ -91,6 +96,12 @@ const { logMsg } = require('../services/logger.js');
|
|||||||
.then(data => { logMsg.info("update success : "+ data); })
|
.then(data => { logMsg.info("update success : "+ data); })
|
||||||
.catch(err => { logMsg.info("update failed : " + err); });
|
.catch(err => { logMsg.info("update failed : " + err); });
|
||||||
}
|
}
|
||||||
|
if (index === update_array_data.length -1) { resolve(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
LineItemUpdate.then((Query_data)=>{
|
||||||
|
Entities.update({ "probe42_data_status": 0 },{ where: { id: entityid }});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (error)
|
catch (error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user