- aggiungo campo "sfuso"

- aggiunto totale al carrello
This commit is contained in:
Surya Paolo
2024-02-11 16:33:00 +01:00
parent e7b0fd1d95
commit 9ca9ea6eaa
14 changed files with 41 additions and 17 deletions

View File

@@ -4,8 +4,8 @@ PDB=mypassword@1A
SEND_EMAIL=0 SEND_EMAIL=0
SEND_EMAIL_ORDERS=1 SEND_EMAIL_ORDERS=1
PORT=3000 PORT=3000
appTelegram_TEST=["1","13"] appTelegram_TEST=["1","17"]
appTelegram=["1","13"] appTelegram=["1","17"]
DOMAIN=mongodb://localhost:27017/ DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true AUTH_MONGODB=true
MONGODB_USER=admin MONGODB_USER=admin

View File

@@ -4,8 +4,8 @@ PDB=mypassword@1A
SEND_EMAIL=0 SEND_EMAIL=0
SEND_EMAIL_ORDERS=1 SEND_EMAIL_ORDERS=1
PORT=3000 PORT=3000
appTelegram_TEST=["1","13"] appTelegram_TEST=["1","17"]
appTelegram=["1","13"] appTelegram=["1","17"]
DOMAIN=mongodb://localhost:27017/ DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=true AUTH_MONGODB=true
MONGODB_USER=admin MONGODB_USER=admin

View File

@@ -67,7 +67,7 @@ html
- var img = rec.order.product.productInfo.img - var img = rec.order.product.productInfo.img
- var price = rec.order.price - var price = rec.order.price
- var after_price = rec.order.after_price - var after_price = rec.order.after_price
- var TotalPriceProduct = rec.order.TotalPriceProduct - var TotalPriceProduct = rec.order.TotalPriceProductstr
if (rec.order.gasordine) if (rec.order.gasordine)
- var gasordine = rec.order.gasordine.name - var gasordine = rec.order.gasordine.name
else else

View File

@@ -65,7 +65,7 @@ html
- var gasordine = '' - var gasordine = ''
- var qty = rec.order.product.quantity - var qty = rec.order.product.quantity
- var qtypreordered = rec.order.quantitypreordered - var qtypreordered = rec.order.quantitypreordered
- var TotalPriceProduct = rec.order.TotalPriceProduct - var TotalPriceProduct = rec.order.TotalPriceProductstr
- index = index + 1 - index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center") table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")

View File

@@ -72,7 +72,7 @@ html
- var qty = rec.order.product.quantity - var qty = rec.order.product.quantity
- var qtypreordered = rec.order.quantitypreordered - var qtypreordered = rec.order.quantitypreordered
- var unit = rec.order.product.productInfo.unitstr - var unit = rec.order.product.productInfo.unitstr
- var TotalPriceProduct = rec.order.TotalPriceProduct - var TotalPriceProduct = rec.order.TotalPriceProductstr
- index = index + 1 - index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center") table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")

View File

@@ -71,7 +71,7 @@ html
- var qty = rec.order.product.quantity - var qty = rec.order.product.quantity
- var qtypreordered = rec.order.quantitypreordered - var qtypreordered = rec.order.quantitypreordered
- var unit = rec.order.product.productInfo.unitstr - var unit = rec.order.product.productInfo.unitstr
- var TotalPriceProduct = rec.order.TotalPriceProduct - var TotalPriceProduct = rec.order.TotalPriceProductstr
- index = index + 1 - index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center") table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")

View File

