aggio gasordine

This commit is contained in:
Surya Paolo
2024-01-16 16:56:39 +01:00
parent 9265e9bfb3
commit d22e808626
4 changed files with 39 additions and 14 deletions

View File

@@ -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 {