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

@@ -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;
}