@@ -54,6 +54,9 @@ const orderSchema = new Schema({
type: Number, type: Number,
default: 0, default: 0,
}, },
TotalPriceProductstr: {
type: String,
},
TotalPriceProductCalc: { TotalPriceProductCalc: {
type: Number, type: Number,
default: 0, default: 0,
@@ -362,6 +365,7 @@ module.exports.updateTotals = function (order) {
order.TotalPriceProductCalc += mypricecalc; order.TotalPriceProductCalc += mypricecalc;
order.TotalPriceProduct += mypricecalc; order.TotalPriceProduct += mypricecalc;
order.TotalPriceProductstr = parseFloat(order.TotalPriceProduct.toFixed(2));
return order; return order;

View File

@@ -919,10 +919,12 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
if (ord.order.quantitypreordered > 0) if (ord.order.quantitypreordered > 0)
qtynum += ord.order.quantitypreordered; qtynum += ord.order.quantitypreordered;
// if (ord.order.product.productInfo.weight) if (ord.order.product.productInfo.sfuso && ord.order.product.productInfo.weight)
// qtynum *= ord.order.product.productInfo.weight; qtyrisult = qtynum * ord.order.product.productInfo.weight;
else
qtyrisult = qtynum + ' x ' + ord.order.product.productInfo.weight;
qtystr += qtynum + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true); qtystr += qtyrisult + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true);
if (ord.order.quantitypreordered > 0) if (ord.order.quantitypreordered > 0)
qtystr += ' Pre-Ordinati'; qtystr += ' Pre-Ordinati';

View File

@@ -58,6 +58,9 @@ const productInfoSchema = new Schema({
type: Number, type: Number,
default: 0, default: 0,
}, },
sfuso: { // serve se moltiplicare le qta (es: 12 kg) oppure fare (2 x 20 ml)
type: Boolean
},
vegan: { vegan: {
type: Boolean type: Boolean
}, },

View File

@@ -254,6 +254,7 @@ class Cart {
order.TotalPriceProductCalc += mypricecalc; order.TotalPriceProductCalc += mypricecalc;
if (updatecalcprice) { if (updatecalcprice) {
order.TotalPriceProduct += mypricecalc; order.TotalPriceProduct += mypricecalc;
order.TotalPriceProductstr = parseFloat(order.TotalPriceProduct.toFixed(2));
} }
// Qui lo calcolo sempre, anche se lo cambio manualmente // Qui lo calcolo sempre, anche se lo cambio manualmente

View File

@@ -17,6 +17,7 @@ module.exports = {
{_id: 15, descr: 'Sport'}, {_id: 15, descr: 'Sport'},
{_id: 16, descr: 'Un po\' di Tutto'}, {_id: 16, descr: 'Un po\' di Tutto'},
{_id: 17, descr: 'Attrezzature'}, {_id: 17, descr: 'Attrezzature'},
{_id: 18, descr: 'Animali'},
], ],
}; };

View File

@@ -151,8 +151,11 @@ function extractArrayDataFromCSV(idapp, rec) {
arrcampi_product = getValoriAndIndice_Product(null); arrcampi_product = getValoriAndIndice_Product(null);
for (const campoobj of arrcampi_productInfo) { for (const campoobj of arrcampi_productInfo) {
if (rec.hasOwnProperty(campoobj)) if (rec.hasOwnProperty(campoobj)) {
productInfo[campoobj] = rec[campoobj]; let myval = rec[campoobj];
productInfo[campoobj] = myval === 'TRUE' ? true : (myval === 'FALSE' ? false : myval);
}
} }
for (const campoobj of arrcampi_product) { for (const campoobj of arrcampi_product) {
@@ -375,9 +378,9 @@ router.post('/import', authenticate, async (req, res) => {
} }
} else if (cmd === shared_consts.Cmd.PRODUCTS_V2) { } else if (cmd === shared_consts.Cmd.PRODUCTS_V2) {
let mydata = `[${data.arrdata}]`;
let arrrec = JSON.parse(`[${data.arrdata}]`); let cleanmydata = mydata.replace(/\n/g, '');
let arrrec = JSON.parse(cleanmydata);
let updated = 0; let updated = 0;
let imported = 0; let imported = 0;
let errors = 0; let errors = 0;

View File

@@ -712,7 +712,7 @@ const MyTelegramBot = {
arrTeleg = appTelegram; arrTeleg = appTelegram;
} }
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
arrTeleg = appTelegram_DEVELOP; arrTeleg = MyTelegramBot.getAppTelegramDevelop();
} else if (process.env.NODE_ENV === 'test') { } else if (process.env.NODE_ENV === 'test') {
arrTeleg = MyTelegramBot.getAppTelegramTest(); arrTeleg = MyTelegramBot.getAppTelegramTest();
} else { } else {
@@ -736,6 +736,15 @@ const MyTelegramBot = {
}, },
getAppTelegramDevelop: function () {
if (process.env.appTelegram_TEST) {
return JSON.parse(process.env.appTelegram_TEST);
} else {
return appTelegram_DEVELOP;
}
},
local_sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text, local_sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text,
message_id, chat_id, ripr_menuPrec, message_id, chat_id, ripr_menuPrec,
MyForm = null) { MyForm = null) {

View File

@@ -980,6 +980,7 @@ module.exports = {
'unit_lordo', 'unit_lordo',
'size', 'size',
'vegan', 'vegan',
'sfuso',
'img', 'img',
'link', 'link',
'ingredienti', 'ingredienti',