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 test = require("../controllers/test.controller.js"); const ExcelController = require("../controllers/excel.controller.js"); const { logMsg } = require('../services/logger.js'); var router = require("express").Router(); router.get("/checkProbeApi", financials.checkProbeApi); /** * @swagger * /api/checkProbeStatus: * get: * summary: check Probe42 Data Status * description: checking probe42 data status changed or not for recall menulist api (call this api id probe42_data_status = 1 -> Data Fetching in progress) * parameters: * - in: query * name: entityid * schema: * type: integer * required: true * description: primary id of entity object * example: 319 * - in: query * name: probe42_data_status * schema: * type: integer * required: true * description: probe42 data undate status * example: 1 * responses: * 200: * description: success */ // get financials summary router.get("/checkProbeStatus", financials.checkProbeStatus); /** * @swagger * definitions: * RefreshApiCall: * type: object * properties: * losid: * type: string * description: losid * example: MW83333683 * entityid: * type: integer * description: entityid * example: 317 * cin: * type: integer * description: cin number * example: U92140KL2015PTC038339 */ /** * @swagger * /api/refreshApi: * post: * summary: RefreshApi * description: once again calling probe42 data Api for financial data update * requestBody: * content: * application/json: * schema: * $ref: '#/definitions/RefreshApiCall' * responses: * 200: * description: RefreshApi called and data updated * 500: * description: failure in fetching probe42 data for the cin number */ router.post("/refreshApi", financials.refreshApi); /** * @swagger * /api/ConsolidatedSummary: * get: * summary: Consolidated Summary * description: Get consolidated Financials Summary data by sending losid * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: LOSID * example: MW83333683 * responses: * 200: * description: success */ // get financials summary router.get("/ConsolidatedSummary", financials.ConsolidatedSummary); /** * @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: 317 * 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: MW83333683 * 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: 317 * 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); /** * @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: 317 * 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); /** * @swagger * definitions: * NewFinancialYear: * type: object * properties: * losid: * type: string * description: losid * example: MW83333683 * entityid: * type: integer * description: entityid * example: 318 * fy: * type: integer * description: financial Year * example: 2022 * st_type: * type: integer * description: statement type * example: 2 * additional_year_type: * 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 * /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); /** * @openapi * /api/Statementtype_list: * get: * description: This is List api Statementtype * responses: * 200: * description: Returns Statementtype. */ router.get("/Statementtype_list", master.Statementtype_list); /** * @swagger * definitions: * Statementtype: * type: object * properties: * entityid: * type: integer * description: entityid * example: 317 * fy: * type: integer * description: year * example: 2022 * st_type: * type: integer * description: 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); /** * @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 /** * @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 */ 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); /** * @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); /** * @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); /** * @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_summary: * type: integer * description: is_calculated - it shows the field need to be shows on summary page 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); /** * @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); /** * @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); /** * @swagger * /api/TaskComplete: * get: * summary: MakerSubmit,cheker complete * description: MakerSubmit,cheker complete * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: LOSID * example: MW112233 * - in: query * name: pan * schema: * type: string * required: true * description: pan no * example: AAA123AAA * - in: query * name: cin * schema: * type: string * required: true * description: cin no * example: CIN * responses: * 200: * description: success */ router.get("/TaskComplete", master.TaskComplete); /** * @swagger * /api/ReInitiate: * get: * summary: ReInitiate * description: ReInitiate * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: LOSID * example: MW112233 * - in: query * name: pan * schema: * type: string * required: true * description: pan no * example: AAA123AAA * - in: query * name: cin * schema: * type: string * required: true * description: cin no * example: CIN * responses: * 200: * description: success */ router.get("/ReInitiate", master.ReInitiate); /** * @swagger * /api/Reassign: * get: * summary: Reassign * description: Reassign * parameters: * - in: query * name: entityid * schema: * type: integer * required: true * description: primary id * example: 6 * responses: * 200: * description: success */ router.get("/Reassign", master.Reassign); /** * @swagger * /api/makerComplete: * get: * summary: makerComplete * description: makerComplete * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: losid * example: MW112233 * - in: query * name: entityid * schema: * type: integer * required: true * description: primary id * example: 6 * responses: * 200: * description: success */ router.get("/makerComplete", master.makerComplete); /** * @swagger * /api/checkerComplete: * get: * summary: checkerComplete * description: checkerComplete * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: losid * example: MW112233 * - in: query * name: entityid * schema: * type: integer * required: true * description: primary id * example: 6 * responses: * 200: * description: success */ router.get("/checkerComplete", master.checkerComplete); /** * @swagger * /api/deActivateFinancialsYear: * get: * summary: deActivate FinancialsYear data * description: deActivateFinancialsYear * parameters: * - in: query * name: losid * schema: * type: string * required: true * description: losid * example: MW112233 * - in: query * name: entityid * schema: * type: integer * required: true * description: * example: * - in: query * name: FY * schema: * type: integer * required: true * description: * example: * responses: * 200: * description: success */ router.get("/deActivateFinancialsYear", financials.deActivateFinancialsYear); /** * @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); router.post("/updateEntityCin", financials.updateEntityCin); router.post("/updateFinancials", financials.updateFinancials); //excel data import const multer = require('multer'); filename = ""; const storage = multer.diskStorage({ destination: (req, file, cb) => { cb(null, 'storage/uploads/'); }, filename: (req, file, cb) => { filename = ""; filename += Date.now()+'-'+file.originalname; cb(null, filename); } }); const uploadExcel = multer({ storage }); router.post('/uploadExcel',uploadExcel.single('excel_file'),function(req,res){ExcelController.ImportExcelData(req,res,filename)}); // third party api call example router.get('/third_party_api', (req, res) => { // const options = { // url: "http://localhost:8000/api/MenuList/MW112233", // }; // request.get(options).pipe(res); // 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. }); }); }) router.get("/getfilename", test.readLogFileName); router.post("/readlogs", test.readLogFile); router.get("/view", test.viewLandingPage); router.post("/deletelog", test.deleteLogFile); // routes started here app.use('/api', router); };