From 0c6763554839bee1b1285af75659731fc02e9220 Mon Sep 17 00:00:00 2001 From: sriramv Date: Thu, 7 Apr 2022 10:52:45 +0530 Subject: [PATCH] swagger --- app/controllers/financial.controller.js | 35 ++++++++------ app/controllers/master.controller.js | 6 +-- app/routes/routes.js | 61 ++++++++++++------------- 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 9cfc9d3..1f3e64e 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -393,7 +393,7 @@ exports.ConsolidatedSummary = async (req, res) => { } }); // end of foreach - var query = "Select x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,g.subsection as subsection , g.itemtext as subsection_itemtext, a.itemid,e.itemtext as items,e.is_summary,e.itemorder,e.pvtltd_itemorder,a.fy as Y1 , SUM(a.value) as Y1_value"+ select_items +" from entities z JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+year_1+"'and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) a ON z.id = a.entity_id" + sub_query + " JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary,itemorder,pvtltd_itemorder FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) g ON e.subsection = g.id where losid = '"+losid+"' GROUP BY a.itemid,x.id,x.statement,y.id,y.section,e.subsection,g.subsection,g.itemtext,e.itemtext,e.statement,e.section,e.id,a.fy,e.is_summary " + group + " ORDER BY e.statement asc , e.section asc asc" + var query = "Select x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,g.subsection as subsection , g.itemtext as subsection_itemtext, a.itemid,e.itemtext as items,e.is_summary,e.itemorder,e.pvtltd_itemorder,a.fy as Y1 , SUM(a.value) as Y1_value"+ select_items +" from entities z JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+year_1+"'and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) a ON z.id = a.entity_id" + sub_query + " JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated,is_summary,itemorder,pvtltd_itemorder FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) g ON e.subsection = g.id where losid = '"+losid+"' GROUP BY a.itemid,x.id,x.statement,y.id,y.section,e.subsection,g.subsection,g.itemtext,e.itemtext,e.statement,e.section,e.id,a.fy,e.is_summary,e.itemorder,e.pvtltd_itemorder " + group + " ORDER BY e.statement asc , e.section asc " setTimeout(function(){ sequelize.query(query) @@ -540,7 +540,7 @@ exports.createFinancials = (req, res) => { { 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,"is_active":value.is_active,"createdby":value.createdby }) + 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); } }) @@ -573,7 +573,7 @@ exports.updateFinancials = (req, res) => { message: err.message || "Some error occurred while inserting statements." ,'data': "No data" }); } -}; +}; @@ -586,9 +586,10 @@ exports.updateFinancials = (req, res) => { exports.createFinancialYear = async (req, res) => { losid = req.body.losid; entityid = req.body.entityid; + probe42_data_status = req.body.probe42_data_status; Entityfinyear.findOne({ where: { losid : losid , entityid : entityid } }) - .then(Entityfinyearsdata => { + .then(async(Entityfinyearsdata) => { const fy = req.body.fy; const st_type = req.body.st_type; @@ -597,13 +598,21 @@ exports.createFinancialYear = async (req, res) => { if(req.body.fy != 0) { Entityfinyear.create({ losid:Entityfinyearsdata.dataValues.losid,entityid:Entityfinyearsdata.dataValues.entityid,FY:fy,st_type:st_type,additional_year_type:additional_year_type }) - .then(Entityfinyearsdata => { + .then(async(Entityfinyearsdata) => { // generate new financials data array for given FY with entity_id - Itemsmaster.findAll({ where :{is_active : 1},attributes: ['id'] , order: [['id', 'ASC']] }) - .then(ItemsmasterData => { - - + + // Itemsmaster.findAll({ where :{is_active : 1},attributes: ['id'] , order: [['id', 'ASC']] }) + // .then(ItemsmasterData => { + if(probe42_data_status == 0) + { + ItemsmasterData = await Itemsmaster.findAll({ where :{pvtltd:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['pvtltd_itemorder', 'ASC']] }); + } + else if(probe42_data_status == 2) + { + ItemsmasterData = await Itemsmaster.findAll({ where :{manual:1,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC'],['itemorder', 'ASC']] }); + } + //construct lineitem array for bulk insert using itemmaster primarykey (id) var SkeletonInsert = new Promise((resolve, reject) => { @@ -625,7 +634,7 @@ exports.createFinancialYear = async (req, res) => { - }).catch(err=>(console.log(err))); //itemmaster query + //}).catch(err=>(console.log(err))); //itemmaster query }).catch(err => { res.status(404).send({'status':404, @@ -650,7 +659,7 @@ exports.createFinancialYear = async (req, res) => { -exports.refreshApi = (req, res) => { +exports.refreshApi = async (req, res) => { try { @@ -697,7 +706,7 @@ exports.refreshApi = (req, res) => { .then(Entityfinyearsdata => { // create skeletion with itemmaster data (itemmaster(id) == financial(itemid)) - Itemsmaster.findAll({ where :{is_active : 1},attributes: ['id'] , order: [['id', 'ASC']] }) + Itemsmaster.findAll({ where :{pvtltd : 1 ,is_active : 1},attributes: ['id'] , order: [['statement', 'ASC'],['section', 'ASC']] }) .then(ItemsmasterData => { //construct lineitem array for bulk insert using itemmaster primarykey (id) var SkeletonInsert = new Promise((resolve, reject) => { @@ -798,7 +807,7 @@ 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, "") diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 1b6f017..b2c1623 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -4,7 +4,7 @@ -const {Entities,sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type,Entityfinyears} = require('../models') +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'); @@ -452,12 +452,12 @@ exports.Statementtype_list = (req, res) => { exports.Statementtype_insert = (req, res) => { - const req_array_data = req.body; + try { // const losid = req_array_data.losid; //const entityid = req_array_data.entityid; - Entityfinyears.update({ "Y1_st_type":req_array_data.Y1_st_type,"Y2_st_type":req_array_data.Y2_st_type,"Y3_st_type":req_array_data.Y3_st_type,"Y4_st_type":req_array_data.Y4_st_type,"updatedby":req_array_data.updatedby },{ where: { 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"); diff --git a/app/routes/routes.js b/app/routes/routes.js index 4cbc0bf..50c9dd7 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -7,7 +7,7 @@ module.exports = app => { const { logMsg } = require('../services/logger.js'); var router = require("express").Router(); - router.get("/test", financials.demo); + router.get("/test", financials.test); /** * @swagger * /api/checkProbeStatus: @@ -21,7 +21,7 @@ module.exports = app => { * type: integer * required: true * description: primary id of entity object -* example: 304 +* example: 319 * - in: query * name: probe42_data_status * schema: @@ -44,15 +44,15 @@ module.exports = app => { * losid: * type: string * description: losid -* example: MW00075486 +* example: MW83333683 * entityid: * type: integer * description: entityid -* example: 279 +* example: 317 * cin: * type: integer * description: cin number -* example: U45209DL2007PTC162603 +* example: U92140KL2015PTC038339 */ /** * @swagger @@ -85,7 +85,7 @@ module.exports = app => { * type: string * required: true * description: LOSID -* example: MW112233 +* example: MW83333683 * responses: * 200: * description: success @@ -106,7 +106,7 @@ module.exports = app => { * type: integer * required: true * description: id of the Entity -* example: 7 +* example: 317 * responses: * 200: * description: success @@ -127,7 +127,7 @@ module.exports = app => { * type: string * required: true * description: Los id of entity -* example: MW112233 +* example: MW83333683 * responses: * 200: * description: success @@ -148,7 +148,7 @@ module.exports = app => { * type: integer * required: true * description: id of the Entity -* example: 7 +* example: 317 * responses: * 200: * description: success @@ -181,7 +181,7 @@ module.exports = app => { * entity_id: * type: integer * description: primary id of entity -* example: 1 +* example: 317 * from: * type: date * description: selected date @@ -249,11 +249,11 @@ module.exports = app => { * losid: * type: string * description: losid -* example: MW12233 +* example: MW83333683 * entityid: * type: integer * description: entityid -* example: 1 +* example: 318 * fy: * type: integer * description: financial Year @@ -266,6 +266,10 @@ module.exports = app => { * type: integer * description: additional year type * example: 2 +* probe42_data_status: +* type: integer +* description: probe42 api data status (if status = 2(probe failed) it will create manual case skeleton . if status = 0(probe success) it will create probe case skeleton) +* example: 2 */ /** * @swagger @@ -306,23 +310,15 @@ module.exports = app => { * entityid: * type: integer * description: entityid -* example: 1 -* Y1_st_type: +* example: 317 +* fy: +* type: integer +* description: year +* example: 2022 +* st_type: * type: integer -* description: First Year statement type +* description: Year statement type * example: 1 -* Y2_st_type: -* type: integer -* description: Second Year statement type -* example: 1 -* Y3_st_type: -* type: integer -* description: Third Year statement type -* example: 1 -* Y4_st_type: -* type: integer -* description: fourth Year statement type -* example: 1 or null * updatedby: * type: integer * description: The person who modified @@ -346,7 +342,7 @@ module.exports = app => { * description: failure in inserting Statementtype */ router.post("/Statementtype_insert", master.Statementtype_insert); - router.get("/intiator", test.intiator); + /** * @swagger * definitions: @@ -372,12 +368,13 @@ module.exports = app => { */ + + + + //master.controller api's -// get statment master data - - //logMsg.info("Success -route "); - /** +/** * @openapi * /api/StatementsList: * get: