aggio gasordine
This commit is contained in:
@@ -144,7 +144,24 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
let recProductExist = await Product.findOne({ idProductInfo: product.idProductInfo }).lean();
|
||||
// Cerca il GAS
|
||||
let recGas = null;
|
||||
if (prod.gas_name) {
|
||||
// Cerca il GAS
|
||||
recGas = await Gasordine.findOne({ idapp, name: prod.gas_name }).lean();
|
||||
}
|
||||
|
||||
let recProductExist = null;
|
||||
let queryprod = { idProductInfo: product.idProductInfo };
|
||||
|
||||
if (recGas) {
|
||||
queryprod = {...queryprod, gas}
|
||||
} else {
|
||||
recProductExist = await Product.findOne().lean();
|
||||
}
|
||||
|
||||
recProductExist = await Product.findOne({ queryprod }).lean();
|
||||
|
||||
if (!recProductExist) {
|
||||
isnuovo = true;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ router.post('/', auth_default, async function (req, res, next) {
|
||||
if (products)
|
||||
res.send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
else
|
||||
res.status(400).send(e);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
|
||||
/*
|
||||
const { query, order } = tools.categorizeQueryString(req.query)
|
||||
|
||||
@@ -1330,6 +1330,16 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
} else if (mydata.dbop === 'SistemaGasOrdine') {
|
||||
const arrrec = await Product.find({}).lean();
|
||||
for (const rec of arrrec) {
|
||||
if (tools.isArray(rec.idGasordines) && rec.idGasordines.length > 0) {
|
||||
await Product.findByIdAndUpdate(rec._id, { $set: { idGasordine: rec.idGasordines[0] } })
|
||||
} else {
|
||||
await Product.findByIdAndUpdate(rec._id, { $set: { idGasordine: null } })
|
||||
}
|
||||
}
|
||||
|
||||
} else if (mydata.dbop === 'CopyPriceToCalc') {
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user