Surya: statement_type insert api, swagger(newfin yr,st_type insert)

This commit is contained in:
surya 2021-09-14 15:43:16 +05:30
parent 5b6c3b9111
commit 78320a4e71
4 changed files with 166 additions and 53 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/node_modules
/storage
.env
/app/controllers/test.controller.js

View File

@ -39,43 +39,46 @@ exports.MenuList = (req, res) => {
try {
const losid = req.query.losid
// call starter function here
// req_obj ={"losid":losid}
// starter_response = starter(req_obj);
// if(starter_response.status == 200)
// {
Statementsmaster.findAll({
where :{is_active : 1} ,
attributes: ['id', 'statement', 'is_active'],
include :[{
association: 'sectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'section', 'is_active'],
include :[{
association: 'subsectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'subsection','itemtext', 'is_active'],
required :false
}],
required :false
}],
required :false
})
.then(MasterData => {
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
.then(EntitiesData => {
let data = [];
EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data);
}); // end of EntitiesData foreach
res.send({'status':200,'message':"success",'data':data});
logMsg.info("MenuList api working");
}); // end of findall EntitiesData
}); // end of findall masters datas
//} // end of starter function if condition
console.log(losid)
req_obj ={"losid":losid}
starter_response = starter(req_obj);
setTimeout(()=>{
if(starter_response.status == 200)
{
Statementsmaster.findAll({
where :{is_active : 1} ,
attributes: ['id', 'statement', 'is_active'],
include :[{
association: 'sectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'section', 'is_active'],
include :[{
association: 'subsectionsmasterData' ,
where :{is_active : 1} ,
attributes: ['id', 'subsection','itemtext', 'is_active'],
required :false
}],
required :false
}],
required :false
})
.then(MasterData => {
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
.then(EntitiesData => {
let data = [];
EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data);
}); // end of EntitiesData foreach
res.send({'status':200,'message':"success",'data':data});
logMsg.info("MenuList api working");
}); // end of findall EntitiesData
}); // end of findall masters datas
} // end of starter function if condition
},5000)
} catch (err) {
console.log(err)
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
@ -296,6 +299,7 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
Financials.bulkCreate(fin_data_array);
//console.log(fin_data_array)
});
}).catch(err => {
res.status(404).send({'status':404,
@ -312,10 +316,10 @@ Pro42Data.forEach((Pro42Datavalue, key)=>{
}); // end of (losid,pan,cin) combination checking entity data exist or not
}); // end of pro42 data foreach
return {'status':200,'message':"success",'data':"No data"}; // success message
} catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"

View File

@ -4,7 +4,7 @@
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type} = require('../models')
const {sequelize , Statementsmaster ,Sectionsmaster , Subsectionsmaster,Itemsmaster ,Fin_remarks,Fin_masters_history,Statement_type,Entityfinyears} = require('../models')
const { logMsg } = require('../services/logger.js');
@ -265,7 +265,7 @@ exports.Insertitem = (req, res) => {
subsection: req.body.subsection,
itemtext: req.body.itemtext,
is_active: req.body.is_active,
pvt_ltd: req.body.pvt_ltd,
pvtltd: req.body.pvtltd,
llp: req.body.llp,
others: req.body.others,
formula: req.body.formula,
@ -432,7 +432,7 @@ exports.Historyapi = (req, res) => {
// Retrieve all statement types from the database.
exports.Statement_type = (req, res) => {
exports.Statementtype_list = (req, res) => {
Statement_type.findAll({where : { is_active : 1}})
.then(data => {
@ -446,6 +446,26 @@ exports.Statement_type = (req, res) => {
};
exports.Statementtype_insert = (req, res) => {
const req_array_data = req.body;
try
{
// const losid = req_array_data.losid;
//const entityid = req_array_data.entityid;
Entityfinyears.update({ "Y1_st_type":req_array_data.Y1_st_type,"Y2_st_type":req_array_data.Y2_st_type,"Y3_st_type":req_array_data.Y3_st_type,"updatedby":req_array_data.updatedby },{ where: { entityid:req_array_data.entityid}})
res.send({'status':200,'message':"success",'data':"No data"});
logMsg.info("Statementtype_insert Success");
}catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting Statementtype_insert." ,'data': "No data"
}); }
};
@ -523,11 +543,6 @@ exports.Statement_type = (req, res) => {

View File

@ -3,6 +3,7 @@ module.exports = app => {
const cors=require('cors');
const financials = require("../controllers/financial.controller.js");
const master = require("../controllers/master.controller.js");
const test = require("../controllers/test.controller.js");
const { logMsg } = require('../services/logger.js');
var router = require("express").Router();
@ -151,19 +152,111 @@ module.exports = app => {
// create broken periods
router.post("/BrokenPeriods", financials.BrokenPeriods);
// create financials data
router.post("/createFinancials", financials.createFinancials);
// create new FinancialYear skeletion
//post_object = {"losid":"MW12233","entityid":6,"fy":2022,"st_type":2}
/**
* @swagger
* definitions:
* NewFinancialYear:
* type: object
* properties:
* losid:
* type: string
* description: losid
* example: MW12233
* entityid:
* type: integer
* description: entityid
* example: 1
* fy:
* type: integer
* description: financial Year
* example: 2022
* st_type:
* type: integer
* description: statement type
* example: 2
*/
/**
* @swagger
* /api/createFinancialYear:
* post:
* summary: createFinancials
* description: createFinancials
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/NewFinancialYear'
* responses:
* 200:
* description: New Financials Year inserted
* 500:
* description: failure in inserting New Financials Year
*/
router.post("/createFinancialYear", financials.createFinancialYear);
/**
* @openapi
* /api/Statementtype_list:
* get:
* description: This is List api Statementtype
* responses:
* 200:
* description: Returns Statementtype.
*/
router.get("/Statement_type", master.Statement_type);
router.get("/Statementtype_list", master.Statementtype_list);
/**
* @swagger
* definitions:
* Statementtype:
* type: object
* properties:
* entityid:
* type: integer
* description: entityid
* example: 1
* Y1_st_type:
* type: integer
* description: First Year statement type
* example: 1
* Y2_st_type:
* type: integer
* description: Second Year statement type
* example: 1
* Y3_st_type:
* type: integer
* description: Third Year statement type
* example: 1
* updatedby:
* type: integer
* description: The person who modified
* example: 1
*/
/**
* @swagger
* /api/Statementtype_insert:
* post:
* summary: Statementtype_insert
* description: statement type insert against corresponds year
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/Statementtype'
* responses:
* 200:
* description: Statementtype inserted
* 500:
* description: failure in inserting Statementtype
*/
router.post("/Statementtype_insert", master.Statementtype_insert);
router.get("/intiator", test.intiator);
/**
* @swagger
* definitions: