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