- preordinabili corretti + altro

This commit is contained in:
Surya Paolo
2023-12-29 21:17:17 +01:00
parent 633b9a2d8c
commit ade9c149c5
11 changed files with 138 additions and 41 deletions

View File

@@ -83,6 +83,14 @@ const productSchema = new Schema({
type: Number,
default: 0,
},
stockBloccatiQty: { // Prenotati
type: Number,
default: 0,
},
bookableBloccatiQty: { // Quantità Prenotati e prenotabili
type: Number,
default: 0,
},
quantityLow: { //Soglia disponibilità bassa
type: Number,
default: 0,
@@ -124,6 +132,9 @@ const productSchema = new Schema({
sconto2: {
type: String,
},
gas_name: {
type: String,
},
});
var Product = module.exports = mongoose.model('Product', productSchema);
@@ -507,6 +518,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
try {
let objtoset = {}
let rec = null
// Impostazioni Base:
if (isnuovo) {
@@ -574,6 +586,24 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
setta = true;
}
}
if (prod.gas_name) {
// Cerca il GAS
rec = await Gasordine.findOne({ idapp, name: prod.gas_name }).lean();
if (!rec) {
rec = new Gasordine({ idapp, name: prod.gas_name, active: true });
// Non esiste questo GAS, quindi lo creo !
ris = await rec.save();
rec = await Gasordine.findOne({ idapp, name: prod.gas_name }).lean();
}
if (rec) {
objtoset = {
...objtoset,
idGasordines: [rec._id],
}
setta = true;
}
}
let arrsconti = []
@@ -638,6 +668,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
magazzino_name: 1,
sconto1: 1,
sconto2: 1,
gas_name: 1,
};
ris = await Product.updateOne({ _id: ObjectID(prod._id) }, { $unset: objDelete })