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 img = product.order.product.img
|
||||||
- var price = product.order.price
|
- var price = product.order.price
|
||||||
- var after_price = product.order.after_price
|
- var after_price = product.order.after_price
|
||||||
|
- var gasordine = product.order.gasordine.name
|
||||||
- var qty = product.order.quantity
|
- var qty = product.order.quantity
|
||||||
- var qtypreordered = product.order.quantitypreordered
|
- var qtypreordered = product.order.quantitypreordered
|
||||||
- index = index + 1
|
- index = index + 1
|
||||||
@@ -61,6 +62,10 @@ html
|
|||||||
td(class="column", valign="top")
|
td(class="column", valign="top")
|
||||||
|
|
||||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||||
|
if (qtypreordereded > 0)
|
||||||
|
tr
|
||||||
|
td(class="sectionContent", valign="top")
|
||||||
|
p Gas Ordine: #{gasordine}
|
||||||
tr
|
tr
|
||||||
td(class="sectionContentTitle boldhigh", valign="top")
|
td(class="sectionContentTitle boldhigh", valign="top")
|
||||||
p #{descr}
|
p #{descr}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ html
|
|||||||
- var img = product.order.product.img
|
- var img = product.order.product.img
|
||||||
- var price = product.order.product.price
|
- var price = product.order.product.price
|
||||||
- var after_price = product.order.product.after_price
|
- var after_price = product.order.product.after_price
|
||||||
|
- var gasordine = product.order.gasordine.name
|
||||||
- var qty = product.order.product.quantity
|
- var qty = product.order.product.quantity
|
||||||
- var qtypreordered = product.order.quantitypreordered
|
- var qtypreordered = product.order.quantitypreordered
|
||||||
- index = index + 1
|
- index = index + 1
|
||||||
@@ -61,6 +62,10 @@ html
|
|||||||
td(class="column", valign="top")
|
td(class="column", valign="top")
|
||||||
|
|
||||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||||
|
if (qtypreordereded > 0)
|
||||||
|
tr
|
||||||
|
td(class="sectionContent", valign="top")
|
||||||
|
p Gas Ordine: #{gasordine}
|
||||||
tr
|
tr
|
||||||
td(class="sectionContentTitle boldhigh", valign="top")
|
td(class="sectionContentTitle boldhigh", valign="top")
|
||||||
p #{descr}
|
p #{descr}
|
||||||
|
|||||||
@@ -178,6 +178,11 @@ module.exports.findAllIdApp = async function (idapp) {
|
|||||||
as: 'gasordine'
|
as: 'gasordine'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
'gasordine.active': true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'scontisticas',
|
from: 'scontisticas',
|
||||||
@@ -369,6 +374,11 @@ module.exports.getTotalOrderById = async function (id) {
|
|||||||
as: 'gasordine'
|
as: 'gasordine'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
'gasordine.active': true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'scontisticas',
|
from: 'scontisticas',
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ const productSchema = new Schema({
|
|||||||
minBuyQty: { // quantità minima acquistabile
|
minBuyQty: { // quantità minima acquistabile
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1,
|
default: 1,
|
||||||
|
required: true,
|
||||||
},
|
},
|
||||||
stockQty: { // in magazzino
|
stockQty: { // in magazzino
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -251,6 +252,34 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
|||||||
as: 'gasordines'
|
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: {
|
$unwind: {
|
||||||
path: '$producer',
|
path: '$producer',
|
||||||
@@ -467,6 +496,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod) {
|
|||||||
let objtoset = {
|
let objtoset = {
|
||||||
idapp,
|
idapp,
|
||||||
img: 'upload/products/' + prod.code + '.jpg',
|
img: 'upload/products/' + prod.code + '.jpg',
|
||||||
|
minBuyQty: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prod.producer_name) {
|
if (prod.producer_name) {
|
||||||
|
|||||||
@@ -58,10 +58,25 @@ class Cart {
|
|||||||
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 step = 1;
|
||||||
if (this.isAvailableByOrder(myitem.order)) {
|
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 {
|
} 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();
|
this.updatetotals();
|
||||||
@@ -75,7 +90,7 @@ class Cart {
|
|||||||
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) {
|
||||||
if (myitem.order.quantitypreordered > 0) {
|
if (myitem.order.quantitypreordered > 0) {
|
||||||
myitem.order.quantitypreordered -= myitem.order.product.minBuyQty;
|
myitem.order.quantitypreordered -= myitem.order.product.minBuyQty | 1;
|
||||||
} else {
|
} else {
|
||||||
if (myitem.order.quantity > 0) {
|
if (myitem.order.quantity > 0) {
|
||||||
myitem.order.quantity--;
|
myitem.order.quantity--;
|
||||||
|
|||||||
Reference in New Issue
Block a user