787 lines
23 KiB
JavaScript
787 lines
23 KiB
JavaScript
//const db = require("../models");
|
|
//const Entities = db.tutorials;
|
|
//const Op = db.Sequelize.Op;
|
|
|
|
|
|
|
|
const {Entities,sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type,Entityfinyear} = require('../models')
|
|
const { logMsg } = require('../services/logger.js');
|
|
const camundaHelper = require('../services/camunda.helper.js');
|
|
|
|
|
|
//statementmaster
|
|
|
|
// Retrieve all statements from the database.
|
|
exports.StatementsList = async (req, res) => {
|
|
|
|
await Statementsmaster.findAll()
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success -controller");
|
|
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" });
|
|
});
|
|
};
|
|
|
|
|
|
exports.Insertstatement = async (req, res) => {
|
|
// Create a statement
|
|
const statement = {
|
|
statement: req.body.statement,
|
|
is_active: req.body.is_active,
|
|
createdby: req.body.createdby,
|
|
updatedby: req.body.updatedby,
|
|
};
|
|
|
|
// Save Tutorial in the database
|
|
await Statementsmaster.create(statement)
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
// updates datas into statementmaster table.
|
|
exports.Updatestatement = async (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
await Statementsmaster.update(req.body, {
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while updating statements." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
//delete
|
|
exports.Deletestatement = async (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
await Statementsmaster.update({ is_active : 0 },{
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while deleting statements." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
|
|
//Sectionsmaster
|
|
|
|
// Retrieve all Sectionsmaster from the database.
|
|
exports.SectionList = (req, res) => {
|
|
|
|
//Sectionsmaster.findAll()
|
|
sequelize.query("SELECT sectionsmaster.id,sectionsmaster.statement as statement_id,statementsmaster.statement,sectionsmaster.section,sectionsmaster.is_active,sectionsmaster.createdby,sectionsmaster.createdon,sectionsmaster.updatedby,sectionsmaster.updatedon FROM sectionsmaster INNER JOIN statementsmaster ON sectionsmaster.statement=statementsmaster.id;")
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while retrieving sections." ,'data': "No data" });
|
|
});
|
|
};
|
|
|
|
exports.Insertsection = (req, res) => {
|
|
// Create a section
|
|
const section = {
|
|
statement: req.body.statement,
|
|
section: req.body.section,
|
|
is_active: req.body.is_active,
|
|
createdby: req.body.createdby,
|
|
updatedby: req.body.updatedby,
|
|
};
|
|
|
|
// Save section in the database
|
|
Sectionsmaster.create(section)
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.send({'status':404,
|
|
message: err.message || "Some error occurred while inserting sections." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
exports.Updatesection = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Sectionsmaster.update(req.body, {
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while updating sections." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
//delete
|
|
exports.Deletesection = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Sectionsmaster.update({ is_active : 0 },{
|
|
where: { id: id }
|
|
})
|
|
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while deleting sections." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
|
|
|
|
//Subsectionsmaster
|
|
// Retrieve all Subsectionsmaster from the database.
|
|
exports.SubsectionList = (req, res) => {
|
|
|
|
//Subsectionsmaster.findAll()
|
|
sequelize.query("SELECT subsectionsmaster.id,subsectionsmaster.section as section_id,sectionsmaster.section,subsectionsmaster.subsection,subsectionsmaster.itemtext,subsectionsmaster.is_active,subsectionsmaster.createdby,subsectionsmaster.createdon,subsectionsmaster.updatedby,subsectionsmaster.updatedon FROM subsectionsmaster INNER JOIN sectionsmaster ON subsectionsmaster.section=sectionsmaster.id")
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while retrieving subsections." ,'data': "No data" });
|
|
});
|
|
};
|
|
|
|
exports.Insertsubsection = (req, res) => {
|
|
// Create a statement
|
|
const subsection = {
|
|
section: req.body.section,
|
|
subsection: req.body.subsection,
|
|
itemtext: req.body.itemtext,
|
|
is_active: req.body.is_active,
|
|
createdby: req.body.createdby,
|
|
updatedby: req.body.updatedby,
|
|
};
|
|
|
|
// Save Tutorial in the database
|
|
Subsectionsmaster.create(subsection)
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while inserting subsection." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
exports.Updatesubsection = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Subsectionsmaster.update(req.body, {
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while updating subsection." ,'data': "No data"
|
|
});
|
|
});
|
|
|
|
};
|
|
|
|
//delete
|
|
exports.Deletesubsection = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Subsectionsmaster.update({ is_active : 0 },{
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while dleleting subsection." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
|
|
//itemsmaster
|
|
// Retrieve all itemsmaster from the database.
|
|
exports.ItemList = (req, res) => {
|
|
try
|
|
{
|
|
//Itemsmaster.findAll()
|
|
sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection,subsectionsmaster.itemtext as subsection_itemtext ,itemsmaster.itemtext,itemsmaster.is_active,pvtltd,llp,others,formula,is_calculated,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id LEFT JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id order by statement_id asc , section_id asc")
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
//logMsg.info("Success :"(data));
|
|
})
|
|
}catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
}); }
|
|
};
|
|
|
|
exports.Insertitem = (req, res) => {
|
|
// Create a item
|
|
const item = {
|
|
statement: req.body.statement,
|
|
section: req.body.section,
|
|
subsection: req.body.subsection,
|
|
itemtext: req.body.itemtext,
|
|
is_active: req.body.is_active,
|
|
pvtltd: req.body.pvtltd,
|
|
llp: req.body.llp,
|
|
others: req.body.others,
|
|
formula: req.body.formula,
|
|
is_calculated: req.body.is_calculated,
|
|
is_summary: is_summary,
|
|
createdby: req.body.createdby,
|
|
updatedby: req.body.updatedby,
|
|
};
|
|
|
|
// Save Tutorial in the database
|
|
Itemsmaster.create(item)
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while inserting items." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
exports.Updateitem = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Itemsmaster.update(req.body, {
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while updating items." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
//delete
|
|
exports.Deleteitem = (req, res) => {
|
|
const id = req.params.id;
|
|
|
|
Itemsmaster.update({ is_active : 0 },{
|
|
where: { id: id }
|
|
})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while deleting items." ,'data': "No data"
|
|
});
|
|
});
|
|
};
|
|
|
|
//ItemFilter
|
|
// Retrieve all items from the database which is under by the represent section.
|
|
exports.ItemFilter = (req, res) => {
|
|
const section = req.query.section
|
|
const statement = req.query.statement
|
|
Itemsmaster.findAll({where : { section : section}})
|
|
// sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection,subsectionsmaster.itemtext as subsection_itemtext ,itemsmaster.itemtext,itemsmaster.is_active,pvtltd,llp,others,formula,is_calculated,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id")
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
|
|
});
|
|
};
|
|
|
|
|
|
exports.createRemarks = (req, res) => {
|
|
|
|
const req_array_data = req.body;
|
|
try
|
|
{
|
|
req_array_data.forEach((value, key)=>{
|
|
if (value.hasOwnProperty("id"))
|
|
{
|
|
Fin_remarks.update({ is_active : 0 },{ where: { id: value.id }});
|
|
logMsg.info("updated is_active = 0 for primary key for Remarks: "+value.id);
|
|
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
|
logMsg.info("Created new Remarks entity_id: "+value.entity_id+"itemid:"+value.itemid);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
Fin_remarks.create({ "entity_id":value.entity_id,"itemid":value.itemid,"remarks":value.remarks,"is_active":value.is_active,"createdby":value.createdby })
|
|
logMsg.info("Created new Remarks entity_id: "+value.entity_id+"itemid:"+value.itemid);
|
|
|
|
}
|
|
});
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
}
|
|
|
|
catch(err)
|
|
{
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
});
|
|
}
|
|
};
|
|
|
|
exports.Historyapi = (req, res) => {
|
|
const reqq = req.query
|
|
//console.log(reqq)
|
|
let table_name;
|
|
if(req.query.table == "statement")
|
|
{
|
|
table_name = "statementsmaster"
|
|
console.log(table_name)
|
|
}
|
|
if(req.query.table == "section")
|
|
{
|
|
table_name = "sectionsmaster"
|
|
}
|
|
if(req.query.table == "subsection")
|
|
{
|
|
table_name = "subsectionsmaster"
|
|
}
|
|
if(req.query.table == "item")
|
|
{
|
|
table_name = "itemsmaster"
|
|
}
|
|
try
|
|
{
|
|
if (reqq.hasOwnProperty("id"))
|
|
{ console.log(table_name)
|
|
const id = req.query.id
|
|
Fin_masters_history.findAll({where: { data_id: id , table_name: table_name }}).then(data => {
|
|
if(data.length)
|
|
{
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
}
|
|
else
|
|
{
|
|
res.send({'status':404,'message':"Failed",'data':'nodata'});
|
|
}
|
|
|
|
// logMsg.info("Success :"(data));
|
|
})
|
|
}
|
|
else
|
|
{
|
|
console.log(table_name)
|
|
Fin_masters_history.findAll({where: { table_name: table_name }}).then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
//logMsg.info("Success :"(data));
|
|
})
|
|
}
|
|
}
|
|
|
|
catch(err)
|
|
{
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
});
|
|
}
|
|
};
|
|
|
|
|
|
// Retrieve all statement types from the database.
|
|
exports.Statementtype_list = (req, res) => {
|
|
|
|
Statement_type.findAll({where : { is_active : 1}})
|
|
.then(data => {
|
|
res.send({'status':200,'message':"success",'data':data});
|
|
logMsg.info("Success :"(data));
|
|
})
|
|
.catch(err => {
|
|
res.status({'status':404,
|
|
message: err.message || "Some error occurred while retrieving items." ,'data': "No data" });
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.Statementtype_insert = (req, res) => {
|
|
|
|
try
|
|
{
|
|
// const losid = req_array_data.losid;
|
|
//const entityid = req_array_data.entityid;
|
|
Entityfinyear.update({ "st_type":req.body.st_type,"updatedby":req.body.updatedby },{ where: { entityid:req.body.entityid,FY:req.body.fy}})
|
|
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
logMsg.info("Statementtype_insert Success");
|
|
}
|
|
catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting Statementtype_insert." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
|
|
|
|
// API: Cheker Complete
|
|
|
|
|
|
exports.TaskComplete = (req, res) => {
|
|
|
|
try
|
|
{
|
|
const losid = req.query.losid;
|
|
const pan = req.query.pan;
|
|
const cin = req.query.cin;
|
|
Entities.findOne({where : { losid : losid,pan : pan,cin : cin },attributes: [ 'id','process_instance_id'] })
|
|
.then(data => {
|
|
const processInstanceId = data.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id){
|
|
if(task_id != false){
|
|
value = true;
|
|
camundaHelper.financialsTaskComplete(task_id,value)
|
|
} });
|
|
});
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},1000)
|
|
logMsg.info("Cheker Completed Success");
|
|
}
|
|
catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while Cheker Complete." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
exports.ReInitiate = async (req, res) => {
|
|
try
|
|
{
|
|
const losid = req.query.losid;
|
|
const pan = req.query.pan;
|
|
const cin = req.query.cin;
|
|
const user = "SMC"
|
|
Entities.findOne({where : { losid : losid,pan : pan,cin : cin },attributes: ['id'] })
|
|
.then(data => {
|
|
const primaryId = data.dataValues.id;
|
|
console.log(primaryId)
|
|
processInstanceId = camundaHelper.startFinancialsProcessInstance(losid,pan,user);
|
|
console.log(processInstanceId)
|
|
processInstanceId.then(function(InstanceId){
|
|
console.log(InstanceId)
|
|
//Entities.update({ "process_instance_id" : InstanceId },{ where: { id: primaryId }})
|
|
Entities.update({ "process_instance_id":InstanceId },{ where: { id: primaryId }})
|
|
.then(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
})
|
|
.catch(err => {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "processInstanceId not updated in entities table." ,'data': "No data" });
|
|
});
|
|
});
|
|
})
|
|
.catch(err => {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Data not found." ,'data': "No data" });
|
|
});
|
|
}
|
|
|
|
catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while Cheker Complete." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
|
|
exports.Reassign = async (req, res) => {
|
|
try
|
|
{
|
|
const id = req.query.entityid;
|
|
console.log(id);
|
|
|
|
Entities.findOne({where : { id : id },attributes: ['process_instance_id'] })
|
|
.then(data => {
|
|
const processInstanceId = data.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id){
|
|
console.log(task_id)
|
|
if(task_id != false){
|
|
value = false
|
|
camundaHelper.financialsTaskComplete(task_id,value)
|
|
}
|
|
});
|
|
});
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},1000)
|
|
logMsg.info("Cheker Completed Success");
|
|
}
|
|
catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while Cheker Complete." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
exports.makerComplete = (req, res) => {
|
|
try
|
|
{
|
|
const losid = req.query.losid;
|
|
const entityid = req.query.entityid;
|
|
|
|
if(losid)
|
|
{
|
|
Entities.findAll({where : { losid : losid },attributes: [ 'id','process_instance_id'] })
|
|
.then(data => {
|
|
data.forEach((AllEntityData, key)=>{
|
|
processInstanceId = AllEntityData.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id)
|
|
{
|
|
if(task_id != false)
|
|
{
|
|
formVariable = camundaHelper.financialsFormVariables(task_id);
|
|
formVariable.then(function(form_result){
|
|
formVariableResult = JSON.parse(form_result);
|
|
let camunda_status = formVariableResult.process_status.value;
|
|
if(camunda_status == "re_started" || camunda_status == "started")
|
|
{
|
|
value = true;
|
|
camundaHelper.financialsTaskComplete(task_id,value);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});// end of foreach
|
|
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},3000)
|
|
});//end of findAll query
|
|
}
|
|
else if(entityid)
|
|
{
|
|
Entities.findOne({where : { id : entityid },attributes: [ 'id','process_instance_id'] })
|
|
.then(data => {
|
|
const processInstanceId = data.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id)
|
|
{
|
|
if(task_id != false)
|
|
{
|
|
value = true;
|
|
camundaHelper.financialsTaskComplete(task_id,value);
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},1000)
|
|
}
|
|
});
|
|
});//end of find one query
|
|
} // end of else if part
|
|
|
|
}catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while Cheker Complete." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
exports.checkerComplete = (req, res) => {
|
|
try
|
|
{
|
|
const losid = req.query.losid;
|
|
const entityid = req.query.entityid;
|
|
|
|
if(losid)
|
|
{
|
|
console.log(losid);
|
|
Entities.findAll({where : { losid : losid },attributes: [ 'id','process_instance_id'] })
|
|
.then(data => {
|
|
data.forEach((AllEntityData, key)=>{
|
|
processInstanceId = AllEntityData.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id)
|
|
{
|
|
if(task_id != false)
|
|
{
|
|
formVariable = camundaHelper.financialsFormVariables(task_id);
|
|
formVariable.then(function(form_result){
|
|
formVariableResult = JSON.parse(form_result);
|
|
let camunda_status = formVariableResult.process_status.value;
|
|
if(camunda_status == "maker_completed" )
|
|
{
|
|
value = true;
|
|
camundaHelper.financialsTaskComplete(task_id,value);
|
|
// update is_verified = 1
|
|
Entities.update({ "is_verified": 1 },{ where: { id: AllEntityData.id }});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});// end of foreach
|
|
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},3000)
|
|
});//end of findAll query
|
|
}
|
|
else if(entityid)
|
|
{
|
|
console.log(entityid);
|
|
Entities.findOne({where : { id : entityid },attributes: [ 'id','process_instance_id'] })
|
|
.then(data => {
|
|
const processInstanceId = data.dataValues.process_instance_id;
|
|
task_id = camundaHelper.financialsListOfProcessInstances(processInstanceId);
|
|
task_id.then(function(task_id)
|
|
{
|
|
if(task_id != false)
|
|
{
|
|
value = true;
|
|
camundaHelper.financialsTaskComplete(task_id,value);
|
|
// update is_verified key = 1
|
|
Entities.update({ "is_verified": 1 },{ where: { id: entityid }});
|
|
setTimeout(()=>{
|
|
res.send({'status':200,'message':"success",'data':"No data"});
|
|
},1000)
|
|
}
|
|
});
|
|
});//end of find one query
|
|
} // end of else if part
|
|
|
|
}catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while Cheker Complete." ,'data': "No data"
|
|
}); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|