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