aggiornato stockQta quando l'ordine viene evaso

This commit is contained in:
Surya Paolo
2023-12-14 00:55:07 +01:00
parent fcdd826c54
commit d0bf7e1b6a
3 changed files with 78 additions and 4 deletions

View File

@@ -281,7 +281,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
const user = req.user;
let status = req.body.status;
const orderCart = await OrdersCart.find({ idapp, _id: order_id });
const orderCart = await OrdersCart.findOne({ idapp, _id: order_id }).lean();
if ((userId !== String(req.user._id)) && !User.isManager(req.user.perm)) {
// I'm trying to write something not mine!
@@ -303,7 +303,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
await OrdersCart.updateCmd(orderCart, status, true);
let ordertype = '';
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
ordertype = 'order_confirmed';
} else if (status === shared_consts.OrderStatus.COMPLETED) {
@@ -313,7 +313,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
}
if (ordertype !== '') {
sendemail.sendEmail_Order(user.lang, idapp, orderCart[0], user, ordertype)
sendemail.sendEmail_Order(user.lang, idapp, orderCart, user, ordertype)
.then((ris) => {
})