diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 0dc6c65..5dc8651 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -613,14 +613,14 @@ exports.BrokenPeriods = (req, res) => { -exports.createFinancials = (req, res) => { +exports.createFinancials = async (req, res) => { const req_array_data = req.body; try { - req_array_data.forEach((value, key)=>{ + req_array_data.forEach(async(value, key)=>{ - Financials.findOne({ where: { id : value.id , is_active : 1} }).then(function(result) { + await Financials.findOne({ where: { id : value.id , is_active : 1} }).then(async function(result) { if(result.value == value.value) { @@ -628,9 +628,9 @@ exports.createFinancials = (req, res) => { } else { - Financials.update({ is_active : 0 },{ where: { id: value.id }}); + await Financials.update({ is_active : 0 },{ where: { id: value.id }}); logMsg.info("updated is_active = 0 for primary key : "+value.id); - Financials.create({ "entity_id":value.entity_id,"st_type":value.st_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"sub_value":value.sub_value,"is_active":value.is_active,"createdby":value.createdby }) + await Financials.create({ "entity_id":value.entity_id,"st_type":value.st_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"sub_value":value.sub_value,"is_active":value.is_active,"createdby":value.createdby }) logMsg.info("Created new financials data - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid); } }) @@ -883,8 +883,17 @@ exports.checkProbeStatus = (req, res) => { +// this api for other income module +exports.getFinancialsYears = async (req, res) => { + try + { + data = await Entityfinyear.findAll({where : { losid : req.query.losid } , attributes: [ [sequelize.fn('DISTINCT', sequelize.col('FY')), 'FY'] ] , order: [['FY', 'DESC']] }) + res.send({'status':200,"message": "success." ,'data': data}); + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data"}); + } - + }; @@ -896,32 +905,8 @@ exports.checkProbeStatus = (req, res) => { exports.test = async (req, res) => { try { - - - // const str = 'a v:ery (long) string'; - // console.log(str) - // var remove_spl_char = str.replace(/[^a-zA-Z ]/g, "") - // console.log(remove_spl_char) - // var strUnderscores = remove_spl_char.replace(/\s+/g, '_'); - // console.log(strUnderscores) - // TempItemMaster.findAll({raw : true ,where :{statement:3 , section:17} , attributes: [ 'id' , 'itemtext' ] }) - // .then(async(ItemsmasterData) => { - - // for( value of ItemsmasterData) - // { - // var txt = value.itemtext; - // var txt1 = txt.slice(0, 15) - // var txt2 = txt1.replace(/[^a-zA-Z ]/g, ""); - // var txt3 = txt2.replace(/\s+/g, '_'); - // var txt4 = "cf_cff_"+txt3; - // var txt5 = txt4.toLowerCase(); - // console.log(txt5); - - // await TempItemMaster.update({ itemkey : txt5 } , { where: { id: value.id }}); - // } - // }); - -}catch(err) { + 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"}); } @@ -929,61 +914,10 @@ exports.test = async (req, res) => { - exports.demo = async (req, res) => { - try - { + // exports.redirectionApitest = async (req, res) => { + // try + // { - key = "manual"; - Itemsmaster.findAll({ where :{manual:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['itemorder', 'ASC']] }) - .then(ItemsmasterData => { - res.send(ItemsmasterData); - }); - - - - // Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}}) - // .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' ] }) - // .then(EntitiesData => { - - - // let data = []; - // var getCamundaStatus = new Promise(async (resolve, reject) => { - - // await EntitiesData.forEach(async (value, key , array)=>{ - - // instancesid = value.dataValues.process_instance_id; - // taskid = await camundaHelper.financialsListOfProcessInstances(instancesid); - - // formVariable = await camundaHelper.financialsFormVariables(taskid); - - // formVariableResult = await JSON.parse(formVariable); - // if(formVariableResult.type){ camunda_status = {"process_status":"NULL"}; } else { camunda_status = formVariableResult; } - // obj_data = { ...value.dataValues ,status:camunda_status , statementsmasterrData:MasterData } - // data.push(obj_data); - // if (key === array.length -1) { resolve(); } - // }); // end of EntitiesData foreach - - // }); - - // getCamundaStatus.then(()=>{ - // // below code for overall sum object push process - // sum_data = { ...{'losid':losid,'bizname':"Consolidated Financials Summary",'is_consolidated_api_call':1} , statementsmasterrData:MasterData }; - // data.push(sum_data); - // // send respose to FE - // res.send({'status':200,'message':"success",'data':data}); - // }); - - // }); // end of findall EntitiesData - // }); // end of findall masters datas - - - - - - - - // redirectionApi = ApiCallHelper.redirectionApiCall(losid); @@ -1013,11 +947,11 @@ exports.test = async (req, res) => { // });//end of probe42 api call // }); - }catch(err) { - res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data"}); - } + // }catch(err) { + // res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data"}); + // } - }; + // }; @@ -1037,7 +971,7 @@ exports.test = async (req, res) => { - // exports.demoone = (req, res) => { + // exports.probedatatest = (req, res) => { // Sync(function() // { // try diff --git a/app/routes/routes.js b/app/routes/routes.js index 60474d4..ecf9d17 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -7,8 +7,8 @@ module.exports = app => { const { logMsg } = require('../services/logger.js'); var router = require("express").Router(); - router.get("/demo", financials.demo); - /** + router.get("/test", financials.test); +/** * @swagger * /api/checkProbeStatus: * get: @@ -1025,7 +1025,7 @@ module.exports = app => { router.get("/makerComplete", master.makerComplete); - /** +/** * @swagger * /api/checkerComplete: * get: @@ -1056,6 +1056,28 @@ module.exports = app => { + + + +/** +* @swagger +* /api/getFinancialsYears: +* get: +* summary: getFinancialsYears(other income module) +* description: getFinancialsYears +* parameters: +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: losid +* example: MW112233 +* responses: +* 200: +* description: success +*/ +router.get("/getFinancialsYears", financials.getFinancialsYears); // third party api call example router.get('/third_party_api', (req, res) => {