aggiornato prodotti e scontistica
This commit is contained in:
@@ -66,6 +66,11 @@ const productSchema = new Schema({
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
minStepQty: { // step quantità acquistabile
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
maxBookableQty: { // quantità massima Pre-ordinabile (singolarmente)
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -113,6 +118,12 @@ const productSchema = new Schema({
|
||||
cat_name: {
|
||||
type: String,
|
||||
},
|
||||
sconto1: {
|
||||
type: String,
|
||||
},
|
||||
sconto2: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Product = module.exports = mongoose.model('Product', productSchema);
|
||||
@@ -502,6 +513,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
objtoset = {
|
||||
idapp,
|
||||
minBuyQty: 1,
|
||||
minStepQty: 1,
|
||||
maxBookableQty: 0,
|
||||
}
|
||||
}
|
||||
@@ -563,6 +575,46 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
}
|
||||
}
|
||||
|
||||
let arrsconti = []
|
||||
|
||||
if (prod.sconto1) {
|
||||
// Cerca la scontistica
|
||||
let recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto1 }).lean();
|
||||
if (!recscontistica) {
|
||||
recscontistica = new Scontistica({ idapp, code: prod.sconto1 });
|
||||
// Non esiste questa scontistica, quindi lo creo !
|
||||
ris = await recscontistica.save();
|
||||
recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto1 }).lean();
|
||||
}
|
||||
|
||||
if (recscontistica) {
|
||||
arrsconti.push(recscontistica);
|
||||
}
|
||||
}
|
||||
|
||||
if (prod.sconto2) {
|
||||
// Cerca la scontistica
|
||||
let recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto2 }).lean();
|
||||
if (!recscontistica) {
|
||||
recscontistica = new Scontistica({ idapp, code: prod.sconto2 });
|
||||
// Non esiste questa scontistica, quindi lo creo !
|
||||
ris = await recscontistica.save();
|
||||
recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto2 }).lean();
|
||||
}
|
||||
|
||||
if (recscontistica) {
|
||||
arrsconti.push(recscontistica);
|
||||
}
|
||||
}
|
||||
|
||||
if (arrsconti.length > 0) {
|
||||
objtoset = {
|
||||
...objtoset,
|
||||
idScontisticas: arrsconti,
|
||||
}
|
||||
setta = true;
|
||||
}
|
||||
|
||||
// Aggiorna il prezzo ?
|
||||
const aggiornaprezzo = false;
|
||||
if (aggiornaprezzo) {
|
||||
@@ -584,6 +636,8 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
producer_name: 1,
|
||||
provider_name: 1,
|
||||
magazzino_name: 1,
|
||||
sconto1: 1,
|
||||
sconto2: 1,
|
||||
};
|
||||
|
||||
ris = await Product.updateOne({ _id: ObjectID(prod._id) }, { $unset: objDelete })
|
||||
|
||||
Reference in New Issue
Block a user