Seleziona l'ordine GAS e compare sulla email
This commit is contained in:
@@ -44,6 +44,7 @@ html
|
||||
- var img = product.order.product.img
|
||||
- var price = product.order.price
|
||||
- var after_price = product.order.after_price
|
||||
- var gasordine = product.order.gasordine.name
|
||||
- var qty = product.order.quantity
|
||||
- var qtypreordered = product.order.quantitypreordered
|
||||
- index = index + 1
|
||||
@@ -61,6 +62,10 @@ html
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordereded > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
|
||||
@@ -44,6 +44,7 @@ html
|
||||
- var img = product.order.product.img
|
||||
- var price = product.order.product.price
|
||||
- var after_price = product.order.product.after_price
|
||||
- var gasordine = product.order.gasordine.name
|
||||
- var qty = product.order.product.quantity
|
||||
- var qtypreordered = product.order.quantitypreordered
|
||||
- index = index + 1
|
||||
@@ -61,6 +62,10 @@ html
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordereded > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
|
||||
@@ -178,6 +178,11 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
'gasordine.active': true
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
@@ -369,6 +374,11 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
'gasordine.active': true
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
|
||||
@@ -100,6 +100,7 @@ const productSchema = new Schema({
|
||||
minBuyQty: { // quantità minima acquistabile
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
stockQty: { // in magazzino
|
||||
type: Number,
|
||||
@@ -175,7 +176,7 @@ module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
@@ -251,6 +252,34 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
||||
as: 'gasordines'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordines',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ 'gasordines.active': true }, // Include documents where gasordines.active is true
|
||||
{ 'gasordines': { $exists: false } } // Include documents where gasordines array doesn't exist
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$_id',
|
||||
gasordines: { $push: '$gasordines' },
|
||||
originalFields: { $first: '$$ROOT' } // Preserve all existing fields
|
||||
}
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: ['$originalFields', { gasordines: '$gasordines' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
@@ -438,10 +467,10 @@ module.exports.getProductByID = function (id, callback) {
|
||||
}
|
||||
|
||||
module.exports.updateProductInOrder = async function (order) {
|
||||
|
||||
|
||||
if (order.product)
|
||||
order.product = await Product.getProductById(order.product._id);
|
||||
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
@@ -467,6 +496,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod) {
|
||||
let objtoset = {
|
||||
idapp,
|
||||
img: 'upload/products/' + prod.code + '.jpg',
|
||||
minBuyQty: 1,
|
||||
}
|
||||
|
||||
if (prod.producer_name) {
|
||||
@@ -552,5 +582,5 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod) {
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -58,10 +58,25 @@ class Cart {
|
||||
async addqty(itemorder) {
|
||||
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
||||
if (!!myitem) {
|
||||
let step = 1;
|
||||
if (this.isAvailableByOrder(myitem.order)) {
|
||||
myitem.order.quantity += 1;
|
||||
if (myitem.order.quantity === 0)
|
||||
step = myitem.order.minBuyQty
|
||||
else if (myitem.order.quantity >= 10)
|
||||
step = 2
|
||||
else if (myitem.order.quantity >= 20)
|
||||
step = 5
|
||||
|
||||
myitem.order.quantity += step;
|
||||
} else {
|
||||
myitem.order.quantitypreordered += myitem.order.product.minBuyQty;
|
||||
if (myitem.order.quantitypreordered === 0)
|
||||
step = myitem.order.minBuyQty
|
||||
else if (myitem.order.quantitypreordered >= 10)
|
||||
step = 2
|
||||
else if (myitem.order.quantitypreordered >= 20)
|
||||
step = 5
|
||||
|
||||
myitem.order.quantitypreordered += step;
|
||||
}
|
||||
|
||||
this.updatetotals();
|
||||
@@ -75,7 +90,7 @@ class Cart {
|
||||
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
||||
if (!!myitem) {
|
||||
if (myitem.order.quantitypreordered > 0) {
|
||||
myitem.order.quantitypreordered -= myitem.order.product.minBuyQty;
|
||||
myitem.order.quantitypreordered -= myitem.order.product.minBuyQty | 1;
|
||||
} else {
|
||||
if (myitem.order.quantity > 0) {
|
||||
myitem.order.quantity--;
|
||||
|
||||
Reference in New Issue
Block a user