addOrderToMovement

This commit is contained in:
Surya Paolo
2024-01-03 23:19:15 +01:00
parent 66e4c577c7
commit 0aaa331b3f

View File

@@ -473,7 +473,7 @@ module.exports.createOrdersCart = async function (newOrdersCart) {
}
module.exports.addOrderToCash = async function (idorderscart, usernameStore, req) {
module.exports.addOrderToMovement = async function (idorderscart, usernameStore, req) {
try {
@@ -661,13 +661,21 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
}
module.exports.getStorehouseActual = async function (ordersCart) {
return ordersCart && ordersCart.storehouse && ordersCart.storehouse.lenght > 0
? ordersCart.storehouse[0].username
: null
}
module.exports.updateCmd = async function (ordersCart, status, value, req, options) {
const usernameStore = (options && options.usernameStore) ?? null;
let myOrderCart = await OrdersCart.findOne({ _id: ordersCart._id })
.populate('items.order').lean();
const usernameStore = OrdersCart.getStorehouseActual(ordersCart);
try {
if (!!myOrderCart) {
@@ -689,7 +697,7 @@ module.exports.updateCmd = async function (ordersCart, status, value, req, optio
} else if (status === shared_consts.OrderStatus.PAYED) {
if (value) {
await OrdersCart.addOrderToCash(id, usernameStore, req);
await OrdersCart.addOrderToMovement(id, usernameStore, req);
}
ris = await OrdersCart.setPagatoById(value, myOrderCart);
@@ -791,7 +799,7 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
qtystr += qtynum + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true);
if (ord.order.quantitypreordered > 0)
qtystr += ord.order.quantitypreordered + ' Pre-Ordinati'
qtystr += ' Pre-Ordinati';
msg += '✅ [' + qtystr + '] ' + ord.order.product.productInfo.name + ' a ' + ord.order.price + '€ ' + (ord.order.after_price ? ord.order.after_price : '') + '<br>Totale = ' + ord.order.TotalPriceProduct + '€';
}