menulist:GWM
This commit is contained in:
parent
b26cd2138a
commit
258fc67b93
@ -65,6 +65,7 @@ exports.MenuList = (req, res) => {
|
||||
var EntityInsert = new Promise((resolve, reject) => {
|
||||
// insert pro42data into entities table using using foreach
|
||||
Pro42Data.forEach((Pro42Datavalue, key,array)=>{
|
||||
|
||||
// check if the Pro42Data (entity) already inserted
|
||||
Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
|
||||
if(Entity)
|
||||
@ -101,22 +102,21 @@ var EntityInsert = new Promise((resolve, reject) => {
|
||||
Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.year,"st_type": 1 })
|
||||
.then(Entityfinyearsdata => {
|
||||
|
||||
// create skeletion
|
||||
// generate financials data array
|
||||
// create skeletion with itemmaster data (itemmaster(id) == financial(itemid))
|
||||
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 = [];
|
||||
for (let i = 1; i < 141; i++)
|
||||
{
|
||||
if(i != 124 && i != 125 && i != 130)
|
||||
{
|
||||
fin_data_obj = { "entity_id":Entityfinyearsdata.dataValues.entityid,"st_type":Entityfinyearsdata.dataValues.st_type,"itemid":i,"fy":Entityfinyearsdata.dataValues.FY,"value":0,"is_active":1,"createdby":4}
|
||||
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_array.push(fin_data_obj);
|
||||
}
|
||||
} //console.log("------"+entity_id +"---"+ fy)
|
||||
//bulk financials data create
|
||||
Financials.bulkCreate(fin_data_array).then(data=>{}).catch(err=>(console.log(err)));
|
||||
|
||||
console.log("working")
|
||||
setTimeout(() => {
|
||||
if (index === itemvaluearray.length -1) { resolve(fin_data_array); }
|
||||
})
|
||||
});
|
||||
SkeletonInsert.then((Query_data)=>{
|
||||
Financials.bulkCreate(Query_data).then(data=>{
|
||||
//line item data update
|
||||
lineItem_result.forEach((value,index,array) => {
|
||||
// mapping of probe42 api lineItem with itemMaster primary key
|
||||
final_array = Probe42DataMappingHelper.lineItemMapping(value,entityid);
|
||||
@ -125,8 +125,11 @@ var EntityInsert = new Promise((resolve, reject) => {
|
||||
Probe42DataMappingHelper.lineItemUpdate(update_array_data);
|
||||
});//end of lineItemUpdate helper call
|
||||
});//end of lineItem mapping with itemMaster primary key helper call
|
||||
}, 500);
|
||||
|
||||
}).catch(err=>(console.log(err))); //skeleton bulk create query
|
||||
});
|
||||
|
||||
}).catch(err=>(console.log(err))); //itemmaster query
|
||||
|
||||
|
||||
|
||||
@ -144,13 +147,14 @@ var EntityInsert = new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
|
||||
|
||||
if (key === array.length -1) {resolve();}
|
||||
// resolve here
|
||||
if (key === array.length -1) { resolve(); }
|
||||
|
||||
}).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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user