- Categorie
- ProductInfo
This commit is contained in:
@@ -154,10 +154,24 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
as: 'product'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product.productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product.productInfo',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'producers',
|
||||
localField: 'idProducer',
|
||||
localField: 'product.idProducer',
|
||||
foreignField: '_id',
|
||||
as: 'producer'
|
||||
}
|
||||
@@ -165,7 +179,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'idProvider',
|
||||
localField: 'product.idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
@@ -178,15 +192,24 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
'gasordine.active': true
|
||||
$or: [
|
||||
{ 'gasordine': { $exists: false } },
|
||||
{ 'gasordine.active': true }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
localField: 'idScontisticas',
|
||||
localField: 'product.idScontisticas',
|
||||
foreignField: '_id',
|
||||
as: 'scontistica'
|
||||
}
|
||||
@@ -209,12 +232,6 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
@@ -270,9 +287,9 @@ module.exports.updateTotals = function (order) {
|
||||
|
||||
try {
|
||||
if (!order) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let mypricecalc = 0;
|
||||
order.TotalPriceProduct = 0;
|
||||
|
||||
@@ -342,10 +359,30 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'product'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'product.productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product.productInfo',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'producers',
|
||||
localField: 'idProducer',
|
||||
localField: 'product.idProducer',
|
||||
foreignField: '_id',
|
||||
as: 'producer'
|
||||
}
|
||||
@@ -361,7 +398,7 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'idProvider',
|
||||
localField: 'product.idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
@@ -374,25 +411,28 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
'gasordine.active': true
|
||||
$or: [
|
||||
{ 'gasordine': { $exists: false } },
|
||||
{ 'gasordine.active': true }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
localField: 'idScontisticas',
|
||||
localField: 'product.idScontisticas',
|
||||
foreignField: '_id',
|
||||
as: 'scontisticas'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
@@ -411,12 +451,6 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'orders',
|
||||
|
||||
Reference in New Issue
Block a user