This commit is contained in:
Surya Paolo
2024-01-09 15:31:59 +01:00
parent 4cdc4f7de1
commit 3dfb990620
4 changed files with 2 additions and 129 deletions

View File

@@ -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 };

View File

@@ -346,7 +346,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
return null;
}
return ris;
return null;
};

View File

@@ -10,7 +10,6 @@ const Storehouse = require('../models/storehouse');
const Provider = require('../models/provider');
const Gasordine = require('../models/gasordine');
const Product = require('../models/product');
const Cash = require('../models/cash');
const ProductInfo = require('../models/productInfo');
const { Circuit } = require('../models/circuit');

View File

@@ -75,7 +75,6 @@ const Group = require('../models/group');
const { Todo } = require('../models/todo');
const Hours = require('../models/hours');
const Order = require('../models/order');
const Cash = require('../models/cash');
const CashCategory = require('../models/cashCategory');
const CashSubCategory = require('../models/cashSubCategory');
@@ -149,7 +148,7 @@ module.exports = {
mytable = Producer;
else if (tablename === 'carts')
mytable = Cart;
else if (tablename === 'orderscart')
else if (tablename === 'orderscarts')
mytable = OrdersCart;
else if (tablename === 'sendmsgs')
mytable = SendMsg;