add api , susee

This commit is contained in:
suseendhiran17 2022-04-23 12:32:57 +05:30
parent 078b6a2796
commit d2bccc4043
4 changed files with 288 additions and 2 deletions

View File

@ -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
}

29
app/models/EmiTracking.js Normal file
View File

@ -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
}

View File

@ -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 }
},
{

View File

@ -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