++ Cassa - parte 1
This commit is contained in:
@@ -10,6 +10,7 @@ const Storehouse = require('../models/storehouse');
|
||||
const Provider = require('../models/provider');
|
||||
const Gasordine = require('../models/gasordine');
|
||||
const Product = require('../models/product');
|
||||
const Cash = require('../models/cash');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -469,12 +470,25 @@ module.exports.createOrdersCart = async function (newOrdersCart) {
|
||||
return await newOrdersCart.save()
|
||||
}
|
||||
|
||||
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
|
||||
|
||||
module.exports.addOrderToCash = async function (idorderscart, userIdStore, req) {
|
||||
|
||||
try {
|
||||
|
||||
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
|
||||
|
||||
const mycash = await Cash.createMovementCashByOrdersCart(myorderscart, userIdStore, req);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
|
||||
|
||||
try {
|
||||
|
||||
const myorderscart = await OrdersCart.findOne({ _id: idorderscart }).populate('items.order').lean();
|
||||
if (myorderscart) {
|
||||
for (const idkey in myorderscart.items) {
|
||||
let order = myorderscart.items[idkey].order;
|
||||
@@ -633,8 +647,9 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
|
||||
|
||||
}
|
||||
|
||||
module.exports.updateCmd = async function (ordersCart, status, value) {
|
||||
module.exports.updateCmd = async function (ordersCart, status, value, req, options) {
|
||||
|
||||
const userIdStore = options.userIdStore ?? null;
|
||||
|
||||
let myOrderCart = await OrdersCart.findOne({ _id: ordersCart._id })
|
||||
.populate('items.order').lean();
|
||||
@@ -659,6 +674,10 @@ module.exports.updateCmd = async function (ordersCart, status, value) {
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.PAYED) {
|
||||
|
||||
if (value) {
|
||||
await OrdersCart.addOrderToCash(id, userIdStore, req);
|
||||
}
|
||||
|
||||
ris = await OrdersCart.setPagatoById(value, myOrderCart);
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.DELIVERED) { // Consegnato
|
||||
|
||||
Reference in New Issue
Block a user