- catalogo

- corretto logica del RefreshToken che non richiedeva il nuovo token, quindi scadeva tutte le volte, richiedendo sempre l'accesso !
This commit is contained in:
Surya Paolo
2025-01-07 16:50:55 +01:00
parent 7f6ed73763
commit 9fb7df56e6
24 changed files with 1199 additions and 59 deletions

View File

@@ -235,11 +235,11 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
myaccount.totTransato = 0;
}
myaccount.totTransato += Math.abs(amount);
if (!myaccount.numtransactions)
myaccount.numtransactions = 0;
myaccount.numtransactions++;
myaccount.date_updated = new Date();
myaccountupdate.saldo = myaccount.saldo;
@@ -255,7 +255,9 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
// Calcola Saldo Pendente !
await myaccount.calcPending(true);
return ris;
const recupdated = await Account.findOne({ _id: myaccount.id });
return recupdated;
}
} catch (e) {
@@ -322,8 +324,9 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
});
if (contocom) {
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_contocom || shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
myaccount.qta_maxConcessa = mycircuit.qta_max_default_contocom || shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
} else {
if (!mycircuit.fido_scoperto_default_grp)
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
@@ -343,7 +346,13 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
myaccount.fidoConcesso = 0;
}
return await myaccount.save();
let acc = await myaccount.save();
if (mycircuit.creditodiPartenza && mycircuit.creditodiPartenza > 0) {
acc = await Account.addtoSaldo(acc, mycircuit.creditodiPartenza, false);
}
return acc;
}
return myaccount;
@@ -605,8 +614,12 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso,
}
});
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
const circuit = await Circuit.findOne({ _id: circuitId });
if (!circuit.circuitoIndipendente) {
// Se aggiorno questi dati, e non è un Circuito Indipendente, allora devo aggiornare anche gli account del RIS Nazionale
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
}
} else {
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
@@ -690,9 +703,9 @@ AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (i
} catch (e) {
console.error('updateAccountCircuitoNazionaleByLimiti', e);
}
return false;
};
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
@@ -736,7 +749,7 @@ AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, ci
// Rimuovi l'account
AccountSchema.statics.removeAccount = async function (accountId) {
return await Account.deleteOne({ _id: accountId});
return await Account.deleteOne({ _id: accountId });
};
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {