diff --git a/.gitignore b/.gitignore index 3b517ec..478b61e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /node_modules /storage .env +/app/controllers/test.controller.js diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 62aa210..c7b8890 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -1,4 +1,3 @@ - const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models') const { logMsg } = require('../services/logger.js'); @@ -39,42 +38,46 @@ exports.MenuList = (req, res) => { try { const losid = req.query.losid // call starter function here - // req_obj ={"losid":losid} - // starter_response = starter(req_obj); - // if(starter_response.status == 200) - // { - Statementsmaster.findAll({ - where :{is_active : 1} , - attributes: ['id', 'statement', 'is_active'], - include :[{ - association: 'sectionsmasterData' , - where :{is_active : 1} , - attributes: ['id', 'section', 'is_active'], - include :[{ - association: 'subsectionsmasterData' , - where :{is_active : 1} , - attributes: ['id', 'subsection','itemtext', 'is_active'], - required :false - }], - required :false - }], - required :false - }) - .then(MasterData => { - Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] }) - .then(EntitiesData => { - let data = []; - EntitiesData.forEach((value, key)=>{ - obj_data = { ...value.dataValues , statementsmasterrData:MasterData } - - data.push(obj_data); - }); // end of EntitiesData foreach - - res.send({'status':200,'message':"success",'data':data}); - logMsg.info("MenuList api working"); - }); // end of findall EntitiesData - }); // end of findall masters datas - //} // end of starter function if condition + console.log(losid) + req_obj ={"losid":losid} + + starter_response = starter(req_obj); + setTimeout(()=>{ + if(starter_response.status == 200) + { + Statementsmaster.findAll({ + where :{is_active : 1} , + attributes: ['id', 'statement', 'is_active'], + include :[{ + association: 'sectionsmasterData' , + where :{is_active : 1} , + attributes: ['id', 'section', 'is_active'], + include :[{ + association: 'subsectionsmasterData' , + where :{is_active : 1} , + attributes: ['id', 'subsection','itemtext', 'is_active'], + required :false + }], + required :false + }], + required :false + }) + .then(MasterData => { + Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] }) + .then(EntitiesData => { + let data = []; + EntitiesData.forEach((value, key)=>{ + obj_data = { ...value.dataValues , statementsmasterrData:MasterData } + + data.push(obj_data); + }); // end of EntitiesData foreach + + res.send({'status':200,'message':"success",'data':data}); + logMsg.info("MenuList api working"); + }); // end of findall EntitiesData + }); // end of findall masters datas + } // end of starter function if condition + },5000) } catch (err) { console.log(err) return res.status(500).json({'status':404,'message':"failed",'data':"No data"}) @@ -95,22 +98,11 @@ exports.FinantialsSummary = async (req, res) => { const Year_2 = data[0][0].Y2; const Year_3 = data[0][0].Y3; const years_data = data[0][0]; - const current_year = new Date().getFullYear(); - const current_month = new Date().getMonth() + 1; - let add_new_FY_flag; - if(Year_1 == current_year && 3 < current_month) - { - add_new_FY_flag = {show_add_finyear_button:0}; - } - else - { - add_new_FY_flag = {show_add_finyear_button:1,FY:current_year}; - } //sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type,f.statement_name as st_name,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id LEFT JOIN ( SELECT id, statement_name FROM statement_type ) f ON a.st_type = f.id LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks ) g ON a.entity_id = g.entity_id and a.itemid = g.itemid 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 ) z ON e.subsection = z.id JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_3+" and is_active = 1 and entity_id = "+id+") c ON a.entity_id = c.entity_id and a.itemid = c.itemid JOIN ( SELECT id,entity_id, itemid, value,fy,is_active FROM financials WHERE fy = "+Year_2+" and is_active = 1 and entity_id = "+id+") b ON a.entity_id = b.entity_id and a.itemid = b.itemid AND a.fy = "+Year_1+" WHERE a.entity_id = "+id+" and a.is_active = 1 order by x.id asc , y.id asc , a.itemid asc ") sequelize.query("Select a.entity_id,x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext ,a.itemid,e.itemtext as items,e.formula,e.is_calculated,a.st_type as Y1_st_type,a.fy as Y1,a.id as Y1_id ,a.value as Y1_value ,b.st_type as Y2_st_type,b.fy as Y2, b.id Y2_id ,b.value Y2_value ,c.st_type as Y3_st_type,c.fy as Y3,c.id as Y3_id ,c.value Y3_value , g.remarks , g.id as remarks_id FROM financials a LEFT JOIN ( SELECT id,entity_id,itemid,remarks FROM fin_remarks WHERE is_active = 1) g ON a.entity_id = g.entity_id and a.itemid = g.itemid JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated 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 ) z ON e.subsection = z.id LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_3+" and entity_id ="+id+" and is_active = 1) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN ( SELECT id,entity_id, itemid, value,fy,is_active,st_type FROM financials WHERE fy = "+Year_2+" and entity_id = "+id+" and is_active = 1) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = "+Year_1+" and a.entity_id = "+id+" and a.is_active = 1 order by e.statement asc , e.section asc , e.id asc") .then(result => { const arr = {"years" : years_data , "summary" : result } - res.send({'status':200,'message':"success",'data':{"years" : years_data ,"add_new_finyear_flag" : add_new_FY_flag, "summary" : result } }); + res.send({'status':200,'message':"success",'data':{"years" : years_data , "summary" : result } }); }).catch(err => { res.status(500).send({'status':404, message: err.message || "Some error occurred while retrieving tutorials." ,'data': "No data" }); @@ -306,6 +298,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{ Financials.bulkCreate(fin_data_array); //console.log(fin_data_array) }); + }).catch(err => { res.status(404).send({'status':404, @@ -322,10 +315,10 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{ }); // end of (losid,pan,cin) combination checking entity data exist or not }); // end of pro42 data foreach - + return {'status':200,'message':"success",'data':"No data"}; // success message - + } catch(err) { res.status(500).send({'status':404, message: err.message || "Some error occurred while inserting statements." ,'data': "No data" @@ -376,36 +369,7 @@ exports.createFinancialYear = async (req, res) => { }; -exports.test = (req , res)=>{ -// let promise = new Promise(function(resolve, reject) { -// setTimeout(() => resolve({msg: 'To do some more job'}), 1000); -// }); -// promise.then(function(result) { -// return {data: 'some data'}; -// }); - -// promise.then(function(result) { -// return {data: 'some other data'}; -// }); - -// promise.then(function(result) { -// return {data: 'some more data'}; - -// }); - - -let promise = new Promise((resolve, reject) => { - fn_call = testhree(); - resolve({ status: 200,message: 'success', data:fn_call }) -}) - - -promise.then(messages => { - console.log(messages.data) -}) - -}; exports.testwo = async (req, res) => { @@ -416,10 +380,6 @@ exports.testwo = async (req, res) => { }; function testhree(req , res) { console.log( new Date().getFullYear()) - console.log("first") - for(let i=0 ; i < 5 ; i++){console.log(i)} - console.log("last") - return {'status':200,'message':"success from "}; -} - - + console.log( req.losid) + return {'status':200,'message':"success"}; +} \ No newline at end of file diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 0002ad9..da55bef 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -4,7 +4,7 @@ -const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history} = require('../models') +const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type,Entityfinyears} = require('../models') const { logMsg } = require('../services/logger.js'); @@ -265,7 +265,7 @@ exports.Insertitem = (req, res) => { subsection: req.body.subsection, itemtext: req.body.itemtext, is_active: req.body.is_active, - pvt_ltd: req.body.pvt_ltd, + pvtltd: req.body.pvtltd, llp: req.body.llp, others: req.body.others, formula: req.body.formula, @@ -431,9 +431,39 @@ exports.Historyapi = (req, res) => { }; - - - +// 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.send({'status':404, + message: err.message || "Some error occurred while retrieving items." ,'data': "No data" }); + }); +}; + + + + +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,"updatedby":req_array_data.updatedby },{ where: { entityid:req_array_data.entityid}}) + + 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" + }); } + +}; diff --git a/app/models/Statement_type.js b/app/models/Statement_type.js new file mode 100644 index 0000000..3b79e5a --- /dev/null +++ b/app/models/Statement_type.js @@ -0,0 +1,39 @@ +'use strict' +const { Model } = require('sequelize') +const { logMsg } = require('../services/logger.js') +module.exports = (sequelize, DataTypes) => { + class Statement_type extends Model { + /** + * Helper method for defining associations. + * This method is not a part of Sequelize lifecycle. + * The `models/index` file will call this method automatically. + */ + // define association here + // static associate({ Sectionsmaster }) { + // this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' }) + // } + +//Sectionsmaster.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmaster' }) + + } + + Statement_type.init( + { + + statement_name: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, + createdby: { type: DataTypes.INTEGER }, + updatedby: { type: DataTypes.INTEGER }, + + + }, + { + sequelize, + tableName: 'statement_type', + modelName: 'Statement_type', + + } + ) + // logMsg.info("Success-model ") + return Statement_type +} diff --git a/app/routes/routes.js b/app/routes/routes.js index a3007d8..d2d7558 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -1,734 +1,825 @@ module.exports = app => { - const request = require("request"); - const cors=require('cors'); - const financials = require("../controllers/financial.controller.js"); - const master = require("../controllers/master.controller.js"); - const { logMsg } = require('../services/logger.js'); - var router = require("express").Router(); + const request = require("request"); + const cors=require('cors'); + const financials = require("../controllers/financial.controller.js"); + const master = require("../controllers/master.controller.js"); + const test = require("../controllers/test.controller.js"); + const { logMsg } = require('../services/logger.js'); + var router = require("express").Router(); + + - +/** +* @swagger +* /api/FinantialsSummary: +* get: +* summary: Financials Summary +* description: Get Financials Summary data by sending entityid +* parameters: +* - in: query +* name: entityid +* schema: +* type: integer +* required: true +* description: id of the Entity +* example: 7 +* responses: +* 200: +* description: success +*/ + // get financials summary + router.get("/FinantialsSummary", financials.FinantialsSummary); + +/** +* @swagger +* /api/MenuList: +* get: +* summary: Menu List +* description: Get Menu List data by sending losid +* parameters: +* - in: query +* name: losid +* schema: +* type: string +* required: true +* description: Los id of entity +* example: MW112233 +* responses: +* 200: +* description: success +*/ + // get menu list + router.get("/MenuList", financials.MenuList); /** - * @swagger - * /api/FinantialsSummary: - * get: - * summary: Financials Summary - * description: Get Financials Summary data by sending entityid - * parameters: - * - in: query - * name: entityid - * schema: - * type: integer - * required: true - * description: id of the Entity - * example: 7 - * responses: - * 200: - * description: success - */ - // get financials summary - router.get("/FinantialsSummary", financials.FinantialsSummary); - -/** - * @swagger - * /api/MenuList: - * get: - * summary: Menu List - * description: Get Menu List data by sending losid - * parameters: - * - in: query - * name: losid - * schema: - * type: string - * required: true - * description: Los id of entity - * example: MW112233 - * responses: - * 200: - * description: success - */ - // get menu list - router.get("/MenuList", financials.MenuList); +* @swagger +* /api/BrokenPeriodsList: +* get: +* summary: Broken Periods +* description: Get Broken Period data by sending entityid +* parameters: +* - in: query +* name: entityid +* schema: +* type: integer +* required: true +* description: id of the Entity +* example: 7 +* responses: +* 200: +* description: success +*/ + // Retrieve all Broken periods + router.get("/BrokenPeriodsList", financials.BrokenPeriodsList); /** - * @swagger - * /api/BrokenPeriodsList: - * get: - * summary: Broken Periods - * description: Get Broken Period data by sending entityid - * parameters: - * - in: query - * name: entityid - * schema: - * type: integer - * required: true - * description: id of the Entity - * example: 7 - * responses: - * 200: - * description: success - */ - // Retrieve all Broken periods - router.get("/BrokenPeriodsList", financials.BrokenPeriodsList); +* @openapi +* /api/MasterDatas: +* get: +* description: This is List of all master data for new item master insert (dropdown) +* responses: +* 200: +* description: Returns a mysterious string. +*/ + // fetching all master data + router.get("/MasterDatas", financials.MasterDatas); /** - * @openapi - * /api/MasterDatas: - * get: - * description: This is List of all master data for new item master insert (dropdown) - * responses: - * 200: - * description: Returns a mysterious string. - */ - // fetching all master data - router.get("/MasterDatas", financials.MasterDatas); +* @swagger +* definitions: +* BrokenPeriod: +* type: object +* properties: +* id: +* type: integer +* description: primary id of the broken period +* example: 1 +* entity_id: +* type: integer +* description: primary id of entity +* example: 1 +* from: +* type: date +* description: selected date +* example: '2020-01-01' +* to: +* type: date +* description: selected date +* example: '2020-01-01' +* months: +* type: integer +* description: month count between from and to date +* example: 3 +* cy: +* type: integer +* description: current year +* example: 1 +* py: +* type: integer +* description: previous year +* example: 1 +* variation: +* type: string +* description: calculated value +* example: '3%' +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ +/** +* @swagger +* /api/BrokenPeriods: +* post: +* summary: create or update Broken Periods +* description: create or update BrokenPeriods value with this single api by altering json object . If key 'id' exist in json object it will update the record otherwise it will create the record . +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/BrokenPeriod' +* responses: +* 200: +* description: BrokenPeriods created or updated succesfully +* 500: +* description: failure in creating statement +*/ + // create broken periods + router.post("/BrokenPeriods", financials.BrokenPeriods); + // create financials data + + + router.post("/createFinancials", financials.createFinancials); + + // create new FinancialYear skeletion + //post_object = {"losid":"MW12233","entityid":6,"fy":2022,"st_type":2} + /** +* @swagger +* definitions: +* NewFinancialYear: +* type: object +* properties: +* losid: +* type: string +* description: losid +* example: MW12233 +* entityid: +* type: integer +* description: entityid +* example: 1 +* fy: +* type: integer +* description: financial Year +* example: 2022 +* st_type: +* type: integer +* description: statement type +* example: 2 +*/ +/** +* @swagger +* /api/createFinancialYear: +* post: +* summary: createFinancials +* description: createFinancials +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/NewFinancialYear' +* responses: +* 200: +* description: New Financials Year inserted +* 500: +* description: failure in inserting New Financials Year +*/ + router.post("/createFinancialYear", financials.createFinancialYear); /** - * @swagger - * definitions: - * BrokenPeriod: - * type: object - * properties: - * id: - * type: integer - * description: primary id of the broken period - * example: 1 - * entity_id: - * type: integer - * description: primary id of entity - * example: 1 - * from: - * type: date - * description: selected date - * example: '2020-01-01' - * to: - * type: date - * description: selected date - * example: '2020-01-01' - * months: - * type: integer - * description: month count between from and to date - * example: 3 - * cy: - * type: integer - * description: current year - * example: 1 - * py: - * type: integer - * description: previous year - * example: 1 - * variation: - * type: string - * description: calculated value - * example: '3%' - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ +* @openapi +* /api/Statementtype_list: +* get: +* description: This is List api Statementtype +* responses: +* 200: +* description: Returns Statementtype. +*/ + + router.get("/Statementtype_list", master.Statementtype_list); /** - * @swagger - * /api/BrokenPeriods: - * post: - * summary: create or update Broken Periods - * description: create or update BrokenPeriods value with this single api by altering json object . If key 'id' exist in json object it will update the record otherwise it will create the record . - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/BrokenPeriod' - * responses: - * 200: - * description: BrokenPeriods created or updated succesfully - * 500: - * description: failure in creating statement - */ - // create broken periods - router.post("/BrokenPeriods", financials.BrokenPeriods); - // create financials data - router.post("/createFinancials", financials.createFinancials); - - // create new FinancialYear skeletion - //post_object = {"losid":"MW12233","entityid":6,"fy":2022,"st_type":2} - router.post("/createFinancialYear", financials.createFinancialYear); - - router.get("/test", financials.test); - - - - - - - - - /** - * @swagger - * definitions: - * statement: - * type: object - * properties: - * statement: - * type: string - * description: name of the statement - * example: 'profit' - * is_active: - * type: integer - * description: the state of statement(0 means inactive,1 means active) - * example: 1 - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ +* @swagger +* definitions: +* Statementtype: +* type: object +* properties: +* entityid: +* type: integer +* description: entityid +* example: 1 +* Y1_st_type: +* type: integer +* description: First 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 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ +/** +* @swagger +* /api/Statementtype_insert: +* post: +* summary: Statementtype_insert +* description: statement type insert against corresponds year +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/Statementtype' +* responses: +* 200: +* description: Statementtype inserted +* 500: +* description: failure in inserting Statementtype +*/ + router.post("/Statementtype_insert", master.Statementtype_insert); + router.get("/intiator", test.intiator); +/** +* @swagger +* definitions: +* statement: +* type: object +* properties: +* statement: +* type: string +* description: name of the statement +* example: 'profit' +* is_active: +* type: integer +* description: the state of statement(0 means inactive,1 means active) +* example: 1 +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ //master.controller api's // get statment master data - - //logMsg.info("Success -route "); - /** - * @openapi - * /api/StatementsList: - * get: - * description: This is List api statement! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.get("/StatementsList", master.StatementsList); - + + //logMsg.info("Success -route "); + /** +* @openapi +* /api/StatementsList: +* get: +* description: This is List api statement! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.get("/StatementsList", master.StatementsList); + /** - * @swagger - * /api/Insertstatement: - * post: - * summary: create statement - * description: create statement - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/statement' - * responses: - * 200: - * description: statement created succesfully - * 500: - * description: failure in creating statement - */ +* @swagger +* /api/Insertstatement: +* post: +* summary: create statement +* description: create statement +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/statement' +* responses: +* 200: +* description: statement created succesfully +* 500: +* description: failure in creating statement +*/ - router.post("/Insertstatement", master.Insertstatement); + router.post("/Insertstatement", master.Insertstatement); /** - * @swagger - * /api/Updatestatement/{id}: - * put: - * summary: update statement - * description: update statement - * consumes: - * - application/json - * produces: - * - application/json - * parameters: - * - in: path - * name: id - * schema: - * type: integer - * required: true - * description: id of the statement - * example: 2 - * - in: body - * name: body - * required: true - * description: body object - * schema: - * $ref: '#/definitions/statement' - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/statement' - * responses: - * 200: - * description: success - * content: - * application/json: - * schema: - * $ref: '#/definitions/statement' - */ - router.put("/Updatestatement/:id", master.Updatestatement); +* @swagger +* /api/Updatestatement/{id}: +* put: +* summary: update statement +* description: update statement +* consumes: +* - application/json +* produces: +* - application/json +* parameters: +* - in: path +* name: id +* schema: +* type: integer +* required: true +* description: id of the statement +* example: 2 +* - in: body +* name: body +* required: true +* description: body object +* schema: +* $ref: '#/definitions/statement' +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/statement' +* responses: +* 200: +* description: success +* content: +* application/json: +* schema: +* $ref: '#/definitions/statement' +*/ + router.put("/Updatestatement/:id", master.Updatestatement); /** - * @openapi - * /api/Deletestatement/:id: - * get: - * description: This is Delete api statement! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.put("/Deletestatement/:id", master.Deletestatement); +* @openapi +* /api/Deletestatement/:id: +* get: +* description: This is Delete api statement! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.put("/Deletestatement/:id", master.Deletestatement); - /** - * @swagger - * definitions: - * section: - * type: object - * properties: - * statement: - * type: integer - * description: id of the statement - * example: 1 - * section: - * type: string - * description: name of the section - * example: 'section' - * is_active: - * type: integer - * description: the state of section(0 means inactive,1 means active) - * example: 1 - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ - - - /** - * @openapi - * /api/SectionList: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - - router.get("/SectionList", master.SectionList); /** - * @swagger - * /api/Insertsection: - * post: - * summary: create section - * description: create section - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/section' - * responses: - * 200: - * description: section created succesfully - * 500: - * description: failure in creating section - */ - router.post("/Insertsection", master.Insertsection); -/** - * @swagger - * /api/Updatesection/{id}: - * put: - * summary: update section - * description: update section - * consumes: - * - application/json - * produces: - * - application/json - * parameters: - * - in: path - * name: id - * schema: - * type: integer - * required: true - * description: id of the section - * example: 2 - * - in: body - * name: body - * required: true - * description: body object - * schema: - * $ref: '#/definitions/section' - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/section' - * responses: - * 200: - * description: success - * content: - * application/json: - * schema: - * $ref: '#/definitions/section' - */ - router.put("/Updatesection/:id", master.Updatesection); +* @swagger +* definitions: +* section: +* type: object +* properties: +* statement: +* type: integer +* description: id of the statement +* example: 1 +* section: +* type: string +* description: name of the section +* example: 'section' +* is_active: +* type: integer +* description: the state of section(0 means inactive,1 means active) +* example: 1 +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ + + /** - * @openapi - * /api/Deletesection/:id: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.put("/Deletesection/:id", master.Deletesection); - +* @openapi +* /api/SectionList: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + + router.get("/SectionList", master.SectionList); +/** +* @swagger +* /api/Insertsection: +* post: +* summary: create section +* description: create section +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/section' +* responses: +* 200: +* description: section created succesfully +* 500: +* description: failure in creating section +*/ + router.post("/Insertsection", master.Insertsection); +/** +* @swagger +* /api/Updatesection/{id}: +* put: +* summary: update section +* description: update section +* consumes: +* - application/json +* produces: +* - application/json +* parameters: +* - in: path +* name: id +* schema: +* type: integer +* required: true +* description: id of the section +* example: 2 +* - in: body +* name: body +* required: true +* description: body object +* schema: +* $ref: '#/definitions/section' +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/section' +* responses: +* 200: +* description: success +* content: +* application/json: +* schema: +* $ref: '#/definitions/section' +*/ + router.put("/Updatesection/:id", master.Updatesection); +/** +* @openapi +* /api/Deletesection/:id: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.put("/Deletesection/:id", master.Deletesection); + //************************************************************ - /** - * @swagger - * definitions: - * subsection: - * type: object - * properties: - * section: - * type: integer - * description: id of the section - * example: 1 - * subsection: - * type: string - * description: name of the subsection - * example: 'subsection' - * is_active: - * type: integer - * description: the state of subsection(0 means inactive,1 means active) - * example: 1 - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ -/** - * @openapi - * /api/SubsectionList: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.get("/SubsectionList", master.SubsectionList); /** - * @swagger - * /api/Insertsubsection: - * post: - * summary: create subsection - * description: create subsection - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/subsection' - * responses: - * 200: - * description: subsection created succesfully - * 500: - * description: failure in creating subsection - */ - router.post("/Insertsubsection", master.Insertsubsection); -/** - * @swagger - * /api/Updatesubsection/{id}: - * put: - * summary: update subsection - * description: update subsection - * consumes: - * - application/json - * produces: - * - application/json - * parameters: - * - in: path - * name: id - * schema: - * type: integer - * required: true - * description: id of the subsection - * example: 2 - * - in: body - * name: body - * required: true - * description: body object - * schema: - * $ref: '#/definitions/subsection' - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/subsection' - * responses: - * 200: - * description: success - * content: - * application/json: - * schema: - * $ref: '#/definitions/subsection' - */ - router.put("/Updatesubsection/:id", master.Updatesubsection); +* @swagger +* definitions: +* subsection: +* type: object +* properties: +* section: +* type: integer +* description: id of the section +* example: 1 +* subsection: +* type: string +* description: name of the subsection +* example: 'subsection' +* is_active: +* type: integer +* description: the state of subsection(0 means inactive,1 means active) +* example: 1 +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ /** - * @openapi - * /api/Deletesubsection/:id: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.put("/Deletesubsection/:id", master.Deletesubsection); +* @openapi +* /api/SubsectionList: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.get("/SubsectionList", master.SubsectionList); +/** +* @swagger +* /api/Insertsubsection: +* post: +* summary: create subsection +* description: create subsection +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/subsection' +* responses: +* 200: +* description: subsection created succesfully +* 500: +* description: failure in creating subsection +*/ + router.post("/Insertsubsection", master.Insertsubsection); +/** +* @swagger +* /api/Updatesubsection/{id}: +* put: +* summary: update subsection +* description: update subsection +* consumes: +* - application/json +* produces: +* - application/json +* parameters: +* - in: path +* name: id +* schema: +* type: integer +* required: true +* description: id of the subsection +* example: 2 +* - in: body +* name: body +* required: true +* description: body object +* schema: +* $ref: '#/definitions/subsection' +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/subsection' +* responses: +* 200: +* description: success +* content: +* application/json: +* schema: +* $ref: '#/definitions/subsection' +*/ + router.put("/Updatesubsection/:id", master.Updatesubsection); +/** +* @openapi +* /api/Deletesubsection/:id: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.put("/Deletesubsection/:id", master.Deletesubsection); - /** - * @swagger - * definitions: - * item: - * type: object - * properties: - * statement: - * type: integer - * description: id of the statement - * example: 1 - * section: - * type: integer - * description: id of the section - * example: 1 - * subsection: - * type: integer - * description: id of the subsection - * example: 1 - * itemtext: - * type: string - * description: name of the item - * example: 'itemtext' - * pvtltd: - * type: integer - * description: pvtltd - Private Limited - * example: 1 - * llp: - * type: integer - * description: llp - * example: 1 - * others: - * type: integer - * description: others - * example: 1 - * formula: - * type: string - * description: formula - * example: 'a+b' - * is_calculated: - * type: integer - * description: is_calculated - it shows the field need to be calculate or not - * example: 1 - * is_active: - * type: integer - * description: the state of section(0 means inactive,1 means active) - * example: 1 - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ -/** - * @openapi - * /api/ItemList: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.get("/ItemList", master.ItemList); /** - * @swagger - * /api/Insertitem: - * post: - * summary: create item - * description: create item - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/item' - * responses: - * 200: - * description: item created succesfully - * 500: - * description: failure in creating item - */ - router.post("/Insertitem", master.Insertitem); -/** - * @swagger - * /api/Updateitem/{id}: - * put: - * summary: update item - * description: update item - * consumes: - * - application/json - * produces: - * - application/json - * parameters: - * - in: path - * name: id - * schema: - * type: integer - * required: true - * description: id of the item - * example: 2 - * - in: body - * name: body - * required: true - * description: body object - * schema: - * $ref: '#/definitions/item' - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/item' - * responses: - * 200: - * description: success - * content: - * application/json: - * schema: - * $ref: '#/definitions/item' - */ - router.put("/Updateitem/:id", master.Updateitem); +* @swagger +* definitions: +* item: +* type: object +* properties: +* statement: +* type: integer +* description: id of the statement +* example: 1 +* section: +* type: integer +* description: id of the section +* example: 1 +* subsection: +* type: integer +* description: id of the subsection +* example: 1 +* itemtext: +* type: string +* description: name of the item +* example: 'itemtext' +* pvtltd: +* type: integer +* description: pvtltd - Private Limited +* example: 1 +* llp: +* type: integer +* description: llp +* example: 1 +* others: +* type: integer +* description: others +* example: 1 +* formula: +* type: string +* description: formula +* example: 'a+b' +* is_calculated: +* type: integer +* description: is_calculated - it shows the field need to be calculate or not +* example: 1 +* is_active: +* type: integer +* description: the state of section(0 means inactive,1 means active) +* example: 1 +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ /** - * @openapi - * /api/Deleteitem/:id: - * get: - * description: Welcome to swagger-jsdoc! - * responses: - * 200: - * description: Returns a mysterious string. - */ - router.put("/Deleteitem/:id", master.Deleteitem); - - //sample - //router.put("/:id", tutorials.update); - //router.delete("/:id", tutorials.delete); - - - /** - * @swagger - * /api/ItemFilter: - * get: - * summary: ItemFilter - * description: ItemFilter - * parameters: - * - in: query - * name: section - * schema: - * type: integer - * required: true - * description: id of the section - * example: 1 - * responses: - * 200: - * description: success - */ - // get financials summary - router.get("/ItemFilter", master.ItemFilter); +* @openapi +* /api/ItemList: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.get("/ItemList", master.ItemList); +/** +* @swagger +* /api/Insertitem: +* post: +* summary: create item +* description: create item +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/item' +* responses: +* 200: +* description: item created succesfully +* 500: +* description: failure in creating item +*/ + router.post("/Insertitem", master.Insertitem); +/** +* @swagger +* /api/Updateitem/{id}: +* put: +* summary: update item +* description: update item +* consumes: +* - application/json +* produces: +* - application/json +* parameters: +* - in: path +* name: id +* schema: +* type: integer +* required: true +* description: id of the item +* example: 2 +* - in: body +* name: body +* required: true +* description: body object +* schema: +* $ref: '#/definitions/item' +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/item' +* responses: +* 200: +* description: success +* content: +* application/json: +* schema: +* $ref: '#/definitions/item' +*/ + router.put("/Updateitem/:id", master.Updateitem); +/** +* @openapi +* /api/Deleteitem/:id: +* get: +* description: Welcome to swagger-jsdoc! +* responses: +* 200: +* description: Returns a mysterious string. +*/ + router.put("/Deleteitem/:id", master.Deleteitem); - /** - * @swagger - * definitions: - * remarks: - * type: object - * properties: - * entity_id: - * type: integer - * description: id of the entity - * example: 1 - * itemid: - * type: integer - * description: id of the item - * example: 1 - * remarks: - * type: string - * description: remarks - * example: testttttttttttttt - * is_active: - * type: integer - * description: the state of section(0 means inactive,1 means active) - * example: 1 - * createdby: - * type: integer - * description: The person who created - * example: 1 - * updatedby: - * type: integer - * description: The person who modified - * example: 1 - */ + //sample + //router.put("/:id", tutorials.update); + //router.delete("/:id", tutorials.delete); + + /** - * @swagger - * /api/createRemarks: - * post: - * summary: create Remarks - * description: create Remarks - * requestBody: - * content: - * application/json: - * schema: - * $ref: '#/definitions/remarks' - * responses: - * 200: - * description: item created succesfully - * 500: - * description: failure in creating item - */ - router.post("/createRemarks", master.createRemarks); - /** - * @swagger - * /api/Historyapi: - * get: - * summary: Historyapi - * description: Historyapi - * parameters: - * - in: query - * name: table - * schema: - * type: string - * required: true - * description: table name - * example: item - * - in: query - * name: id - * schema: - * type: integer - * required: true - * description: id - * example: 109 - * responses: - * 200: - * description: success - */ - router.get("/Historyapi", master.Historyapi); - - - - - // third party api call example - router.get('/third_party_api', (req, res) => { +* @swagger +* /api/ItemFilter: +* get: +* summary: ItemFilter +* description: ItemFilter +* parameters: +* - in: query +* name: section +* schema: +* type: integer +* required: true +* description: id of the section +* example: 1 +* responses: +* 200: +* description: success +*/ + // get financials summary + router.get("/ItemFilter", master.ItemFilter); + +/** +* @swagger +* definitions: +* remarks: +* type: object +* properties: +* entity_id: +* type: integer +* description: id of the entity +* example: 1 +* itemid: +* type: integer +* description: id of the item +* example: 1 +* remarks: +* type: string +* description: remarks +* example: testttttttttttttt +* is_active: +* type: integer +* description: the state of section(0 means inactive,1 means active) +* example: 1 +* createdby: +* type: integer +* description: The person who created +* example: 1 +* updatedby: +* type: integer +* description: The person who modified +* example: 1 +*/ +/** +* @swagger +* /api/createRemarks: +* post: +* summary: create Remarks +* description: create Remarks +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/remarks' +* responses: +* 200: +* description: item created succesfully +* 500: +* description: failure in creating item +*/ + router.post("/createRemarks", master.createRemarks); +/** +* @swagger +* /api/Historyapi: +* get: +* summary: Historyapi +* description: Historyapi +* parameters: +* - in: query +* name: table +* schema: +* type: string +* required: true +* description: table name for wanting to see history (statementsmaster - statement, sectionsmaster - section, subsectionsmaster - subsection, itemsmaster - item) +* example: item +* - in: query +* name: id +* schema: +* type: integer +* required: true +* description: the row for wnating to see history +* example: 109 +* responses: +* 200: +* description: success +*/ + router.get("/Historyapi", master.Historyapi); + + + + + // third party api call example + router.get('/third_party_api', (req, res) => { // const options = { // url: "http://localhost:8000/api/MenuList/MW112233", // }; @@ -736,17 +827,17 @@ module.exports = app => { // console.log(options.status); request('http://localhost:8000/api/MenuList/MW112233', function (error, response, body) { - console.error('error:', error); // Print the error if one occurred - console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received - let data = JSON.parse(body); - let array = data.data; - array.forEach((value, key)=>{ - console.log('result :',value.statementsmasterrData ); // Print the HTML for the Google homepage. - }); - +console.error('error:', error); // Print the error if one occurred +console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received +let data = JSON.parse(body); +let array = data.data; +array.forEach((value, key)=>{ + console.log('result :',value.statementsmasterrData ); // Print the HTML for the Google homepage. + }); + }); - }) - - // routes started here - app.use('/api', router); - }; \ No newline at end of file + }) + + // routes started here + app.use('/api', router); +}; \ No newline at end of file