From 51642489cd3cb6f214d3f6304e8fcc377c9108bb Mon Sep 17 00:00:00 2001 From: sriramv Date: Fri, 21 Jul 2023 18:40:04 +0530 Subject: [PATCH] updateFinancial:GWM --- app/controllers/financial.controller.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index 46053a6..9351534 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -775,12 +775,23 @@ exports.updateFinancials = (req, res) => { const req_array_data = req.body; try { - req_array_data.forEach((value, key)=>{ - const id = value.id; - Financials.update({ "entity_id":value.entity_id,"st_type":value.sy_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"updatedby":value.updatedby },{ where: { id:id }}) + req_array_data.forEach(async(value, key)=>{ + await Financials.findOne({ where: { id : value.id , is_active : 1} }).then(async function(result) { + + if(result.value == value.value) + { + logMsg.info("Value not updated for - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid+",primary key :"+value.id); + } + else + { + Financials.update({ "value":value.value,"sub_value":value.sub_value},{ where: { id:value.id }}) + } + + }); + }); res.send({'status':200,'message':"success",'data':"No data"}); - logMsg.info("multiple financials update Success"); + }catch(err) { res.send({'status':404, message: err.message || "Some error occurred while inserting statements." ,'data': "No data"