updateFinancial:GWM

This commit is contained in:
sriramv 2023-07-21 18:40:04 +05:30
parent 4e733b4da4
commit 51642489cd

View File

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