diff --git a/app/controllers/financial.controller.js b/app/controllers/financial.controller.js index b3794fb..6d0d10c 100644 --- a/app/controllers/financial.controller.js +++ b/app/controllers/financial.controller.js @@ -8,19 +8,36 @@ const { logMsg } = require('../services/logger.js'); // menu list api exports.MenuList = async (req, res) => { - + //findAll({ where :{is_active : 1} ,include : { association: 'sectionsmasterData' } }); + //findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} }}); try { const losid = req.params.losid - //const MasterData = await Statementsmaster.findAll({include : 'sectionsmasterData'}); - let EntitiesData = await Entities.findAll({where : { losid } }); - - return res.send({'status':200,'message':"success",'data':EntitiesData}); + const MasterData = await Statementsmaster.findAll({ + where :{is_active : 1} , + include :[{ + association: 'sectionsmasterData' , + where :{is_active : 1} , + include :[{ + association: 'subsectionsmasterData' , + //where :{is_active : 1} + }] + }] + }); + const EntitiesData = await Entities.findAll({where : { losid } }); + let data = []; + EntitiesData.forEach((value, key)=>{ + obj_data = { ...value.dataValues , statementsmasterrData:MasterData} + data.push(obj_data); + }); + return res.send({'status':200,'message':"success",'data':data}); } catch (err) { console.log(err) return res.status(500).json({'status':404,'message':"failed",'data':"No data"}) } }; + + // Retrieve all Entities from the database. exports.findAllEntities = (req, res) => { diff --git a/app/models/Statementsmaster.js b/app/models/Statementsmaster.js index e3e87cb..4978018 100644 --- a/app/models/Statementsmaster.js +++ b/app/models/Statementsmaster.js @@ -17,8 +17,13 @@ module.exports = (sequelize, DataTypes) => { } Statementsmaster.init( { +<<<<<<< HEAD statement: { type: DataTypes.STRING }, is_active: { type: DataTypes.INTEGER }, +======= + statement: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, +>>>>>>> 58fe8288fbfafc85973b4d3718def076990ff1d2 createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER }, diff --git a/app/models/Subsectionsmaster.js b/app/models/Subsectionsmaster.js index 751bc50..dc84841 100644 --- a/app/models/Subsectionsmaster.js +++ b/app/models/Subsectionsmaster.js @@ -20,9 +20,9 @@ module.exports = (sequelize, DataTypes) => { Subsectionsmaster.init( { section: { type: DataTypes.INTEGER }, - subsection: { type: DataTypes.STRING }, - itemtext: { type: DataTypes.STRING }, - is_active: { type: DataTypes.INTEGER }, + subsection: { type: DataTypes.STRING }, + itemtext: { type: DataTypes.STRING }, + is_active: { type: DataTypes.INTEGER }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER },