- Uscita PRIMA VERSIONE PiuCheBuono.app
This commit is contained in:
@@ -37,8 +37,12 @@ html
|
||||
p!= mioheader
|
||||
else
|
||||
p Ciao #{username},
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_makeorder
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_makeorder
|
||||
|
||||
- var miomakeorder = mystorehouse.email_html_makeorder
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
else
|
||||
@@ -46,67 +50,67 @@ html
|
||||
p Il pagamento, se non diversamente comunicato, potrai farlo direttamente in sede.
|
||||
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.price
|
||||
- var after_price = rec.order.after_price
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
|
||||
- var qty = rec.order.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- index = index + 1
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.price
|
||||
- var after_price = rec.order.after_price
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
|
||||
- var qty = rec.order.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
|
||||
@@ -40,14 +40,17 @@ html
|
||||
else
|
||||
p Ciao #{name},
|
||||
|
||||
- var miordconfirmed = mystorehouse.email_html_order_confirmed
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miordconfirmed = mystorehouse.email_html_GAS_order_confirmed
|
||||
else
|
||||
- var miordconfirmed = mystorehouse.email_html_order_confirmed
|
||||
|
||||
if (miordconfirmed)
|
||||
p!= miordconfirmed
|
||||
else
|
||||
p Puoi pertanto venire a ritirarli direttamente in sede, negli orari che ti sono stati indicati.
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
|
||||
@@ -28,9 +28,35 @@ html
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
p Ciao #{name},
|
||||
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
else
|
||||
p Ciao #{username},
|
||||
|
||||
p L'ordine n. #{ordernumber} è stato Consegnato correttamente !
|
||||
p Grazie Mille per aver contribuito a far crescere la Comunità
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_order_consegnato
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_order_consegnato
|
||||
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
27
filelog.txt
27
filelog.txt
@@ -105,3 +105,30 @@ Dom 17/12 ORE 16:19: USER [admin]: il mio profilo
|
||||
Dom 17/12 ORE 16:19: USER [admin]: prova
|
||||
|
||||
Dom 17/12 ORE 16:19: USER [admin]: link da condividere
|
||||
|
||||
Sab 30/12 ORE 20:06: USER [admin]: gruppo di acquisto per le arance:
|
||||
|
||||
produttore:
|
||||
🍊sicilia frutta express (catania)
|
||||
|
||||
la piccola azienda a conduzione familiare di giovanni si trova in provincia di catania (sicilia), i frutti vengono prodotti rispettando i principi della biodinamica infatti non viene utilizzato nulla di chimico (niente irrorazioni) e la concimazione avviene tramite concimi naturali (letame).
|
||||
|
||||
⚠️ offerta sconto valida solo fino al 3 gennaio 2024, raggiungendo 100 kg totali di ordini di arance:
|
||||
i prezzi sono compresi di spese di spedizione e di gestione.
|
||||
|
||||
🍊 arance tarocco spremuta: 1,20 € / kg
|
||||
|
||||
🥑 avocado: 7,80 € / kg
|
||||
|
||||
🍋 limoni: 2,40 € / kg
|
||||
|
||||
👉🏻 entra sul gruppo telegram piu che buono
|
||||
|
||||
per le prenotazioni potete registratevi sul nuovo sito:
|
||||
👉🏻 piu che buono - gas e bottega (piuchebuono.app)
|
||||
|
||||
come funziona:
|
||||
- registratevi su piuchebuono.app, verificate la email.
|
||||
- accedete e poi cliccate su "gruppo di acquisto".
|
||||
- cliccate sul carrello verde 🛒 per aggiungere i kg che desiderate.
|
||||
- per finire: cliccare su "procedi all'ordine" e confermate.
|
||||
|
||||
@@ -54,18 +54,11 @@ const orderSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
evaso: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockQty)
|
||||
confermato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockQty)
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_evaso: {
|
||||
type: Date
|
||||
},
|
||||
consegnato: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_consegnato: {
|
||||
date_confermato: {
|
||||
type: Date
|
||||
},
|
||||
pagato: {
|
||||
@@ -75,13 +68,6 @@ const orderSchema = new Schema({
|
||||
date_pagato: {
|
||||
type: Date
|
||||
},
|
||||
spedito: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_spedito: {
|
||||
type: Date
|
||||
},
|
||||
consegnato: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -89,6 +75,13 @@ const orderSchema = new Schema({
|
||||
date_consegnato: {
|
||||
type: Date
|
||||
},
|
||||
spedito: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_spedito: {
|
||||
type: Date
|
||||
},
|
||||
ricevuto: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -572,7 +565,7 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
$subtract: ["$product.stockQty", "$product.QuantitaOrdinateInAttesa"],
|
||||
},
|
||||
'product.bookableAvailableQty': {
|
||||
$subtract: ["$product.bookableQty", "$product.QuantitaPrenotateInAttesa"],
|
||||
$subtract: ["$product.maxbookableGASQty", "$product.QuantitaPrenotateInAttesa"],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,11 +39,11 @@ const OrdersCartSchema = new Schema({
|
||||
type: Number,
|
||||
Default: 0,
|
||||
},
|
||||
evaso: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockBloccatiQty)
|
||||
confermato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockBloccatiQty)
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_evaso: {
|
||||
date_confermato: {
|
||||
type: Date
|
||||
},
|
||||
pagato: {
|
||||
@@ -439,11 +439,11 @@ module.exports.setConsegnatoById = async function (value, myOrderCart) {
|
||||
|
||||
}
|
||||
|
||||
module.exports.setEvasoById = async function (value, myOrderCart) {
|
||||
module.exports.setConfermatoById = async function (value, myOrderCart) {
|
||||
|
||||
let objtoset = {
|
||||
evaso: value,
|
||||
date_evaso: new Date(),
|
||||
confermato: value,
|
||||
date_confermato: new Date(),
|
||||
};
|
||||
|
||||
return await OrdersCart.setFieldInOrdersById(objtoset, myOrderCart);
|
||||
@@ -469,7 +469,7 @@ module.exports.createOrdersCart = async function (newOrdersCart) {
|
||||
return await newOrdersCart.save()
|
||||
}
|
||||
|
||||
module.exports.updateStockQtaDalMagazzino = async function (idorderscart) {
|
||||
module.exports.updateStockQtaDalMagazzinoOrdineConfermato = async function (idorderscart) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -479,19 +479,21 @@ module.exports.updateStockQtaDalMagazzino = async function (idorderscart) {
|
||||
for (const idkey in myorderscart.items) {
|
||||
let order = myorderscart.items[idkey].order;
|
||||
|
||||
if (!order.evaso) {
|
||||
if (!order.confermato) { // Se ancora non è stato confermato:
|
||||
let update = {
|
||||
$inc: {
|
||||
stockQty: -order.quantity,
|
||||
stockBloccatiQty: order.quantity
|
||||
stockBloccatiQty: order.quantity,
|
||||
bookedQtyConfirmed: order.quantity,
|
||||
}
|
||||
};
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
|
||||
update = {
|
||||
$inc: {
|
||||
bookableQty: -order.quantitypreordered,
|
||||
bookableBloccatiQty: order.quantitypreordered
|
||||
maxbookableGASQty: -order.quantitypreordered,
|
||||
bookableGASBloccatiQty: order.quantitypreordered,
|
||||
bookedGASQtyOrdered: order.quantitypreordered,
|
||||
}
|
||||
};
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
@@ -504,7 +506,40 @@ module.exports.updateStockQtaDalMagazzino = async function (idorderscart) {
|
||||
}
|
||||
|
||||
}
|
||||
module.exports.updateStockBloccatiQtaDalMagazzino = async function (idorderscart) {
|
||||
module.exports.updateMagazzinoOrdineInLavorazione = 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;
|
||||
|
||||
if (!order.confermato) { // Se ancora non è stato confermato:
|
||||
let update = {
|
||||
$inc: {
|
||||
bookedQtyConfirmed: order.quantity,
|
||||
}
|
||||
};
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
|
||||
update = {
|
||||
$inc: {
|
||||
bookedGASQtyOrdered: order.quantitypreordered,
|
||||
}
|
||||
};
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
}
|
||||
module.exports.updateStockBloccatiQtaDalMagazzinoOrdineConsegnato = async function (idorderscart) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -523,7 +558,7 @@ module.exports.updateStockBloccatiQtaDalMagazzino = async function (idorderscart
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
update = {
|
||||
$inc: {
|
||||
bookableBloccatiQty: -order.quantitypreordered
|
||||
bookableGASBloccatiQty: -order.quantitypreordered
|
||||
}
|
||||
};
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
@@ -537,6 +572,67 @@ module.exports.updateStockBloccatiQtaDalMagazzino = async function (idorderscart
|
||||
|
||||
}
|
||||
|
||||
module.exports.updateStockQtaPerCancellazioneOrdine = 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;
|
||||
let update = {};
|
||||
|
||||
let fieldstoUpdate = {};
|
||||
|
||||
if (order.consegnato) {
|
||||
// Se l'ordine era stato già Consegnato, allora non fare niente !
|
||||
return false;
|
||||
} else {
|
||||
|
||||
if (order.confermato) { // Se l'ordine era stato confermato, allora rimetti le Qta in Magazzino
|
||||
fieldstoUpdate = {
|
||||
...fieldstoUpdate,
|
||||
stockQty: order.quantity,
|
||||
stockBloccatiQty: -order.quantity,
|
||||
bookedQtyConfirmed: -order.quantity,
|
||||
}
|
||||
}
|
||||
|
||||
update = {
|
||||
$inc: fieldstoUpdate,
|
||||
};
|
||||
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
// --------------
|
||||
|
||||
fieldstoUpdate = {};
|
||||
|
||||
if (order.confermato) { // Se l'ordine era stato confermato, allora rimetti le Qta in Magazzino
|
||||
fieldstoUpdate = {
|
||||
...fieldstoUpdate,
|
||||
maxbookableGASQty: order.quantitypreordered,
|
||||
bookableGASBloccatiQty: -order.quantitypreordered,
|
||||
bookedGASQtyOrdered: -order.quantitypreordered,
|
||||
}
|
||||
}
|
||||
|
||||
update = {
|
||||
$inc: fieldstoUpdate,
|
||||
};
|
||||
|
||||
await Product.findOneAndUpdate({ _id: order.idProduct }, update, { new: false });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports.updateCmd = async function (ordersCart, status, value) {
|
||||
|
||||
|
||||
@@ -547,26 +643,40 @@ module.exports.updateCmd = async function (ordersCart, status, value) {
|
||||
if (!!myOrderCart) {
|
||||
|
||||
const id = myOrderCart._id;
|
||||
if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
if (status === shared_consts.OrderStatus.CHECKOUT_SENT) {
|
||||
|
||||
if (value) {
|
||||
await OrdersCart.updateMagazzinoOrdineInLavorazione(id);
|
||||
}
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.ORDER_CONFIRMED) {
|
||||
|
||||
// Aggiorna anche il Magazzino, togliendo le quantità in Stock e aggiungendole su quelle bloccate
|
||||
if (value) {
|
||||
await OrdersCart.updateStockQtaDalMagazzino(id);
|
||||
await OrdersCart.updateStockQtaDalMagazzinoOrdineConfermato(id);
|
||||
}
|
||||
ris = await OrdersCart.setEvasoById(value, myOrderCart);
|
||||
ris = await OrdersCart.setConfermatoById(value, myOrderCart);
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.PAYED) {
|
||||
|
||||
ris = await OrdersCart.setPagatoById(value, myOrderCart);
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.DELIVERED) { // Consegnato
|
||||
if (value) {
|
||||
await OrdersCart.updateStockBloccatiQtaDalMagazzino(id);
|
||||
await OrdersCart.updateStockBloccatiQtaDalMagazzinoOrdineConsegnato(id);
|
||||
}
|
||||
ris = await OrdersCart.setConsegnatoById(value, myOrderCart);
|
||||
} else if (status === shared_consts.OrderStatus.SHIPPED) {
|
||||
|
||||
ris = await OrdersCart.setSpeditoById(value, myOrderCart);
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.RECEIVED) {
|
||||
ris = await OrdersCart.setRicevutoById(value, myOrderCart);
|
||||
} else if (status === shared_consts.OrderStatus.CANCELED) {
|
||||
await OrdersCart.updateStockQtaPerCancellazioneOrdine(id)
|
||||
|
||||
} else if (status === shared_consts.OrderStatus.DELETE_REALLY) {
|
||||
await OrdersCart.updateStockQtaPerCancellazioneOrdine(id)
|
||||
ris = await OrdersCart.deleteReally(value, myOrderCart);
|
||||
}
|
||||
|
||||
@@ -574,7 +684,6 @@ module.exports.updateCmd = async function (ordersCart, status, value) {
|
||||
|
||||
await OrdersCart.setFieldInOrdersById({ status }, myOrderCart);
|
||||
|
||||
|
||||
myOrderCart = await OrdersCart.getOrdersCartById(ordersCart._id)
|
||||
}
|
||||
// myOrderCart = await OrdersCart.findOne({ _id: idorderscart });
|
||||
|
||||
@@ -71,26 +71,42 @@ const productSchema = new Schema({
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
maxBookableQty: { // quantità massima Pre-ordinabile (singolarmente)
|
||||
maxBookableSinglePersQty: { // quantità massima Pre-ordinabile (singolarmente)
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
||||
stockQty: { // in magazzino
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
bookableQty: { // Quantità prenotabili
|
||||
stockBloccatiQty: { // Prenotati Bloccati
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
stockBloccatiQty: { // Prenotati
|
||||
bookedQtyConfirmed: { // Quantità Prenotate Confermate Totali
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
bookableBloccatiQty: { // Quantità Prenotati e prenotabili
|
||||
|
||||
// GAS:
|
||||
qtyToReachForGas: { // Quantità minima da raggiungere per fare l'ordine GAS
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
maxbookableGASQty: { // Quantità massima (ancora disponibile) Ordine GAS prenotabile (Complessivamente tra tutti gli ordini)
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
bookedGASQtyOrdered: { // Quantità Ordine GAS Prenotate Confermate Totali
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
bookableGASBloccatiQty: { // Quantità Prenotate Bloccate GAS
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
||||
quantityLow: { //Soglia disponibilità bassa
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -114,6 +130,9 @@ const productSchema = new Schema({
|
||||
dateAvailableFrom: {
|
||||
type: Date
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
producer_name: {
|
||||
type: String,
|
||||
},
|
||||
@@ -421,7 +440,7 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
||||
$subtract: ["$stockQty", "$QuantitaOrdinateInAttesa"],
|
||||
},
|
||||
bookableAvailableQty: {
|
||||
$subtract: ["$bookableQty", "$QuantitaPrenotateInAttesa"],
|
||||
$subtract: ["$maxbookableGASQty", "$QuantitaPrenotateInAttesa"],
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -503,16 +522,16 @@ module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports.convertAfterImport = async function (idapp, dataObjects) {
|
||||
module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
|
||||
|
||||
const arrprod = await Product.find({ idapp }).lean();
|
||||
for (const prod of arrprod) {
|
||||
await this.singlerecconvert_AfterImport(prod);
|
||||
await this.singlerecconvert_AfterImport_AndSave(prod);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuovo) {
|
||||
module.exports.singlerecconvert_AfterImport_AndSave = async function (idapp, prod, isnuovo) {
|
||||
|
||||
let setta = false;
|
||||
|
||||
@@ -524,9 +543,13 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
if (isnuovo) {
|
||||
objtoset = {
|
||||
idapp,
|
||||
minBuyQty: 1,
|
||||
minStepQty: 1,
|
||||
maxBookableQty: 0,
|
||||
// minBuyQty: 1,
|
||||
// minStepQty: 1,
|
||||
maxBookableSinglePersQty: 0,
|
||||
bookedGASQtyOrdered: 0,
|
||||
bookableGASBloccatiQty: 0,
|
||||
// qtyToReachForGas: 0,
|
||||
// maxbookableGASQty: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,6 +591,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (prod.provider_name) {
|
||||
// Cerca il produttore
|
||||
let recprovider = await Provider.findOne({ idapp, name: prod.provider_name }).lean();
|
||||
|
||||
@@ -50,7 +50,8 @@ const productInfoSchema = new Schema({
|
||||
type: Boolean
|
||||
},
|
||||
unit: {
|
||||
type: Number
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
|
||||
@@ -189,10 +189,10 @@ reactionSchema.statics.updateReactionsCounts = async function () {
|
||||
|
||||
risupdate = await mytable.updateOne({ _id: rec._id }, {
|
||||
$set: {
|
||||
numseen: ris.myreact.numseen | 0,
|
||||
numfav: ris.myreact.numfav | 0,
|
||||
numbook: ris.myreact.numbook | 0,
|
||||
numattend: ris.myreact.numattend | 0,
|
||||
numseen: ris.myreact.numseen ?? 0,
|
||||
numfav: ris.myreact.numfav ?? 0,
|
||||
numbook: ris.myreact.numbook ?? 0,
|
||||
numattend: ris.myreact.numattend ?? 0,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,6 +60,18 @@ const storehouseSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
email_html_GAS_makeorder: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
email_html_GAS_order_confirmed: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
email_html_GAS_order_consegnato: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
var Storehouse = module.exports = mongoose.model('Storehouse', storehouseSchema);
|
||||
|
||||
@@ -73,7 +73,7 @@ class Cart {
|
||||
let step = stepmin;
|
||||
if (this.isAvailableByOrder(myitem.order)) {
|
||||
if (myitem.order.quantity === 0)
|
||||
step = myitem.order.product.minBuyQty | stepmin
|
||||
step = myitem.order.product.minBuyQty ?? stepmin
|
||||
else if (myitem.order.quantity >= 10)
|
||||
step = stepmin < 2 ? 2 : stepmin
|
||||
else if (myitem.order.quantity >= 20)
|
||||
@@ -82,7 +82,7 @@ class Cart {
|
||||
myitem.order.quantity += step;
|
||||
} else {
|
||||
if (myitem.order.quantitypreordered === 0)
|
||||
step = myitem.order.product.minBuyQty | stepmin
|
||||
step = myitem.order.product.minBuyQty ?? stepmin
|
||||
else if (myitem.order.quantitypreordered >= 10)
|
||||
step = stepmin < 2 ? 2 : stepmin
|
||||
else if (myitem.order.quantitypreordered >= 20)
|
||||
|
||||
@@ -74,13 +74,15 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
if (product.cat_name) {
|
||||
arrcat = product.cat_name.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
// Cerca la Categoria
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
// Non esiste questo produttore, quindi lo creo !
|
||||
reccateg = new CatProd({ idapp, name: mycat });
|
||||
reccateg = new CatProd({ idapp, name: mycatstr });
|
||||
ris = await reccateg.save();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
}
|
||||
|
||||
if (reccateg) {
|
||||
@@ -125,9 +127,10 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
if (!options.aggiornaStockQty && esisteindb) {
|
||||
delete product.stockQty;
|
||||
delete product.bookableQty;
|
||||
delete product.maxbookableGASQty;
|
||||
}
|
||||
|
||||
// AGGIORNA PRODUCT
|
||||
let risrec = await Product.findOneAndUpdate({ idProductInfo: product.idProductInfo }, { $set: product }, { new: true, upsert: true });
|
||||
|
||||
let recnew = await Product.findOne({ idProductInfo: product.idProductInfo }).lean();
|
||||
@@ -150,7 +153,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
errors++;
|
||||
}
|
||||
|
||||
await Product.singlerecconvert_AfterImport(idapp, recnew, isnuovo);
|
||||
await Product.singlerecconvert_AfterImport_AndSave(idapp, recnew, isnuovo);
|
||||
} else {
|
||||
console.error('Error ProductInfo: ', product.code);
|
||||
errors++;
|
||||
@@ -162,7 +165,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
/*return await Product.insertMany(dataObjects, { ordered: false })
|
||||
.then((ris) => {
|
||||
|
||||
Product.convertAfterImport(idapp, dataObjects).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp, dataObjects).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
|
||||
@@ -170,7 +173,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
})
|
||||
.catch((errors) => {
|
||||
console.error(errors);
|
||||
Product.convertAfterImport(idapp).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
});*/
|
||||
|
||||
@@ -290,7 +290,7 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
else {
|
||||
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
|
||||
const myris = ris;
|
||||
// Cancella il Cart appena salvato in OrdersCart
|
||||
@@ -302,6 +302,8 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
.then((orders) => {
|
||||
if (!!orders) {
|
||||
|
||||
OrdersCart.updateCmd(orders[0], status, true);
|
||||
|
||||
// Invia la email dell'Ordine
|
||||
sendemail.sendEmail_OrderProduct(user.lang, idapp, orders[0], user)
|
||||
.then(async (ris) => {
|
||||
@@ -384,7 +386,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
}
|
||||
|
||||
if (ordertype !== '') {
|
||||
sendemail.sendEmail_Order(user.lang, idapp, orderCart, user, ordertype)
|
||||
sendemail.sendEmail_Order(user.lang, idapp, orderCart, user, ordertype, status)
|
||||
.then((ris) => {
|
||||
|
||||
})
|
||||
|
||||
@@ -36,6 +36,7 @@ const { authenticate, authenticate_noerror } = require('../middleware/authentica
|
||||
const Cart = require('../models/cart');
|
||||
const CartClass = require('../modules/Cart');
|
||||
const Product = require('../models/product');
|
||||
const CatProd = require('../models/catprod');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const Order = require('../models/order');
|
||||
const OrdersCart = require('../models/orderscart');
|
||||
@@ -1311,6 +1312,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await Product.collection.drop();
|
||||
ris = await ProductInfo.collection.drop();
|
||||
|
||||
} else if (mydata.dbop === 'dropCatProd') {
|
||||
|
||||
await CatProd.collection.drop();
|
||||
|
||||
} else if (mydata.dbop === 'dropAllOrders') {
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user