suseendhiran , change update api
This commit is contained in:
parent
2c7f0e831c
commit
af7326dab4
@ -32,7 +32,7 @@ exports.GetObligationBankStatement = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await ObligationBankStatement.findAll({where : {los_id : req.query.los_id , is_active : 1},order: [['item_order', 'ASC']] })
|
||||
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});
|
||||
@ -101,18 +101,20 @@ exports.UpdateObligationBankStatement = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
id = req.body.id;
|
||||
delete req.body.id
|
||||
await ObligationBankStatement.update({is_active : 0 },{ where: { id: id }});
|
||||
ObligationBankStatement.create(req.body).then(data =>
|
||||
req.body.forEach( async (element , index ) =>
|
||||
{
|
||||
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" });
|
||||
});
|
||||
|
||||
ObligationBankStatement.update( element , { where: { id: element.id }}).then(data =>
|
||||
{
|
||||
if (req.body.length - 1 == index)
|
||||
{
|
||||
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
|
||||
@ -153,13 +155,14 @@ exports.CreateObligationEmiTrackingMonth = async (req, res) =>
|
||||
{
|
||||
var dateStore = [ ]
|
||||
var date = new Date(req.body.month_6);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let i = 0; i < 5; i++)
|
||||
{
|
||||
var a = date.setMonth(date.getMonth() - 1);
|
||||
var b = date.toLocaleDateString("en-GB")
|
||||
var yourdate = b.split("/").reverse().join("-");
|
||||
dateStore.push(yourdate)
|
||||
}
|
||||
await EmiTracking.create({los_id : req.body.los_id , month_1 : dateStore[4] , month_2 : dateStore[3] , month_3 : dateStore[2] ,month_4 : dateStore[1] , month_5 : dateStore[0] , month_6 : req.body.month_6 })
|
||||
EmiTracking.create({los_id : req.body.los_id , month_1 : dateStore[4] , month_2 : dateStore[3] , month_3 : dateStore[2] ,month_4 : dateStore[1] , month_5 : dateStore[0] , month_6 : req.body.month_6 })
|
||||
.then(data =>
|
||||
{
|
||||
res.send({'status':200,'message':"success",'data': data});
|
||||
@ -182,18 +185,18 @@ exports.UpdateObligationEmiTracking = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
id = req.body.id;
|
||||
delete req.body.id
|
||||
await EmiTracking.update({is_active : 0 },{ where: { id: id }});
|
||||
var dateStore = [ ]
|
||||
var date = new Date(req.body.month_6);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
var a = date.setMonth(date.getMonth() - 1);
|
||||
var b = date.toLocaleDateString("en-GB")
|
||||
var yourdate = b.split("/").reverse().join("-");
|
||||
dateStore.push(yourdate)
|
||||
}
|
||||
await EmiTracking.create({los_id : req.body.los_id , month_1 : dateStore[4] , month_2 : dateStore[3] , month_3 : dateStore[2] ,month_4 : dateStore[1] , month_5 : dateStore[0] , month_6 : req.body.month_6 })
|
||||
var dateArr = [ ];
|
||||
var dateObj = { };
|
||||
var mon_6_date = new Date(req.body.month_6);
|
||||
for (let i = 0; i < 5; i++)
|
||||
{
|
||||
mon_6_date.setMonth(mon_6_date.getMonth() - 1);
|
||||
get_local_date = mon_6_date.toLocaleDateString("en-GB");
|
||||
get_all_dates = get_local_date.split("/").reverse().join("-");
|
||||
dateArr.push(get_all_dates)
|
||||
}
|
||||
Object.assign(dateObj, { los_id : req.body.los_id, month_1: dateArr[4], month_2: dateArr[3], month_3: dateArr[2], month_4: dateArr[1], month_5: dateArr[0], month_6: req.body.month_6 })
|
||||
EmiTracking.update(dateObj , {where: { id: req.body.id , is_active : 1 } })
|
||||
.then(data =>
|
||||
{
|
||||
res.send({'status':200,'message':"success",'data':data});
|
||||
|
||||
@ -481,7 +481,7 @@ router.post("/createObligationEmiTrackingMonth",Mycontroller.CreateObligationEmi
|
||||
* los_id:
|
||||
* type: string
|
||||
* description: los_id
|
||||
* example: 123ab
|
||||
* example: MW112233
|
||||
* month_6:
|
||||
* type: string
|
||||
* description: month_1
|
||||
@ -496,8 +496,8 @@ router.post("/createObligationEmiTrackingMonth",Mycontroller.CreateObligationEmi
|
||||
* @swagger
|
||||
* /api/updateObligationEmiTracking:
|
||||
* post:
|
||||
* summary: create Obligation Obligation EmiTracking details
|
||||
* description: create Obligation Obligation EmiTracking details
|
||||
* summary: update Obligation Obligation EmiTracking details
|
||||
* description: update Obligation Obligation EmiTracking details
|
||||
* requestBody:
|
||||
* content:
|
||||
* application/json:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user