aggiorna
This commit is contained in:
@@ -1,125 +0,0 @@
|
|||||||
const mongoose = require('mongoose').set('debug', false)
|
|
||||||
const Schema = mongoose.Schema;
|
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
|
||||||
mongoose.level = "F";
|
|
||||||
|
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
|
||||||
mongoose.plugin(schema => {
|
|
||||||
schema.options.usePushEach = true
|
|
||||||
});
|
|
||||||
|
|
||||||
const CashSchema = new Schema({
|
|
||||||
idapp: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
creatorUserId: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
idCashCategory: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
type: { // CashType: TYPE_IN, TYPE_OUT
|
|
||||||
type: Number,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fromUsername: { type: Schema.Types.String },
|
|
||||||
toUsername: { type: Schema.Types.String },
|
|
||||||
idOrdersCart: { type: Schema.Types.ObjectId, ref: 'OrdersCart' },
|
|
||||||
date_created: {
|
|
||||||
type: Date,
|
|
||||||
default: Date.now,
|
|
||||||
},
|
|
||||||
date_payment: {
|
|
||||||
type: Date,
|
|
||||||
default: Date.now,
|
|
||||||
},
|
|
||||||
causale: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
price: {
|
|
||||||
type: Number
|
|
||||||
},
|
|
||||||
internal: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
extra: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
confirmed: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
var Cash = module.exports = mongoose.model('Cash', CashSchema);
|
|
||||||
|
|
||||||
Cash.createIndexes((err) => {
|
|
||||||
if (err) throw err;
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports.getFieldsForSearch = function () {
|
|
||||||
return []
|
|
||||||
};
|
|
||||||
|
|
||||||
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 Cash.find(myfind);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.getAllCash = function (query, sort, callback) {
|
|
||||||
Cash.find(query, null, sort, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.getCashByUserId = function (userId, sort, callback) {
|
|
||||||
Cash.find({ userId }, null, sort, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.getCashByID = function (id, callback) {
|
|
||||||
Cash.findById(id, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.createMovementCashByOrdersCart = async function (ordersCart, usernameStore, req, internal) {
|
|
||||||
|
|
||||||
let casjobj = {
|
|
||||||
idapp: req.user.iapp,
|
|
||||||
idOrdersCart: ordersCart._id,
|
|
||||||
creatorUserId: req.user ? req.user._id : null,
|
|
||||||
type: shared_consts.TYPECASH.IN,
|
|
||||||
fromUsername: ordersCart.user.username,
|
|
||||||
toUsername: usernameStore,
|
|
||||||
causal: 'Pagato Ordine n.' + ordersCart.numorder,
|
|
||||||
price: ordersCart.totalPrice,
|
|
||||||
internal,
|
|
||||||
}
|
|
||||||
|
|
||||||
const CashModel = new Cash(casjobj);
|
|
||||||
|
|
||||||
return await CashModel.save(Cash)
|
|
||||||
.then((ris) => {
|
|
||||||
if (!!ris)
|
|
||||||
return ris._id;
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// const Cash = mongoose.model('Cash', CashSchema);
|
|
||||||
|
|
||||||
// module.exports = { Cash };
|
|
||||||
@@ -346,7 +346,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ris;
|
return null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ const Storehouse = require('../models/storehouse');
|
|||||||
const Provider = require('../models/provider');
|
const Provider = require('../models/provider');
|
||||||
const Gasordine = require('../models/gasordine');
|
const Gasordine = require('../models/gasordine');
|
||||||
const Product = require('../models/product');
|
const Product = require('../models/product');
|
||||||
const Cash = require('../models/cash');
|
|
||||||
const ProductInfo = require('../models/productInfo');
|
const ProductInfo = require('../models/productInfo');
|
||||||
|
|
||||||
const { Circuit } = require('../models/circuit');
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ const Group = require('../models/group');
|
|||||||
const { Todo } = require('../models/todo');
|
const { Todo } = require('../models/todo');
|
||||||
const Hours = require('../models/hours');
|
const Hours = require('../models/hours');
|
||||||
const Order = require('../models/order');
|
const Order = require('../models/order');
|
||||||
const Cash = require('../models/cash');
|
|
||||||
const CashCategory = require('../models/cashCategory');
|
const CashCategory = require('../models/cashCategory');
|
||||||
const CashSubCategory = require('../models/cashSubCategory');
|
const CashSubCategory = require('../models/cashSubCategory');
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ module.exports = {
|
|||||||
mytable = Producer;
|
mytable = Producer;
|
||||||
else if (tablename === 'carts')
|
else if (tablename === 'carts')
|
||||||
mytable = Cart;
|
mytable = Cart;
|
||||||
else if (tablename === 'orderscart')
|
else if (tablename === 'orderscarts')
|
||||||
mytable = OrdersCart;
|
mytable = OrdersCart;
|
||||||
else if (tablename === 'sendmsgs')
|
else if (tablename === 'sendmsgs')
|
||||||
mytable = SendMsg;
|
mytable = SendMsg;
|
||||||
|
|||||||
Reference in New Issue
Block a user