Circuits...
Circuits Fido e Max Qta Fixed error eslint: 7.0.0 is OK
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Account is a User's single Circuit
|
||||
*/
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -35,6 +35,12 @@ const AccountSchema = new Schema({
|
||||
deperibile: {
|
||||
type: Boolean,
|
||||
},
|
||||
fidoConcesso: {
|
||||
type: Number,
|
||||
},
|
||||
qta_maxConcessa: {
|
||||
type: Number,
|
||||
},
|
||||
importo_iniziale: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -138,11 +144,14 @@ AccountSchema.statics.getUserAccounts = async function(idapp, username) {
|
||||
},
|
||||
},
|
||||
},
|
||||
/*
|
||||
{
|
||||
$project: {
|
||||
"circuit.name": 1,
|
||||
},
|
||||
},
|
||||
|
||||
*/
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
@@ -164,7 +173,7 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
|
||||
if (myaccount) {
|
||||
myaccount.saldo = myaccount.saldo + amount;
|
||||
myaccount.date_updated = new Date();
|
||||
return myaccount.save();
|
||||
return await myaccount.save();
|
||||
|
||||
}
|
||||
|
||||
@@ -174,6 +183,8 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, username, circuitId, createifnotexist) {
|
||||
const Account = this;
|
||||
|
||||
const {Circuit} = require('../models/circuit');
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
@@ -183,6 +194,8 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
||||
circuitId,
|
||||
};
|
||||
|
||||
const mycircuit = await Circuit.getCircuitById(circuitId);
|
||||
|
||||
let myaccount = await Account.findOne(myquery).lean();
|
||||
|
||||
if (!myaccount && createifnotexist) {
|
||||
@@ -191,11 +204,13 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
||||
username,
|
||||
circuitId,
|
||||
deperibile: false,
|
||||
fidoConcesso: mycircuit.fido_scoperto_default,
|
||||
qta_maxConcessa: mycircuit.qta_max_default,
|
||||
importo_iniziale: 0,
|
||||
saldo: 0,
|
||||
});
|
||||
|
||||
return myaccount.save();
|
||||
return await myaccount.save();
|
||||
}
|
||||
|
||||
return myaccount;
|
||||
|
||||
Reference in New Issue
Block a user