diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index f04a7a1..0757a30 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -67,10 +67,10 @@ exports.MenuList = async (req, res) => { { //Redirection api call with losid redirectionApi = ApiCallHelper.redirectionApiCall(losid); + redirectionApi.then(function(redirectionApiData){ if(redirectionApiData == false) { - resolve(); logMsg.info("Redirection api data fetching failed for losid = "+losid); } @@ -90,7 +90,6 @@ exports.MenuList = async (req, res) => { } else { - Entities.create({ "losid":Pro42Datavalue.loginNo,"pan":Pro42Datavalue.pan,"cin":cin_number,"bizname":Pro42Datavalue.entityName,"entity_type":Pro42Datavalue.entityType,"probe42_data_status":1,"is_verified":0,"createdby":Pro42Datavalue.createdby}) .then(Entitydata => { logMsg.info("entity created , data:"+Entitydata); @@ -100,12 +99,14 @@ exports.MenuList = async (req, res) => { //process instance Id update const entityid = Entitydata.dataValues.id; const user = "SMC"; - processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user); - processInstanceId.then(function(InstanceId){ - Entities.update({ "process_instance_id":InstanceId },{ where: { id: entityid }}).then(processInstanceIdData =>{ - // resolve here - if (key === array.length -1) { resolve(); } }).catch(err=>{ logMsg.info("camunda process_instance_id creation for entity_id= "+entityid); }); - }); + // processInstanceId = camundaHelper.startFinancialsProcessInstance(Entitydata.dataValues.losid,Entitydata.dataValues.pan,user); + // processInstanceId.then(function(InstanceId){ + // console.log("startFinancialsProcessInstance data"); + // console.log(InstanceId); + // Entities.update({ "process_instance_id":InstanceId },{ where: { id: entityid }}).then(processInstanceIdData =>{ + // // resolve here + // if (key === array.length -1) { resolve(); } }).catch(err=>{ logMsg.info("camunda process_instance_id creation for entity_id= "+entityid); }); + // }); // call and get financial year wise data for entity (probe42 api call) financials_data_api_response = ApiCallHelper.probe42ApiCall(cin); @@ -199,7 +200,6 @@ exports.MenuList = async (req, res) => { .then(MasterData => { Entities.findAll({where : { losid } , attributes: [ 'id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' , 'process_instance_id' , 'probe42_data_status' ,'is_verified' ], order: [['id', 'ASC']] }) .then(async(EntitiesData) => { - let Time = 2000; let data = []; @@ -222,18 +222,10 @@ exports.MenuList = async (req, res) => { for(const value of EntitiesData) { - Time = Time + 500; - instancesid = value.dataValues.process_instance_id; - taskid = await camundaHelper.financialsListOfProcessInstances(instancesid); - Time = Time + 500; - formVariable = await camundaHelper.financialsFormVariables(taskid); - formVariableResult = JSON.parse(formVariable); - if(formVariableResult.type){ camunda_status = {"process_status":"NULL"}; } else { camunda_status =JSON.parse(formVariable); } - obj_data = { ...value.dataValues ,status:camunda_status , statementsmasterrData:MasterData } + obj_data = { ...value.dataValues , statementsmasterrData:MasterData } data.push(obj_data); } // end of for loop - setTimeout(()=>{ if(data.length > 1) { // below code for overall sum object push process @@ -252,7 +244,6 @@ exports.MenuList = async (req, res) => { res.send({'status':404,'message':"failed",'data':"data not found"}); } - },Time) }); // end of findall EntitiesData }); // end of findall masters datas @@ -419,10 +410,10 @@ sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.state 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,w.itemkey,w.itemorder,w.pvtltd_itemorder,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,a.sub_value as Y1_sub_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,itemkey,itemorder,pvtltd_itemorder,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 "; // get camunda status - taskid = await camundaHelper.financialsListOfProcessInstances(instancesid); - formVariable = await camundaHelper.financialsFormVariables(taskid); - formVariableResult = JSON.parse(formVariable); - if(formVariableResult.type){ camunda_status = {"process_status":"NULL"}; } else { camunda_status =JSON.parse(formVariable); } + // taskid = await camundaHelper.financialsListOfProcessInstances(instancesid); + // formVariable = await camundaHelper.financialsFormVariables(taskid); + // formVariableResult = JSON.parse(formVariable); + // if(formVariableResult.type){ camunda_status = {"process_status":"NULL"}; } else { camunda_status =JSON.parse(formVariable); } // execute constructed financial summary query sequelize.query(query).then(async(summary) => { @@ -438,7 +429,7 @@ sequelize.query("select a.losid,a.entityid,a.FY,a.st_type as st_type_id, b.state }); - res.send({'status':200,'message':"success",'data':{"years" : years , formula_obj : formula_obj ,"add_new_finyear_flag" : add_new_FY_flag , status:camunda_status,"summary" : is_summary_item_array , "fin_summary" : summary } }); + res.send({'status':200,'message':"success",'data':{"years" : years , formula_obj : formula_obj ,"add_new_finyear_flag" : add_new_FY_flag,"summary" : is_summary_item_array , "fin_summary" : summary } }); }).catch(err => { res.status(500).send({'status':404, diff --git a/app/services/camunda.helper.js b/app/services/camunda.helper.js index 0cc4918..e036613 100644 --- a/app/services/camunda.helper.js +++ b/app/services/camunda.helper.js @@ -6,6 +6,7 @@ const URL = process.env.CAMUNDA_URL { try { + console.log("1"); const start_url = URL+"process-definition/"+DEFINITION_ID+"/start"; const businessKey = losid+"-"+cin+"-"+user; const myJSONObject = { @@ -22,6 +23,7 @@ const URL = process.env.CAMUNDA_URL json: true, body: myJSONObject }, function (error, response, body){ + console.log(body); let data = body; instancesid = data.id; resolve(instancesid); @@ -39,6 +41,7 @@ const URL = process.env.CAMUNDA_URL { try { + console.log("1"); const task_id_url = URL+"task"; const myJSONObject = { "processInstanceIdIn":[instancesid] }; return new Promise((resolve, reject) => { @@ -75,7 +78,7 @@ const URL = process.env.CAMUNDA_URL { try { - + console.log("1"); const task_complete_url = URL+"task/"+taskid+"/complete"; const myJSONObject = {"variables":{"review_status":{"value":value}}}; @@ -100,6 +103,7 @@ const URL = process.env.CAMUNDA_URL { try { + console.log("1"); const form_variable_url = URL+"task/"+taskid+"/form-variables"; return new Promise((resolve, reject) => { request({ diff --git a/app/services/financials.apicall.helper.js b/app/services/financials.apicall.helper.js index e8d8f22..1cca28d 100644 --- a/app/services/financials.apicall.helper.js +++ b/app/services/financials.apicall.helper.js @@ -60,7 +60,6 @@ function redirectionApiCall(losid) { json: true, body: myJSONObject }, function (error, response, body) { - if (body != undefined) { if (body.status == "Success" && body.data.length != 0) { resolve(body.data); diff --git a/package-lock.json b/package-lock.json index 124ce19..22e2964 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1362,9 +1362,9 @@ "integrity": "sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q==" }, "fibers": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.0.tgz", - "integrity": "sha512-UpGv/YAZp7mhKHxDvC1tColrroGRX90sSvh8RMZV9leo+e5+EkRVgCEZPlmXeo3BUNQTZxUaVdLskq1Q2FyCPg==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.3.tgz", + "integrity": "sha512-/qYTSoZydQkM21qZpGLDLuCq8c+B8KhuCQ1kLPvnRNhxhVbvrpmH9l2+Lblf5neDuEsY4bfT7LeO553TXQDvJw==", "requires": { "detect-libc": "^1.0.3" } @@ -3039,7 +3039,7 @@ "sync": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/sync/-/sync-0.2.5.tgz", - "integrity": "sha1-ORC7m2ar7lZULi5w8M5UkDElLfY=", + "integrity": "sha512-g7UDPo8z33h0KAr1cXDU0UzV3LTHONom/EuU7oyEgTEf4/sWR8OYzvKYwiEYqgCmMlbF8YQutoDAfw3hsDU5EQ==", "requires": { "fibers": ">=0.6" }