createFinancials:GWM
This commit is contained in:
parent
40de1eb17b
commit
995b25018f
@ -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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Financials.update({ is_active : 0 },{ where: { id: value.id }});
|
||||||
|
logMsg.info("updated is_active = 0 for primary key : "+value.id);
|
||||||
|
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 })
|
||||||
|
logMsg.info("Created new financials data - EntityId : "+value.entity_id+" , FY : "+value.fy+",ItemId : "+value.itemid);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
|
||||||
logMsg.info("Is_active update failed ,meaasge :"(err.message));
|
|
||||||
});
|
|
||||||
Financials.bulkCreate(req_array_data)
|
|
||||||
.then(data => {
|
|
||||||
res.send({'status':200,'message':"success",'data':data});
|
|
||||||
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"});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user