Start Monetary Implementation (RIS)
This commit is contained in:
81
src/server/models/account.js
Executable file
81
src/server/models/account.js
Executable file
@@ -0,0 +1,81 @@
|
|||||||
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = 'F';
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
const {ObjectID} = require('mongodb');
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const AccountSchema = new Schema({
|
||||||
|
_id: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
circuitId: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
nome_conto: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
deperibile: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
importo_iniziale: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
saldo: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
AccountSchema.statics.findAllIdApp = async function(idapp) {
|
||||||
|
const MyAccount = this;
|
||||||
|
|
||||||
|
const myfind = {idapp};
|
||||||
|
|
||||||
|
return await MyAccount.find(myfind, (err, arrrec) => {
|
||||||
|
return arrrec;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
AccountSchema.pre('save', async function(next) {
|
||||||
|
if (this.isNew) {
|
||||||
|
const myrec = await Account.findOne().limit(1).sort({_id: -1});
|
||||||
|
if (!!myrec) {
|
||||||
|
if (myrec._doc._id === 0)
|
||||||
|
this._id = 1;
|
||||||
|
else
|
||||||
|
this._id = myrec._doc._id + 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this._id = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
AccountSchema.statics.getFieldsForSearch = function() {
|
||||||
|
return [
|
||||||
|
{field: 'nome_conto', type: tools.FieldType.string},
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
AccountSchema.statics.executeQueryTable = function(idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, 0, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Account = mongoose.model('Account', AccountSchema);
|
||||||
|
|
||||||
|
module.exports = {Account};
|
||||||
147
src/server/models/circuit.js
Executable file
147
src/server/models/circuit.js
Executable file
@@ -0,0 +1,147 @@
|
|||||||
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = 'F';
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
const {ObjectID} = require('mongodb');
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const CircuitSchema = new Schema({
|
||||||
|
_id: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
nome_circuito: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
sotto_nome: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
descr: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
systemUserDescr: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
systemUserId: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
founderUserId: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
totCircolante: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
totTransato: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
nome_valuta: {
|
||||||
|
type: String,
|
||||||
|
maxlength: 20,
|
||||||
|
},
|
||||||
|
simbolo: {
|
||||||
|
type: String,
|
||||||
|
maxlength: 3,
|
||||||
|
},
|
||||||
|
sigla: {
|
||||||
|
type: String,
|
||||||
|
maxlength: 3,
|
||||||
|
},
|
||||||
|
compara_valuta: {
|
||||||
|
type: Number,
|
||||||
|
default: 1,
|
||||||
|
},
|
||||||
|
compara_euro: {
|
||||||
|
type: Number,
|
||||||
|
default: 1,
|
||||||
|
},
|
||||||
|
valuta_per_euro: {
|
||||||
|
type: Number,
|
||||||
|
default: 1,
|
||||||
|
},
|
||||||
|
fido_scoperto_default: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
data_costituz: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
deperimento: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
freq_deper: { // H, D, W, M, Y
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
minuto_deper: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
ora_deper: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
giorno_deper: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
mese_deper: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
ultimo_deper: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
durata_deper: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
// -------------
|
||||||
|
img_logo: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
CircuitSchema.statics.findAllIdApp = async function(idapp) {
|
||||||
|
const MyCircuit = this;
|
||||||
|
|
||||||
|
const myfind = {idapp};
|
||||||
|
|
||||||
|
return await MyCircuit.find(myfind, (err, arrrec) => {
|
||||||
|
return arrrec;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
CircuitSchema.pre('save', async function(next) {
|
||||||
|
if (this.isNew) {
|
||||||
|
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
|
||||||
|
if (!!myrec) {
|
||||||
|
if (myrec._doc._id === 0)
|
||||||
|
this._id = 1;
|
||||||
|
else
|
||||||
|
this._id = myrec._doc._id + 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this._id = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
CircuitSchema.statics.getFieldsForSearch = function() {
|
||||||
|
return [
|
||||||
|
{field: 'nome_circuito', type: tools.FieldType.string},
|
||||||
|
{field: 'sotto_nome', type: tools.FieldType.string},
|
||||||
|
{field: 'nome_valuta', type: tools.FieldType.string},
|
||||||
|
{field: 'descr', type: tools.FieldType.string}];
|
||||||
|
};
|
||||||
|
|
||||||
|
CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, 0, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||||
|
|
||||||
|
module.exports = {Circuit};
|
||||||
84
src/server/models/movement.js
Executable file
84
src/server/models/movement.js
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = 'F';
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
|
const {ObjectID} = require('mongodb');
|
||||||
|
|
||||||
|
// Resolving error Unknown modifier: $pushAll
|
||||||
|
mongoose.plugin(schema => {
|
||||||
|
schema.options.usePushEach = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const MovementSchema = new Schema({
|
||||||
|
_id: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
transactionDate: {
|
||||||
|
type: Date
|
||||||
|
},
|
||||||
|
accountFromId: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
accountToId: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
amount: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
causal: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
residual: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
expiringDate: {
|
||||||
|
type: Date
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
MovementSchema.statics.findAllIdApp = async function(idapp) {
|
||||||
|
const MyMovement = this;
|
||||||
|
|
||||||
|
const myfind = {idapp};
|
||||||
|
|
||||||
|
return MyMovement.find(myfind, (err, arrrec) => {
|
||||||
|
return arrrec;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
MovementSchema.pre('save', async function(next) {
|
||||||
|
if (this.isNew) {
|
||||||
|
const myrec = await Movement.findOne().limit(1).sort({_id: -1});
|
||||||
|
if (!!myrec) {
|
||||||
|
if (myrec._doc._id === 0)
|
||||||
|
this._id = 1;
|
||||||
|
else
|
||||||
|
this._id = myrec._doc._id + 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this._id = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
MovementSchema.statics.getFieldsForSearch = function() {
|
||||||
|
return [
|
||||||
|
{field: 'nome_conto', type: tools.FieldType.string},
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
MovementSchema.statics.executeQueryTable = function(idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
|
return tools.executeQueryTable(this, 0, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Movement = mongoose.model('Movement', MovementSchema);
|
||||||
|
|
||||||
|
module.exports = {Movement};
|
||||||
Reference in New Issue
Block a user