createFinancials:GWM

This commit is contained in:
sriramv 2021-08-28 10:42:27 +05:30
parent 40de1eb17b
commit 995b25018f

View File

@ -176,29 +176,28 @@ exports.BrokenPeriods = (req, res) => {
exports.createFinancials = (req, res) => { exports.createFinancials = (req, res) => {
let req_array_data = req.body;
let req_array_id = []; const req_array_data = req.body;
req_array_data.forEach((value, key)=>{ req_array_data.forEach((value, key)=>{
req_array_id.push(value.id);
delete value.id; Financials.findOne({ where: { id : value.id } }).then(function(result) {
});
Financials.update({ is_active : 0 },{ where: { id: req_array_id }}) if(result.value == value.value)
.then(data => { {
logMsg.info("Is_active 0 update Success for :"(data)); logMsg.info("Value not updated for - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid+",primary key :"+value.id);
}) }
.catch(err => { else
logMsg.info("Is_active update failed ,meaasge :"(err.message)); {
}); Financials.update({ is_active : 0 },{ where: { id: value.id }});
Financials.bulkCreate(req_array_data) logMsg.info("updated is_active = 0 for primary key : "+value.id);
.then(data => { Financials.create({ "entity_id":value.entity_id,"st_type":value.st_type,"itemid":value.itemid,"fy":value.fy,"value":value.value,"is_active":value.is_active,"createdby":value.createdby })
res.send({'status':200,'message':"success",'data':data}); logMsg.info("Created new financials data - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid);
logMsg.info("Success :"(data)); }
}) })
.catch(err => {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
});
}); });
res.send({'status':200,'message':"success",'data':"No data"});
}; };