agiornamento, sistemazioni varie PCB
This commit is contained in:
37
.vscode/launch.json
vendored
37
.vscode/launch.json
vendored
@@ -11,15 +11,17 @@
|
|||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"--inspect=9229" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
"--inspect=9229" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
||||||
],
|
],
|
||||||
"args": ["${workspaceFolder}/src/server/server.js"], // Replace with your entry file
|
"args": [
|
||||||
|
"${workspaceFolder}/src/server/server.js"
|
||||||
|
], // Replace with your entry file
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"autoAttachChildProcesses": true,
|
"autoAttachChildProcesses": true,
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"internalConsoleOptions": "neverOpen",
|
"internalConsoleOptions": "neverOpen",
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV":"development",
|
"NODE_ENV": "development",
|
||||||
"TESTING_ON":"1"
|
"TESTING_ON": "1"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -32,33 +34,18 @@
|
|||||||
"runtimeArgs": [
|
"runtimeArgs": [
|
||||||
"--trace-warnings" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
"--trace-warnings" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
||||||
],
|
],
|
||||||
"args": ["${workspaceFolder}/src/server/server.js"], // Replace with your entry file
|
"args": [
|
||||||
|
"${workspaceFolder}/src/server/server.js"
|
||||||
|
], // Replace with your entry file
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"autoAttachChildProcesses": true,
|
"autoAttachChildProcesses": true,
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"internalConsoleOptions": "neverOpen",
|
"internalConsoleOptions": "neverOpen",
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV":"development",
|
"NODE_ENV": "development",
|
||||||
"TESTING_ON":"1"
|
"TESTING_ON": "1"
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Server Debug",
|
|
||||||
"request": "launch",
|
|
||||||
"runtimeArgs": [
|
|
||||||
"run-script",
|
|
||||||
"start"
|
|
||||||
],
|
|
||||||
"runtimeExecutable": "npm",
|
|
||||||
"skipFiles": [
|
|
||||||
"<node_internals>/**"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"NODE_ENV":"development",
|
|
||||||
"TESTING_ON":"1"
|
|
||||||
},
|
|
||||||
"type": "node"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ServerSide",
|
"name": "ServerSide",
|
||||||
@@ -69,8 +56,8 @@
|
|||||||
],
|
],
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV":"development",
|
"NODE_ENV": "development",
|
||||||
"TESTING_ON":"1"
|
"TESTING_ON": "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -132,3 +132,5 @@ come funziona:
|
|||||||
- accedete e poi cliccate su "gruppo di acquisto".
|
- accedete e poi cliccate su "gruppo di acquisto".
|
||||||
- cliccate sul carrello verde 🛒 per aggiungere i kg che desiderate.
|
- cliccate sul carrello verde 🛒 per aggiungere i kg che desiderate.
|
||||||
- per finire: cliccare su "procedi all'ordine" e confermate.
|
- per finire: cliccare su "procedi all'ordine" e confermate.
|
||||||
|
|
||||||
|
Dom 21/01 ORE 19:00: USER [paoloar77]: 👉🏻 indietro
|
||||||
|
|||||||
@@ -26,4 +26,6 @@ Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
|||||||
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
Sab 02/12 ORE 14:15: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
Sab 02/12 ORE 14:15: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
|
Dom 21/01 ORE 19:00: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
|
👉🏻 indietro
|
||||||
@@ -19,6 +19,7 @@ const Cart = require('../models/cart');
|
|||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
const OrdersCartSchema = new Schema({
|
const OrdersCartSchema = new Schema({
|
||||||
@@ -521,6 +522,24 @@ module.exports.addOrderToMovement = async function (myOrderCart, usernameStore,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.checkQtaIfIsLow_SendAlert = async function (idapp, idProduct) {
|
||||||
|
try {
|
||||||
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
|
const isLow = await Product.isLowQuantityInStockById(idProduct);
|
||||||
|
const instock = await Product.getInStockById(idProduct);
|
||||||
|
const myprod = await Product.getProductById(idProduct);
|
||||||
|
if (isLow && myprod) {
|
||||||
|
let msg = `Il Prodotto '${myprod.productInfo.name}' è rimasto a ${instock} quantità !`;
|
||||||
|
|
||||||
|
await telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Err;', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart) {
|
module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -545,6 +564,8 @@ module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||||
|
|
||||||
|
await OrdersCart.checkQtaIfIsLow_SendAlert(myorderscart.idapp, order.idProduct)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -555,6 +576,7 @@ module.exports.updateMagazzinoOrdineInLavorazione = async function (idorderscart
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
|
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -653,7 +675,7 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
|
|||||||
|
|
||||||
fieldstoUpdate = {
|
fieldstoUpdate = {
|
||||||
...fieldstoUpdate,
|
...fieldstoUpdate,
|
||||||
bookedQtyOrdered,
|
bookedQtyOrdered: -order.quantity,
|
||||||
}
|
}
|
||||||
|
|
||||||
update = {
|
update = {
|
||||||
@@ -676,7 +698,7 @@ module.exports.updateStockQtaPerCancellazioneOrdine = async function (idordersca
|
|||||||
|
|
||||||
fieldstoUpdate = {
|
fieldstoUpdate = {
|
||||||
...fieldstoUpdate,
|
...fieldstoUpdate,
|
||||||
bookedGASQtyOrdered,
|
bookedGASQtyOrdered: -order.quantitypreordered,
|
||||||
}
|
}
|
||||||
|
|
||||||
update = {
|
update = {
|
||||||
|
|||||||
@@ -191,6 +191,29 @@ module.exports.getProductById = async function (id) {
|
|||||||
return arrris && arrris.length > 0 ? arrris[0] : null
|
return arrris && arrris.length > 0 ? arrris[0] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.getInStockById = async function (id) {
|
||||||
|
const myprod = await Product.findOne({ _id: id });
|
||||||
|
if (myprod) {
|
||||||
|
let instock = 0;
|
||||||
|
if (myprod.idGasordine) {
|
||||||
|
instock = myprod.maxbookableGASQty;
|
||||||
|
} else {
|
||||||
|
instock = myprod.stockQty;
|
||||||
|
}
|
||||||
|
return instock
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.isLowQuantityInStockById = async function (id) {
|
||||||
|
const instock = await Product.getInStockById(id);
|
||||||
|
const myprod = await Product.findOne({ _id: id });
|
||||||
|
if (instock) {
|
||||||
|
return (instock <= (myprod.quantityLow + 1));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
||||||
let myfind = {};
|
let myfind = {};
|
||||||
let myqueryadd = {};
|
let myqueryadd = {};
|
||||||
@@ -554,6 +577,68 @@ module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.getArrCatProds = async function (idapp, cosa) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
let addquery = {};
|
||||||
|
let arr = [];
|
||||||
|
if (cosa === shared_consts.PROD.GAS) {
|
||||||
|
addquery = { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } }
|
||||||
|
} else if (cosa === shared_consts.PROD.BOTTEGA) {
|
||||||
|
addquery = {
|
||||||
|
idapp, $or: [
|
||||||
|
{ idGasordine: { $exists: false } },
|
||||||
|
{ idGasordine: { $exists: true, $eq: null } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addquery = { idapp };
|
||||||
|
}
|
||||||
|
|
||||||
|
let myquery = [
|
||||||
|
{ $match: addquery },
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "productinfos",
|
||||||
|
localField: "idProductInfo",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "productInfo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "catprods",
|
||||||
|
localField: "productInfo.idCatProds",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "category"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ $unwind: "$category" },
|
||||||
|
{ $group: { _id: "$category._id", name: { $first: "$category.name" } } },
|
||||||
|
{ $sort: { name: 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
arr = await Product.aggregate(myquery, (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
// Gestisci l'errore come desideri
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
const uniqueCategories = result.map(category => category.name);
|
||||||
|
// console.log(uniqueCategories);
|
||||||
|
return uniqueCategories;
|
||||||
|
// Ora uniqueCategories contiene l'array delle categorie univoche utilizzate in tutti i prodotti con active = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('err', e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, prod, isnuovo) {
|
module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, prod, isnuovo) {
|
||||||
|
|
||||||
let setta = false;
|
let setta = false;
|
||||||
|
|||||||
@@ -56,18 +56,21 @@ class Cart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSameStorehouse(itemorder) {
|
isSameStorehouse(itemorder) {
|
||||||
if (this.items.length > 0) {
|
try {
|
||||||
const mystorehouse = this.items[0].order.idStorehouse
|
if (this.items.length > 0) {
|
||||||
return (mystorehouse ? mystorehouse._id.toString() === itemorder.idStorehouse : true);
|
const mystorehouse = this.items[0].order.idStorehouse
|
||||||
} else {
|
return (mystorehouse ? mystorehouse._id.toString() === itemorder.idStorehouse : true);
|
||||||
return true;
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addqty(itemorder) {
|
async addqty(itemorder) {
|
||||||
|
|
||||||
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
||||||
if (!!myitem) {
|
if (!!myitem) {
|
||||||
let stepmin = myitem.order.product.minStepQty;
|
let stepmin = myitem.order.product.minStepQty;
|
||||||
|
|||||||
@@ -1440,7 +1440,8 @@ function load(req, res, version) {
|
|||||||
let workers = User.getusersWorkersList(idapp);
|
let workers = User.getusersWorkersList(idapp);
|
||||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||||
let providers = Provider.findAllIdApp(idapp);
|
let providers = Provider.findAllIdApp(idapp);
|
||||||
let catprods = CatProd.findAllIdApp(idapp);
|
let catprods = Product.getArrCatProds(idapp, shared_consts.PROD.BOTTEGA);
|
||||||
|
let catprods_gas = Product.getArrCatProds(idapp, shared_consts.PROD.GAS);
|
||||||
let subcatprods = SubCatProd.findAllIdApp(idapp);
|
let subcatprods = SubCatProd.findAllIdApp(idapp);
|
||||||
let gasordines = Gasordine.findAllIdApp(idapp);
|
let gasordines = Gasordine.findAllIdApp(idapp);
|
||||||
let ismanager = false;
|
let ismanager = false;
|
||||||
@@ -1455,6 +1456,7 @@ function load(req, res, version) {
|
|||||||
let departments = Department.findAllIdApp(idapp);
|
let departments = Department.findAllIdApp(idapp);
|
||||||
let categories = Category.findAllIdApp(idapp);
|
let categories = Category.findAllIdApp(idapp);
|
||||||
|
|
||||||
|
|
||||||
// SKILLS:
|
// SKILLS:
|
||||||
let levels = Level.findAllIdApp(idapp);
|
let levels = Level.findAllIdApp(idapp);
|
||||||
let adtypes = AdType.findAllIdApp(idapp);
|
let adtypes = AdType.findAllIdApp(idapp);
|
||||||
@@ -1545,6 +1547,7 @@ function load(req, res, version) {
|
|||||||
productInfos,
|
productInfos,
|
||||||
catprods,
|
catprods,
|
||||||
subcatprods,
|
subcatprods,
|
||||||
|
catprods_gas,
|
||||||
]).then((arrdata) => {
|
]).then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
let myuser = req.user;
|
let myuser = req.user;
|
||||||
@@ -1634,6 +1637,7 @@ function load(req, res, version) {
|
|||||||
productInfos: arrdata[44],
|
productInfos: arrdata[44],
|
||||||
catprods: arrdata[45],
|
catprods: arrdata[45],
|
||||||
subcatprods: arrdata[46],
|
subcatprods: arrdata[46],
|
||||||
|
catprods_gas: arrdata[47],
|
||||||
});
|
});
|
||||||
|
|
||||||
const prova = 1;
|
const prova = 1;
|
||||||
|
|||||||
@@ -4395,8 +4395,9 @@ if (true) {
|
|||||||
console.error('Error Telegram LOOP : ' + e.message);
|
console.error('Error Telegram LOOP : ' + e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch((e) => {
|
||||||
arrTeleg = [];
|
arrTeleg = [];
|
||||||
|
console.error('Error internetAvailable:' + e);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user