- Uscita PRIMA VERSIONE PiuCheBuono.app
This commit is contained in:
@@ -74,13 +74,15 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
if (product.cat_name) {
|
||||
arrcat = product.cat_name.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
// Cerca la Categoria
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
// Non esiste questo produttore, quindi lo creo !
|
||||
reccateg = new CatProd({ idapp, name: mycat });
|
||||
reccateg = new CatProd({ idapp, name: mycatstr });
|
||||
ris = await reccateg.save();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
}
|
||||
|
||||
if (reccateg) {
|
||||
@@ -125,9 +127,10 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
if (!options.aggiornaStockQty && esisteindb) {
|
||||
delete product.stockQty;
|
||||
delete product.bookableQty;
|
||||
delete product.maxbookableGASQty;
|
||||
}
|
||||
|
||||
// AGGIORNA PRODUCT
|
||||
let risrec = await Product.findOneAndUpdate({ idProductInfo: product.idProductInfo }, { $set: product }, { new: true, upsert: true });
|
||||
|
||||
let recnew = await Product.findOne({ idProductInfo: product.idProductInfo }).lean();
|
||||
@@ -150,7 +153,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
errors++;
|
||||
}
|
||||
|
||||
await Product.singlerecconvert_AfterImport(idapp, recnew, isnuovo);
|
||||
await Product.singlerecconvert_AfterImport_AndSave(idapp, recnew, isnuovo);
|
||||
} else {
|
||||
console.error('Error ProductInfo: ', product.code);
|
||||
errors++;
|
||||
@@ -162,7 +165,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
/*return await Product.insertMany(dataObjects, { ordered: false })
|
||||
.then((ris) => {
|
||||
|
||||
Product.convertAfterImport(idapp, dataObjects).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp, dataObjects).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
|
||||
@@ -170,7 +173,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
})
|
||||
.catch((errors) => {
|
||||
console.error(errors);
|
||||
Product.convertAfterImport(idapp).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
});*/
|
||||
|
||||
Reference in New Issue
Block a user