agiornamento, sistemazioni varie PCB

This commit is contained in:
Surya Paolo
2024-01-23 00:10:40 +01:00
parent e4504bcf9e
commit aeabf96efe
8 changed files with 144 additions and 38 deletions

View File

@@ -19,6 +19,7 @@ const Cart = require('../models/cart');
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const OrdersCartSchema = new Schema({
@@ -521,6 +522,24 @@ module.exports.addOrderToMovement = async function (myOrderCart, usernameStore,
}
}
module.exports.checkQtaIfIsLow_SendAlert = async function (idapp, idProduct) {
try {
const telegrambot = require('../telegram/telegrambot');
const isLow = await Product.isLowQuantityInStockById(idProduct);
const instock = await Product.getInStockById(idProduct);
const myprod = await Product.getProductById(idProduct);
if (isLow && myprod) {
let msg = `Il Prodotto '${myprod.productInfo.name}' è rimasto a ${instock} quantità !`;
await telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
}
} catch (e) {
console.error('Err;', e);
}
}
module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart) {
try {
@@ -545,6 +564,8 @@ module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart
}
};
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
await OrdersCart.checkQtaIfIsLow_SendAlert(myorderscart.idapp, order.idProduct)
}
}
@@ -555,6 +576,7 @@ module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart
}
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
try {
@@ -653,7 +675,7 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
fieldstoUpdate = {
...fieldstoUpdate,
bookedQtyOrdered,
bookedQtyOrdered: -order.quantity,
}
update = {
@@ -676,7 +698,7 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
fieldstoUpdate = {
...fieldstoUpdate,
bookedGASQtyOrdered,
bookedGASQtyOrdered: -order.quantitypreordered,
}
update = {