Merge branch 'master' of bitbucket.org:venbainformationtechnology/smc_cet_otherincome_backend
This commit is contained in:
commit
88dfb4011a
@ -1,18 +1,18 @@
|
|||||||
|
|
||||||
const { sequelize,MasterP , MasterC , OtherIncomeP , OtherIncomeC} = require('../models')
|
const { sequelize,MasterP , MasterC , OtherIncomeP , OtherIncomeC , Master} = require('../models')
|
||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
|
|
||||||
exports.otherIncomeList = async (req, res) =>
|
exports.otherIncomeList = async (req, res) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OtherIncomeData = await OtherIncomeP.findAll({ where:{ losid:req.query.losid, is_active:1},include:[{model:OtherIncomeC}]}).catch(err=>{});
|
OtherIncomeData = await OtherIncomeP.findAll({ where:{ losid:req.query.losid, is_active:1},order :[['order_id','ASC']],include:[{model:OtherIncomeC}]}).catch(err=>{});
|
||||||
|
|
||||||
if(OtherIncomeData.length != 0)
|
if(OtherIncomeData.length != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
res.send({'status':200 , message:"Success." ,'data': OtherIncomeData});
|
res.send({'status':200 , message:"Success." ,'data': OtherIncomeData});
|
||||||
console.log("data already exist");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ exports.otherIncomeList = async (req, res) =>
|
|||||||
var MasterDataInsert = new Promise(async(resolve, reject) => {
|
var MasterDataInsert = new Promise(async(resolve, reject) => {
|
||||||
|
|
||||||
MasterData.forEach(async(master_value,index,array) => {
|
MasterData.forEach(async(master_value,index,array) => {
|
||||||
OtherIncomeP.create({losid:req.query.losid,table_name:master_value.table_name,particulars:master_value.particulars})
|
OtherIncomeP.create({losid:req.query.losid,order_id:master_value.order_id,table_name:master_value.table_name,particulars:master_value.particulars})
|
||||||
.then(async(parent_data)=>{
|
.then(async(parent_data)=>{
|
||||||
master_value.MasterCs.forEach(async(child_data) => {
|
master_value.MasterCs.forEach(async(child_data) => {
|
||||||
await OtherIncomeC.create({other_income_id:parent_data.dataValues.id,column_name:child_data.column_name,value:child_data.value})
|
await OtherIncomeC.create({other_income_id:parent_data.dataValues.id,column_name:child_data.column_name,value:child_data.value})
|
||||||
@ -33,11 +33,14 @@ exports.otherIncomeList = async (req, res) =>
|
|||||||
|
|
||||||
});
|
});
|
||||||
MasterDataInsert.then(async()=>{
|
MasterDataInsert.then(async()=>{
|
||||||
OtherIncomeData = await OtherIncomeP.findAll({ where:{ losid:req.query.losid, is_active:1},include:[{model:OtherIncomeC}]}).catch(err=>{});
|
setTimeout(async() => {
|
||||||
|
OtherIncomeData = await OtherIncomeP.findAll({ where:{ losid:req.query.losid, is_active:1},order :[['order_id','ASC']],include:[{model:OtherIncomeC}]}).catch(err=>{});
|
||||||
res.send({'status':200 , message:"Success." ,'data': OtherIncomeData});
|
res.send({'status':200 , message:"Success." ,'data': OtherIncomeData});
|
||||||
|
}, 500);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("create master data for losid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +84,22 @@ exports.updateOtherIncome = async (req, res) =>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.getMasterData = async (req, res) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data =await Master.findAll();
|
||||||
|
res.send({'status':200 , message:"Success." ,'data': data});
|
||||||
|
|
||||||
|
} catch(err) {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); } //end of try catch
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
app/models/Master.js
Normal file
25
app/models/Master.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
'use strict'
|
||||||
|
const { Model } = require('sequelize')
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Master extends Model {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Master.init(
|
||||||
|
{
|
||||||
|
|
||||||
|
order_id: { type: DataTypes.INTEGER },
|
||||||
|
column_name: { type: DataTypes.STRING },
|
||||||
|
master_value: { type: DataTypes.STRING },
|
||||||
|
formula: { type: DataTypes.STRING }
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sequelize,
|
||||||
|
tableName: 'master',
|
||||||
|
modelName: 'Master',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return Master
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
{
|
{
|
||||||
master_id: { type: DataTypes.INTEGER },
|
master_id: { type: DataTypes.INTEGER },
|
||||||
column_name: { type: DataTypes.STRING },
|
column_name: { type: DataTypes.STRING },
|
||||||
value: { type: DataTypes.INTEGER },
|
value: { type: DataTypes.STRING },
|
||||||
is_active: { type: DataTypes.INTEGER }
|
is_active: { type: DataTypes.INTEGER }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,6 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
}
|
}
|
||||||
MasterP.init(
|
MasterP.init(
|
||||||
{
|
{
|
||||||
|
order_id: { type: DataTypes.INTEGER },
|
||||||
table_name: { type: DataTypes.STRING },
|
table_name: { type: DataTypes.STRING },
|
||||||
particulars: { type: DataTypes.STRING },
|
particulars: { type: DataTypes.STRING },
|
||||||
is_active: { type: DataTypes.INTEGER }
|
is_active: { type: DataTypes.INTEGER }
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
|
|
||||||
other_income_id: { type: DataTypes.INTEGER },
|
other_income_id: { type: DataTypes.INTEGER },
|
||||||
column_name: { type: DataTypes.STRING },
|
column_name: { type: DataTypes.STRING },
|
||||||
value: { type: DataTypes.INTEGER },
|
value: { type: DataTypes.STRING },
|
||||||
is_active: { type: DataTypes.INTEGER },
|
is_active: { type: DataTypes.INTEGER },
|
||||||
createdby: { type: DataTypes.INTEGER },
|
createdby: { type: DataTypes.INTEGER },
|
||||||
updatedby: { type: DataTypes.INTEGER }
|
updatedby: { type: DataTypes.INTEGER }
|
||||||
|
|||||||
@ -8,6 +8,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
OtherIncomeP.init(
|
OtherIncomeP.init(
|
||||||
{
|
{
|
||||||
losid: { type: DataTypes.STRING },
|
losid: { type: DataTypes.STRING },
|
||||||
|
order_id: { type: DataTypes.INTEGER },
|
||||||
table_name: { type: DataTypes.STRING },
|
table_name: { type: DataTypes.STRING },
|
||||||
particulars: { type: DataTypes.STRING },
|
particulars: { type: DataTypes.STRING },
|
||||||
is_active: { type: DataTypes.INTEGER },
|
is_active: { type: DataTypes.INTEGER },
|
||||||
|
|||||||
@ -5,6 +5,19 @@ module.exports = app => {
|
|||||||
const { logMsg } = require('../services/logger.js');
|
const { logMsg } = require('../services/logger.js');
|
||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/getMasterData:
|
||||||
|
* get:
|
||||||
|
* summary: other Income data List
|
||||||
|
* description:
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: success
|
||||||
|
*/
|
||||||
|
router.get("/getMasterData", IncomeController.getMasterData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/otherIncomeList:
|
* /api/otherIncomeList:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user