Quando accedi al Circuito RIS Nazionale, ti imposta il Fido e QtaMax DOPPIA rispetto al tuo Circuito Locale
This commit is contained in:
BIN
emails/.DS_Store
vendored
Normal file
BIN
emails/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -23,3 +23,5 @@ Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
|||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
|
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
@@ -621,6 +621,20 @@ AccountSchema.statics.updateFido = async function (idapp, username, groupname, c
|
|||||||
return risult;
|
return risult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
|
||||||
|
|
||||||
|
let paramstoupdate = {
|
||||||
|
qta_maxConcessa: qtamax,
|
||||||
|
};
|
||||||
|
let risult = null;
|
||||||
|
if (groupname)
|
||||||
|
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||||
|
else
|
||||||
|
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
|
||||||
|
|
||||||
|
return risult;
|
||||||
|
};
|
||||||
|
|
||||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||||
const account = await Account.findOne({ _id: id }).lean();
|
const account = await Account.findOne({ _id: id }).lean();
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ const CircuitSchema = new Schema({
|
|||||||
totCircolante: {
|
totCircolante: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
showAlways: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
totTransato: {
|
totTransato: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
@@ -212,6 +215,10 @@ const CircuitSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
showAlways: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
@@ -276,6 +283,7 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
|||||||
fido_scoperto_default_grp: 1,
|
fido_scoperto_default_grp: 1,
|
||||||
qta_max_default_grp: 1,
|
qta_max_default_grp: 1,
|
||||||
deperimento: 1,
|
deperimento: 1,
|
||||||
|
showAlways: 1,
|
||||||
transactionsEnabled: 1,
|
transactionsEnabled: 1,
|
||||||
status: 1,
|
status: 1,
|
||||||
valuta_per_euro: 1,
|
valuta_per_euro: 1,
|
||||||
@@ -331,6 +339,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
|||||||
longdescr: 1,
|
longdescr: 1,
|
||||||
regulation: 1,
|
regulation: 1,
|
||||||
numMembers: 1,
|
numMembers: 1,
|
||||||
|
showAlways: 1,
|
||||||
systemUserId: 1,
|
systemUserId: 1,
|
||||||
founderUserId: 1,
|
founderUserId: 1,
|
||||||
nome_valuta: 1,
|
nome_valuta: 1,
|
||||||
@@ -936,6 +945,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
|||||||
photos: [],
|
photos: [],
|
||||||
color: '#ff5500',
|
color: '#ff5500',
|
||||||
deperimento: false,
|
deperimento: false,
|
||||||
|
showAlways: false,
|
||||||
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
||||||
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
||||||
symbol: 'RIS',
|
symbol: 'RIS',
|
||||||
@@ -1092,16 +1102,56 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
|||||||
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
|
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
|
||||||
if (mycircuit) {
|
if (mycircuit) {
|
||||||
const circuitId = mycircuit._id;
|
const circuitId = mycircuit._id;
|
||||||
|
let account = null;
|
||||||
const account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
|
||||||
if (account) {
|
|
||||||
let fido = 0;
|
let fido = 0;
|
||||||
|
let qtamax = 0;
|
||||||
|
|
||||||
|
if (mycircuit.showAlways) {
|
||||||
|
|
||||||
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
|
const myuser = await User.getUserByUsername(idapp, username);
|
||||||
|
|
||||||
|
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
|
||||||
|
const accountsuser = await Account.getUserAccounts(idapp, username);
|
||||||
|
if (accountsuser) {
|
||||||
|
// Se lo trovo della mia provincia, prendo quello
|
||||||
|
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province)
|
||||||
|
if (!account && accountsuser.length > 0) {
|
||||||
|
// Se non lo trovo, prendo il primo in cui sono entrato !
|
||||||
|
account = accountsuser[0];
|
||||||
|
}
|
||||||
|
if (account && account.circuit) {
|
||||||
|
if (groupname) {
|
||||||
|
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
} else {
|
||||||
|
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Se non ho Circuiti locali, non applico il Fido !
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
||||||
if (groupname)
|
if (groupname)
|
||||||
fido = mycircuit.fido_scoperto_default_grp;
|
fido = mycircuit.fido_scoperto_default_grp;
|
||||||
else
|
else
|
||||||
fido = mycircuit.fido_scoperto_default;
|
fido = mycircuit.fido_scoperto_default;
|
||||||
|
}
|
||||||
|
|
||||||
return await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
if (account) {
|
||||||
|
if (qtamax > 0) {
|
||||||
|
await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||||
|
if (ris) {
|
||||||
|
return { qta_maxConcessa: qtamax, fidoConcesso: fido };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -381,16 +381,16 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
|||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
||||||
if (recnotif.paramsObj.isAdmin) {
|
if (recnotif.paramsObj.isAdmin) {
|
||||||
if (recnotif.extrarec.groupname) {
|
if (recnotif.extrarec.groupname) {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fido_scoperto_default_grp, recnotif.paramsObj.circuitnameDest,
|
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||||
username_action);
|
username_action);
|
||||||
} else {
|
} else {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fido_scoperto_default, recnotif.paramsObj.circuitnameDest,
|
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||||
username_action);
|
username_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
recnotif.openUrl = '/my/' + sender;
|
recnotif.openUrl = '/my/' + sender;
|
||||||
} else {
|
} else {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fido_scoperto_default, username_action, recnotif.paramsObj.circuitnameDest);
|
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fidoConcesso, username_action, recnotif.paramsObj.circuitnameDest);
|
||||||
}
|
}
|
||||||
tag = 'setfido';
|
tag = 'setfido';
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||||
|
|||||||
@@ -2615,6 +2615,10 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
|||||||
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
||||||
|
|
||||||
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
||||||
|
if (ris) {
|
||||||
|
|
||||||
|
extrarec.fidoConcesso = ris.fidoConcesso;
|
||||||
|
extrarec.qta_maxConcessa = ris.qta_maxConcessa;
|
||||||
|
|
||||||
// Elimina la richiesta:
|
// Elimina la richiesta:
|
||||||
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
||||||
@@ -2626,6 +2630,9 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
|||||||
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
||||||
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// errore !?
|
||||||
|
}
|
||||||
|
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,12 @@ module.exports = {
|
|||||||
VISIB_ONLY_MANAGER: 2,
|
VISIB_ONLY_MANAGER: 2,
|
||||||
VISIB_ONLY_ADMIN: 4,
|
VISIB_ONLY_ADMIN: 4,
|
||||||
|
|
||||||
|
CIRCUIT_CFG: {
|
||||||
|
MULT_FIDO_USER: 2.0,
|
||||||
|
MULT_FIDO_GROUP: 2.0,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
Visibility_Group: {
|
Visibility_Group: {
|
||||||
PRIVATE: 1,
|
PRIVATE: 1,
|
||||||
HIDDEN: 2,
|
HIDDEN: 2,
|
||||||
@@ -643,6 +649,7 @@ module.exports = {
|
|||||||
nome_valuta: 1,
|
nome_valuta: 1,
|
||||||
fido_scoperto_default: 1,
|
fido_scoperto_default: 1,
|
||||||
deperimento: 1,
|
deperimento: 1,
|
||||||
|
showAlways: 1,
|
||||||
status: 1,
|
status: 1,
|
||||||
transactionsEnabled: 1,
|
transactionsEnabled: 1,
|
||||||
qta_max_default: 1,
|
qta_max_default: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user