updateCin:GWM
This commit is contained in:
parent
eef1766c73
commit
a52a85d065
@ -81,8 +81,9 @@ exports.MenuList = async (req, res) => {
|
|||||||
redirectionApiData.forEach((Pro42Datavalue, key,array)=>{
|
redirectionApiData.forEach((Pro42Datavalue, key,array)=>{
|
||||||
|
|
||||||
let cin_number = Pro42Datavalue.ciN_LLPIN.toUpperCase();
|
let cin_number = Pro42Datavalue.ciN_LLPIN.toUpperCase();
|
||||||
|
// , cin : cin_number
|
||||||
// check if the Pro42Data (entity) already inserted
|
// check if the Pro42Data (entity) already inserted
|
||||||
Entities.findOne({ where: { losid : Pro42Datavalue.loginNo , pan : Pro42Datavalue.pan , cin : cin_number } }).then(Entity => {
|
Entities.findOne({ where: { losid : Pro42Datavalue.loginNo , pan : Pro42Datavalue.pan } }).then(Entity => {
|
||||||
if(Entity)
|
if(Entity)
|
||||||
{
|
{
|
||||||
// skip inserting
|
// skip inserting
|
||||||
@ -96,9 +97,16 @@ exports.MenuList = async (req, res) => {
|
|||||||
const cin = Entitydata.dataValues.cin;
|
const cin = Entitydata.dataValues.cin;
|
||||||
if(cin != "")
|
if(cin != "")
|
||||||
{
|
{
|
||||||
//process instance Id update
|
|
||||||
const entityid = Entitydata.dataValues.id;
|
const entityid = Entitydata.dataValues.id;
|
||||||
const user = "SMC";
|
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
|
||||||
|
{
|
||||||
|
// create skeleton here
|
||||||
|
financialControllerHelper.createSkeleton(losid,entityid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
|
// processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user);
|
||||||
// processInstanceId.then(function(InstanceId){
|
// processInstanceId.then(function(InstanceId){
|
||||||
// console.log("startFinancialsProcessInstance data");
|
// console.log("startFinancialsProcessInstance data");
|
||||||
@ -165,6 +173,12 @@ exports.MenuList = async (req, res) => {
|
|||||||
} // end of probe42 api responce success else condition
|
} // end of probe42 api responce success else condition
|
||||||
});//end of probe42 api call
|
});//end of probe42 api call
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if(Entitydata.dataValues.entity_type == 'PROPRIETORSHIP')
|
||||||
|
{
|
||||||
|
// create skeleton here
|
||||||
|
financialControllerHelper.createSkeleton(losid,Entitydata.dataValues.id);
|
||||||
|
}
|
||||||
// resolve here
|
// resolve here
|
||||||
if (key === array.length -1) { resolve(); }
|
if (key === array.length -1) { resolve(); }
|
||||||
logMsg.info("CIN no not exist for losid = "+losid+" and entity name ="+Entitydata.dataValues.bizname);
|
logMsg.info("CIN no not exist for losid = "+losid+" and entity name ="+Entitydata.dataValues.bizname);
|
||||||
@ -261,6 +275,112 @@ exports.MenuList = async (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.updateEntityCin = (req, res) => {
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var EntityCINUpdate = new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
Entities.update({ "cin":req.body.cin}, {where : { id: req.body.id }}).then(async(data) => {
|
||||||
|
|
||||||
|
Entities.findOne({where : { id : req.body.id , losid : req.body.losid } })
|
||||||
|
.then(async(Entitydata) => {
|
||||||
|
|
||||||
|
const losid = Entitydata.dataValues.losid;
|
||||||
|
const cin = Entitydata.dataValues.cin;
|
||||||
|
const entityid = Entitydata.dataValues.id;
|
||||||
|
|
||||||
|
|
||||||
|
// call and get financial year wise data for entity (probe42 api call)
|
||||||
|
financials_data_api_response = ApiCallHelper.probe42ApiCall(cin);
|
||||||
|
financials_data_api_response.then(function(result){
|
||||||
|
|
||||||
|
if(result == false)
|
||||||
|
{
|
||||||
|
// create skeleton here
|
||||||
|
financialControllerHelper.createSkeleton(losid,entityid);
|
||||||
|
//EntityCINUpdate resolve
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//filter lineitems from api responce and construct to needed format
|
||||||
|
lineItem_data = Probe42DataMappingHelper.lineItemFetching(result);
|
||||||
|
lineItem_data.then(function(lineItem_result){
|
||||||
|
|
||||||
|
//create financial table and entityfinyear table record here
|
||||||
|
lineItem_result.forEach((value, key)=>{
|
||||||
|
|
||||||
|
Entityfinyear.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"FY":value.year,"st_type": 0 })
|
||||||
|
.then(Entityfinyearsdata => {
|
||||||
|
|
||||||
|
// create skeletion with itemmaster data (itemmaster(id) == financial(itemid))
|
||||||
|
Itemsmaster.findAll({ where :{pvtltd:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['pvtltd_itemorder', 'ASC']] })
|
||||||
|
.then(ItemsmasterData => {
|
||||||
|
//construct lineitem array for bulk insert using itemmaster primarykey (id)
|
||||||
|
var SkeletonInsert = new Promise((resolve, reject) => {
|
||||||
|
let fin_data_array = [];
|
||||||
|
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);
|
||||||
|
if (index === itemvaluearray.length -1) { resolve(fin_data_array); }
|
||||||
|
})
|
||||||
|
});
|
||||||
|
SkeletonInsert.then((Query_data)=>{
|
||||||
|
Financials.bulkCreate(Query_data).then(data=>{
|
||||||
|
//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){
|
||||||
|
// update mapped lineitem value here
|
||||||
|
Probe42DataMappingHelper.lineItemUpdate(update_array_data);
|
||||||
|
//EntityCINUpdate resolve
|
||||||
|
resolve();
|
||||||
|
});//end of lineItemUpdate helper call
|
||||||
|
}).catch(err=>(console.log(err))); //skeleton bulk create query
|
||||||
|
});
|
||||||
|
}).catch(err=>(console.log(err))); //itemmaster query
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}).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
|
||||||
|
|
||||||
|
});//end of line item foreach
|
||||||
|
});//end of lineItem filter from api response helper call
|
||||||
|
} // end of probe42 api responce success else condition
|
||||||
|
});//end of probe42 api call
|
||||||
|
|
||||||
|
|
||||||
|
}).catch(err => {res.status(404).send({'status':404,message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });}); // end of entity insert
|
||||||
|
}).catch(err => { res.status(404).send({'status':404,message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" }); });
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EntityCINUpdate.then(async() => {
|
||||||
|
|
||||||
|
res.send({'status':200,'message':"success",'data':"No data"});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}catch(err) {
|
||||||
|
res.send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1111,6 +1111,17 @@ router.get("/deActivateFinancialsYear", financials.deActivateFinancialsYear);
|
|||||||
*/
|
*/
|
||||||
router.get("/getFinancialsYears", financials.getFinancialsYears);
|
router.get("/getFinancialsYears", financials.getFinancialsYears);
|
||||||
|
|
||||||
|
|
||||||
|
router.post("/updateEntityCin", financials.updateEntityCin);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// third party api call example
|
// third party api call example
|
||||||
router.get('/third_party_api', (req, res) => {
|
router.get('/third_party_api', (req, res) => {
|
||||||
// const options = {
|
// const options = {
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const app = express()
|
const app = express()
|
||||||
|
// Enable CORS for all routes
|
||||||
|
const cors = require('cors');
|
||||||
|
app.use(cors());
|
||||||
|
|
||||||
|
|
||||||
//it is used to clear cache
|
//it is used to clear cache
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")
|
res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user