From 4d9d9399bbc03a59e391fe9b9bb51b46686f024f Mon Sep 17 00:00:00 2001 From: sriramv Date: Tue, 24 Aug 2021 10:12:58 +0530 Subject: [PATCH] fin_insert:GWM --- app/controllers/financial.controller.js | 18 +++++++++++++++++- app/models/Financials.js | 1 + app/routes/routes.js | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index b5bbecc..2979d84 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -172,5 +172,21 @@ exports.BrokenPeriods = (req, res) => { - +exports.createFinancials = (req, res) => { + let req_array_data = req.body; + req_array_data.forEach((value, key)=>{ + Financials.update({ is_active : 0 },{ where: { id: value.id }}); + delete value.id; + }); + 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" + }); + }); +}; diff --git a/app/models/Financials.js b/app/models/Financials.js index bdf5ef6..05dbf20 100644 --- a/app/models/Financials.js +++ b/app/models/Financials.js @@ -21,6 +21,7 @@ module.exports = (sequelize, DataTypes) => { fy: { type: DataTypes.STRING }, st_type:{ type: DataTypes.STRING }, itemid: { type: DataTypes.INTEGER }, + is_active: { type: DataTypes.INTEGER }, value: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER }, diff --git a/app/routes/routes.js b/app/routes/routes.js index 295d2aa..5b411cf 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -27,8 +27,11 @@ module.exports = app => { // Retrieve all Broken periods router.get("/BrokenPeriodsList/:entityid", financials.BrokenPeriodsList); - // fetchind all master data + // fetching all master data router.get("/MasterDatas", financials.MasterDatas); + + // create financials data + router.post("/createFinancials", financials.createFinancials); //master.controller api's