Scontistica- Parte 1
This commit is contained in:
@@ -157,6 +157,20 @@ module.exports.findAllIdApp = async function (idapp) {
|
|||||||
as: 'provider'
|
as: 'provider'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'scontisticas',
|
||||||
|
localField: 'idScontisticas',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'scontistica'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$scontistica',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{ $unwind: '$product' },
|
{ $unwind: '$product' },
|
||||||
{ $unwind: '$producer' },
|
{ $unwind: '$producer' },
|
||||||
{ $unwind: '$provider' },
|
{ $unwind: '$provider' },
|
||||||
@@ -244,6 +258,20 @@ module.exports.getTotalOrderById = async function (id) {
|
|||||||
as: 'provider'
|
as: 'provider'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'scontisticas',
|
||||||
|
localField: 'idScontisticas',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'scontistica'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$scontistica',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{ $unwind: '$product' },
|
{ $unwind: '$product' },
|
||||||
{ $unwind: '$producer' },
|
{ $unwind: '$producer' },
|
||||||
{ $unwind: '$storehouse' },
|
{ $unwind: '$storehouse' },
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const tools = require('../tools/general');
|
|||||||
const Producer = require('../models/producer');
|
const Producer = require('../models/producer');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Scontistica = require('../models/scontistica');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
@@ -33,6 +34,9 @@ const productSchema = new Schema({
|
|||||||
idStorehouses: [
|
idStorehouses: [
|
||||||
{ type: Schema.Types.ObjectId, ref: 'Storehouse' }
|
{ type: Schema.Types.ObjectId, ref: 'Storehouse' }
|
||||||
],
|
],
|
||||||
|
idScontisticas: [
|
||||||
|
{ type: Schema.Types.ObjectId, ref: 'Scontistica' }
|
||||||
|
],
|
||||||
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
||||||
code: {
|
code: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -214,7 +218,12 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
|||||||
as: 'producer'
|
as: 'producer'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ $unwind: '$producer' },
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$producer',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'providers',
|
from: 'providers',
|
||||||
@@ -223,7 +232,26 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
|||||||
as: 'provider'
|
as: 'provider'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ $unwind: '$provider' },
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$provider',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'scontisticas',
|
||||||
|
localField: 'idScontisticas',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'scontistica'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$scontistica',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'storehouses',
|
from: 'storehouses',
|
||||||
|
|||||||
59
src/server/models/scontistica.js
Executable file
59
src/server/models/scontistica.js
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
mongoose = require('mongoose').set('debug', false)
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = "F";
|
||||||
|
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true
|
||||||
|
});
|
||||||
|
|
||||||
|
const scontisticaSchema = new Schema({
|
||||||
|
idapp: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
code: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
qta: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
perc_sconto: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
price: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
comulativo: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var Scontistica = module.exports = mongoose.model('Scontistica', scontisticaSchema);
|
||||||
|
|
||||||
|
module.exports.getFieldsForSearch = function () {
|
||||||
|
return [{ field: 'name', type: tools.FieldType.string }]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.findAllIdApp = async function (idapp) {
|
||||||
|
const myfind = { idapp };
|
||||||
|
|
||||||
|
return await Scontistica.find(myfind);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.createIndexes((err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
});
|
||||||
@@ -66,6 +66,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Scontistica = require('../models/scontistica');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
const { Category } = require('../models/category');
|
const { Category } = require('../models/category');
|
||||||
const Group = require('../models/group');
|
const Group = require('../models/group');
|
||||||
@@ -1433,6 +1434,7 @@ function load(req, res, version) {
|
|||||||
let workers = User.getusersWorkersList(idapp);
|
let workers = User.getusersWorkersList(idapp);
|
||||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||||
let providers = Provider.findAllIdApp(idapp);
|
let providers = Provider.findAllIdApp(idapp);
|
||||||
|
let scontistica = Scontistica.findAllIdApp(idapp);
|
||||||
let departments = Department.findAllIdApp(idapp);
|
let departments = Department.findAllIdApp(idapp);
|
||||||
let categories = Category.findAllIdApp(idapp);
|
let categories = Category.findAllIdApp(idapp);
|
||||||
|
|
||||||
@@ -1520,6 +1522,7 @@ function load(req, res, version) {
|
|||||||
myelems, // 38
|
myelems, // 38
|
||||||
categories, // 39
|
categories, // 39
|
||||||
providers,
|
providers,
|
||||||
|
scontistica,
|
||||||
]).then((arrdata) => {
|
]).then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
let myuser = req.user;
|
let myuser = req.user;
|
||||||
@@ -1603,6 +1606,7 @@ function load(req, res, version) {
|
|||||||
myelems: arrdata[38],
|
myelems: arrdata[38],
|
||||||
categories: arrdata[39],
|
categories: arrdata[39],
|
||||||
providers: arrdata[40],
|
providers: arrdata[40],
|
||||||
|
scontistica: arrdata[41],
|
||||||
});
|
});
|
||||||
|
|
||||||
const prova = 1;
|
const prova = 1;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ const tools = require('../tools/general');
|
|||||||
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
||||||
|
|
||||||
const appTelegram_TEST = [tools.FREEPLANET, tools.RISO];
|
const appTelegram_TEST = [tools.FREEPLANET, tools.RISO];
|
||||||
const appTelegram_DEVELOP = [tools.RISO];
|
//const appTelegram_DEVELOP = [tools.RISO];
|
||||||
//const appTelegram_DEVELOP = [tools.FIOREDELLAVITA];
|
const appTelegram_DEVELOP = [tools.PIUCHEBUONO];
|
||||||
|
|
||||||
const appTelegramFinti = ['2', tools.CNM];
|
const appTelegramFinti = ['2', tools.CNM];
|
||||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||||
|
|||||||
@@ -416,6 +416,7 @@ module.exports = {
|
|||||||
CNM: '10',
|
CNM: '10',
|
||||||
RISO: '13',
|
RISO: '13',
|
||||||
FIOREDELLAVITA: '15',
|
FIOREDELLAVITA: '15',
|
||||||
|
PIUCHEBUONO: '17',
|
||||||
|
|
||||||
HELP_CHAT: '',
|
HELP_CHAT: '',
|
||||||
TYPECONF_ZOOM: 'zoom',
|
TYPECONF_ZOOM: 'zoom',
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
|
const Scontistica = require('../models/scontistica');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
const { Category } = require('../models/category');
|
const { Category } = require('../models/category');
|
||||||
const ShareWithUs = require('../models/sharewithus');
|
const ShareWithUs = require('../models/sharewithus');
|
||||||
@@ -107,6 +108,8 @@ module.exports = {
|
|||||||
mytable = Storehouse;
|
mytable = Storehouse;
|
||||||
else if (tablename === 'providers')
|
else if (tablename === 'providers')
|
||||||
mytable = Provider;
|
mytable = Provider;
|
||||||
|
else if (tablename === 'scontisticas')
|
||||||
|
mytable = Scontistica;
|
||||||
else if (tablename === 'departments')
|
else if (tablename === 'departments')
|
||||||
mytable = Department;
|
mytable = Department;
|
||||||
else if (tablename === 'categorys')
|
else if (tablename === 'categorys')
|
||||||
|
|||||||
Reference in New Issue
Block a user