- abilitato circuits e groups
This commit is contained in:
@@ -473,13 +473,13 @@ module.exports.createOrdersCart = async function (newOrdersCart) {
|
||||
}
|
||||
|
||||
|
||||
module.exports.addOrderToMovement = async function (idorderscart, usernameStore, req) {
|
||||
module.exports.addOrderToMovement = async function (idorderscart, usernameStore, groupnameStore, req) {
|
||||
|
||||
try {
|
||||
|
||||
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
|
||||
|
||||
const mymov = await Circuit.addMovementByOrdersCart(id, myOrderCart, usernameStore, '');
|
||||
const mymov = await Circuit.addMovementByOrdersCart(id, myOrderCart, usernameStore, groupnameStore);
|
||||
// const mycash = await Cash.createMovementCashByOrdersCart(myorderscart, usernameStore, req);
|
||||
|
||||
} catch (e) {
|
||||
@@ -661,20 +661,28 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
|
||||
|
||||
}
|
||||
|
||||
module.exports.getStorehouseActual = async function (ordersCart) {
|
||||
module.exports.getUsernameStorehouseActual = async function (ordersCart) {
|
||||
|
||||
return ordersCart && ordersCart.storehouse && ordersCart.storehouse.lenght > 0
|
||||
? ordersCart.storehouse[0].username
|
||||
: null
|
||||
}
|
||||
|
||||
module.exports.getGroupnameStorehouseActual = async function (ordersCart) {
|
||||
|
||||
return ordersCart && ordersCart.storehouse && ordersCart.storehouse.lenght > 0
|
||||
? ordersCart.storehouse[0].groupname
|
||||
: null
|
||||
}
|
||||
|
||||
module.exports.updateCmd = async function (ordersCart, status, value, req, options) {
|
||||
|
||||
|
||||
let myOrderCart = await OrdersCart.findOne({ _id: ordersCart._id })
|
||||
.populate('items.order').lean();
|
||||
|
||||
const usernameStore = OrdersCart.getStorehouseActual(ordersCart);
|
||||
const usernameStore = OrdersCart.getUsernameStorehouseActual(ordersCart);
|
||||
const groupnameStore = OrdersCart.getGroupnameStorehouseActual(ordersCart);
|
||||
|
||||
try {
|
||||
if (!!myOrderCart) {
|
||||
@@ -697,7 +705,7 @@ module.exports.updateCmd = async function (ordersCart, status, value, req, optio
|
||||
} else if (status === shared_consts.OrderStatus.PAYED) {
|
||||
|
||||
if (value) {
|
||||
await OrdersCart.addOrderToMovement(id, usernameStore, req);
|
||||
await OrdersCart.addOrderToMovement(id, usernameStore, groupnameStore, req);
|
||||
}
|
||||
|
||||
ris = await OrdersCart.setPagatoById(value, myOrderCart);
|
||||
|
||||
@@ -22,7 +22,9 @@ const storehouseSchema = new Schema({
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
groupname: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
|
||||
Reference in New Issue
Block a user