orderBy:GWM
This commit is contained in:
parent
4e7f57113b
commit
5fd5650971
@ -6,13 +6,13 @@ 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() => {
|
||||||
res.send({'status':200 , message:"Success." ,'data': OtherIncomeData});
|
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});
|
||||||
|
}, 500);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("create master data for losid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 }
|
||||||
|
|||||||
@ -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 },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user