From d2bccc404326b5339fbe9011f9145f3dc6ba20cf Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Sat, 23 Apr 2022 12:32:57 +0530 Subject: [PATCH] add api , susee --- app/controllers/obligation.controller.js | 76 +++++++++- app/models/EmiTracking.js | 29 ++++ app/models/ObligationBankStatement.js | 1 + app/routes/routes.js | 184 +++++++++++++++++++++++ 4 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 app/models/EmiTracking.js diff --git a/app/controllers/obligation.controller.js b/app/controllers/obligation.controller.js index 6571acf..4f380c2 100644 --- a/app/controllers/obligation.controller.js +++ b/app/controllers/obligation.controller.js @@ -1,4 +1,4 @@ -const { sequelize,Test,ObligationMaster,ObligationBankStatement} = require('../models') +const { sequelize,Test,ObligationMaster,ObligationBankStatement,EmiTracking} = require('../models') const { logMsg } = require('../services/logger.js'); var swaggerSpecToPdf = require("swagger-spec-to-pdf") @@ -31,7 +31,7 @@ exports.GetObligationBankStatement = async (req, res) => { try { - await ObligationBankStatement.findAll({where : {los_id : req.query.los_id , is_active : 1} }) + await ObligationBankStatement.findAll({where : {los_id : req.query.los_id , is_active : 1},order: [['item_order', 'ASC']] }) .then(data => { res.send({'status':200,'message':"success",'data':data}); @@ -120,4 +120,76 @@ exports.UpdateObligationBankStatement = async (req, res) => +// get all Obligation bank statement +exports.GetEmiTrackingMonth = async (req, res) => +{ + try + { + await EmiTracking.findOne({where : {los_id : req.query.los_id , is_active : 1} }) + .then(data => + { + res.send({'status':200,'message':"success",'data':data}); + logMsg.info("Obligation Emi Tracking Month List api call Success"); + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while fetching Obligation Emi Tracking Month." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while fetching Obligation Emi Tracking Month." ,'data': "No data" + }); + } //end of try catch + +}; + + +// create new Obligation master +exports.CreateObligationEmiTrackingMonth = async (req, res) => +{ + try + { + await EmiTracking.create(req.body) + .then(data => + { + res.send({'status':200,'message':"success",'data': data}); + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while create Obligation EmiTracking." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404, + message: err.message || "Some error occurred while create Obligation EmiTracking." ,'data': "No data" + }); + } //end of try catch +}; + + +// update EMi Tracking ( is_active = 0) then create new bank statement +exports.UpdateObligationEmiTracking = async (req, res) => +{ + try + { + id = req.body.id; + delete req.body.id + await EmiTracking.update({is_active : 0 },{ where: { id: id }}); + EmiTracking.create(req.body).then(data => + { + res.send({'status':200,'message':"success",'data':data}); + }) + .catch(err => { + res.send({'status':404, + message: err.message || "Some error occurred while retrieving statements." ,'data': "No data" }); + }); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while inserting statements." ,'data': "No data" }); + } //end of try catch + +} + + diff --git a/app/models/EmiTracking.js b/app/models/EmiTracking.js new file mode 100644 index 0000000..03071c9 --- /dev/null +++ b/app/models/EmiTracking.js @@ -0,0 +1,29 @@ +'use strict' +const { Model } = require('sequelize') +module.exports = (sequelize, DataTypes) => { + class EmiTracking extends Model { + + } + EmiTracking.init( + { + los_id: { type: DataTypes.STRING }, + month_1: { type: DataTypes.DATE }, + month_2: { type: DataTypes.DATE }, + month_3: { type: DataTypes.DATE }, + month_4: { type: DataTypes.DATE }, + month_5: { type: DataTypes.DATE }, + month_6: { type: DataTypes.DATE }, + is_active: { type: DataTypes.INTEGER } + }, + { + sequelize, + tableName: 'emi_tracking_months', + modelName: 'EmiTracking', + } + ) + + + + return EmiTracking + +} \ No newline at end of file diff --git a/app/models/ObligationBankStatement.js b/app/models/ObligationBankStatement.js index 340a1c4..a7b1c38 100644 --- a/app/models/ObligationBankStatement.js +++ b/app/models/ObligationBankStatement.js @@ -33,6 +33,7 @@ module.exports = (sequelize, DataTypes) => { emi_tracking_month_4: { type: DataTypes.INTEGER }, emi_tracking_month_5: { type: DataTypes.INTEGER }, emi_tracking_month_6: { type: DataTypes.INTEGER }, + item_order : { type: DataTypes.INTEGER }, is_active: { type: DataTypes.INTEGER } }, { diff --git a/app/routes/routes.js b/app/routes/routes.js index e1a8593..c098ae7 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -203,6 +203,10 @@ router.post("/createObligationMaster",Mycontroller.CreateObligationMaster) * type: integer * description: emiTrackingMonth_6 * example: 1 +* item_order: +* type: integer +* description: ordering key +* example: 1 * is_active: * type: integer * description: isActive @@ -348,6 +352,10 @@ router.post("/createObligationMaster",Mycontroller.CreateObligationMaster) * type: integer * description: emiTrackingMonth_6 * example: 1 +* item_order: +* type: integer +* description: ordering key +* example: 1 * is_active: * type: integer * description: isActive @@ -375,8 +383,184 @@ router.post("/updateObligationBankStatement",Mycontroller.UpdateObligationBankSt +/** +* @swagger +* /api/getEmiTrackingMonth: +* get: +* summary: Get Obligation Emi Traking Month List +* description: Get Obligation Emi Traking Month List +* parameters: +* - in: query +* name: los_id +* schema: +* type: string +* required: true +* description: Obligation Emi Traking Month List +* example: 12abc +* responses: +* 200: +* description: success +*/ +router.get("/getEmiTrackingMonth",Mycontroller.GetEmiTrackingMonth) +// get Obligation burear bankstatement + +/** +* @swagger +* /api/getObligationBankStatement: +* get: +* summary: Get Obligation Bank Statement List +* description: Get Obligation Bank Statement +* parameters: +* - in: query +* name: los_id +* schema: +* type: string +* required: true +* description: Obligation Bank Statement +* example: 12abc +* responses: +* 200: +* description: success +*/ +router.get("/getObligationBankStatement",Mycontroller.GetObligationBankStatement) + + +// create Obligation Emi Tracking + +/** +* @swagger +* definitions: +* createObligationEmiTrackingMonth: +* type: object +* properties: +* los_id: +* type: string +* description: los_id +* example: 123ab +* month_1: +* type: string +* description: month_1 +* example: "2017-01-01" +* format: date +* month_2: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_3: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_4: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_5: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_6: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* is_active: +* type: integer +* description: isActive +* example: 1 +*/ +/** +* @swagger +* /api/createObligationEmiTrackingMonth: +* post: +* summary: create Obligation Emi Tracking Month details +* description: create a Obligation Emi Tracking Month +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/createObligationEmiTrackingMonth' +* responses: +* 200: +* description: New create Obligation Emi Tracking Month +* 500: +* description: failure in inserting Obligation Emi Tracking Month +*/ +router.post("/createObligationEmiTrackingMonth",Mycontroller.CreateObligationEmiTrackingMonth) + +/** +* @swagger +* definitions: +* updateObligationEmiTracking: +* type: object +* properties: +* id: +* type: integer +* description: id +* example: 1 +* los_id: +* type: string +* description: los_id +* example: 123ab +* month_1: +* type: string +* description: month_1 +* example: "2017-01-01" +* format: date +* month_2: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_3: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_4: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_5: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* month_6: +* type: string +* description: month_1 +* example: "2022-04-12" +* format: date +* is_active: +* type: integer +* description: isActive +* example: 1 +*/ +/** +* @swagger +* /api/updateObligationEmiTracking: +* post: +* summary: create Obligation Obligation EmiTracking details +* description: create Obligation Obligation EmiTracking details +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/updateObligationEmiTracking' +* responses: +* 200: +* description: update Obligation Obligation EmiTracking details +* 500: +* description: failure in updating Obligation EmiTracking details +*/ +router.post("/updateObligationEmiTracking",Mycontroller.UpdateObligationEmiTracking) + // routes started here