- versione: 1.2.77

- aggiustamenti e miglioramenti estetici
This commit is contained in:
Surya Paolo
2025-11-03 14:24:33 +01:00
parent 71fe2ae657
commit 26a42b1f30
5 changed files with 466 additions and 452 deletions

View File

@@ -488,7 +488,8 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
{ deleted: { $exists: true, $eq: false } }],
}, whatToShow_Unknown).sort({ status: -1 }).lean();
const last_my_transactions = await Movement.getLastN_Transactions(idapp, nummovTodownload, username, '');
const last_my_transactions = await Movement.getLastN_Transactions(idapp, nummovTodownload, nummovTodownload, username, '');
const total_transactions = await Movement.getNumTotalTransactions(idapp, username, '');
return {
listcircuits,
@@ -497,6 +498,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
manage_mycircuits,
mycircuits: user.profile.mycircuits,
last_my_transactions,
total_transactions
};
} catch (e) {

View File

@@ -10,7 +10,7 @@ const { ObjectId } = require('mongodb');
const { Account } = require('../models/account');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
mongoose.plugin((schema) => {
schema.options.usePushEach = true;
});
@@ -73,12 +73,10 @@ MovementSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await tools.findAllQueryIdApp(MyMovement, myfind);
};
MovementSchema.pre('save', async function (next) {
if (this.isNew) {
this.transactionDate = new Date();
}
@@ -90,7 +88,6 @@ MovementSchema.statics.getFieldsForSearch = function () {
{ field: 'causal', type: tools.FieldType.string },
{ field: 'amount', type: tools.FieldType.number },
];
};
MovementSchema.statics.executeQueryTable = function (idapp, params) {
@@ -98,14 +95,21 @@ MovementSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, 0, params);
};
MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accountToIdTable, amount, causal, causalDest, notifId, idOrdersCart) {
MovementSchema.statics.addMov = async function (
idapp,
accountFromIdTable,
accountToIdTable,
amount,
causal,
causalDest,
notifId,
idOrdersCart
) {
try {
// Only positive values
amount = Math.abs(amount);
let mymov = await Movement.create(
{
let mymov = await Movement.create({
idapp,
transactionDate: new Date(),
accountFromId: accountFromIdTable._id,
@@ -117,8 +121,7 @@ MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accou
residual: 0,
notifId,
// expiringDate:
},
);
});
if (mymov) {
// Update saldo dell'Account
@@ -134,24 +137,26 @@ MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accou
};
MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username, groupname, contocom, circuitId) {
try {
if (!circuitId) {
return [];
}
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, true, groupname, contocom);
const myaccount = await Account.getAccountByUsernameAndCircuitId(
idapp,
username,
circuitId,
false,
true,
groupname,
contocom
);
if (myaccount) {
let aggr1 = [
{
$match: {
idapp,
$or: [
{ accountFromId: myaccount._id },
{ accountToId: myaccount._id }],
$or: [{ accountFromId: myaccount._id }, { accountToId: myaccount._id }],
},
},
{
@@ -169,15 +174,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -197,15 +196,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -226,15 +219,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -285,15 +272,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { username: '$accto.username', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -313,15 +294,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -341,15 +316,9 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -364,8 +333,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
},
},
{
$project:
{
$project: {
transactionDate: 1,
amount: 1,
causal: 1,
@@ -393,12 +361,10 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
'contocomto.name': 1,
},
},
];
return aggr1;
}
} catch (e) {
return [];
}
@@ -406,9 +372,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
return [];
};
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp, circuitId) {
try {
if (!circuitId) {
return [];
@@ -434,15 +398,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -462,15 +420,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -490,15 +442,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -530,11 +476,11 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
$match: { 'accto.circuitId': circuitId },
},
{
'$lookup': {
'from': 'circuits',
'localField': 'accfrom.circuitId',
'foreignField': '_id',
'as': 'circuitfrom',
$lookup: {
from: 'circuits',
localField: 'accfrom.circuitId',
foreignField: '_id',
as: 'circuitfrom',
},
},
{
@@ -544,11 +490,11 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
},
},
{
'$lookup': {
'from': 'circuits',
'localField': 'accto.circuitId',
'foreignField': '_id',
'as': 'circuitto',
$lookup: {
from: 'circuits',
localField: 'accto.circuitId',
foreignField: '_id',
as: 'circuitto',
},
},
{
@@ -563,15 +509,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { username: '$accto.username', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -591,15 +531,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -619,15 +553,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -642,8 +570,7 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
},
},
{
$project:
{
$project: {
transactionDate: 1,
amount: 1,
causal: 1,
@@ -667,11 +594,9 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
'contocomto.title': 1,
},
},
];
return aggr1;
} catch (e) {
return [];
}
@@ -682,13 +607,11 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp,
MovementSchema.statics.getTotal_Transactions = async function (idapp) {
const MyMovement = this;
const numtransac = await MyMovement.countDocuments(
{
const numtransac = await MyMovement.countDocuments({
idapp,
});
return numtransac;
};
MovementSchema.statics.getTot_RIS_Transati = async function (idapp) {
@@ -697,19 +620,19 @@ MovementSchema.statics.getTot_RIS_Transati = async function (idapp) {
// Utilizza l'aggregazione per sommare tutti gli 'amount' per un dato 'idapp'
const numtot = await MyMovement.aggregate([
{
$match: { idapp } // Filtra i documenti per 'idapp'
$match: { idapp }, // Filtra i documenti per 'idapp'
},
{
$sort: {
transactionDate: -1,
}
},
},
{
$group: {
_id: null,
totalAmount: { $sum: "$amount" } // Somma tutti gli 'amount'
}
}
totalAmount: { $sum: '$amount' }, // Somma tutti gli 'amount'
},
},
]);
try {
@@ -717,8 +640,6 @@ MovementSchema.statics.getTot_RIS_Transati = async function (idapp) {
} catch (e) {
return 0;
}
};
MovementSchema.statics.getMovsByCircuitId = async function (idapp, username, circuitId) {
@@ -741,56 +662,28 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
try {
const rec = await MyMovement.findOne({ notifId }, { _id: 1 });
return !!rec;
} catch (e) {
// If Error, don't send the coins
return true;
}
};
MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz = 10, username = '', groupname = '', contocom = '') {
MovementSchema.statics.getNumTotalTransactions = async function (idapp, username = '', groupname = '', contocom = '') {
const MyMovement = this;
// get last "numtransaz" transactions
// Determina se filtrare per un account specifico
let abilitaquerypersingolo = (username || groupname || contocom);
let querym2 = null;
if (abilitaquerypersingolo) {
let v1 = [];
if (username) {
v1.push({ 'userfrom.username': username },
{ 'userto.username': username });
if (!abilitaquerypersingolo) {
// Se non c'è filtro, conta tutte le transazioni dell'app
return await MyMovement.countDocuments({ idapp });
}
if (groupname) {
v1.push({ 'groupfrom.groupname': groupname },
{ 'groupto.groupname': groupname });
}
if (contocom) {
v1.push({ 'contocomfrom.name': contocom },
{ 'contocomto.name': contocom });
}
querym2 = {
$match:
{ $or: v1 }
};
};
let aggr1 = [
// Pipeline per contare le transazioni
let pipeline = [
{
$match: { idapp },
},
{
$sort: {
transactionDate: -1,
}
},
{
$lookup: {
from: 'accounts',
@@ -800,21 +693,168 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
},
},
{ $unwind: '$accfrom' },
{
$lookup: {
from: 'accounts',
localField: 'accountToId',
foreignField: '_id',
as: 'accto',
},
},
{ $unwind: '$accto' },
];
// Costruisci il filtro OR per entrata o uscita
let orConditions = [];
if (username) {
orConditions.push(
{ 'accfrom.username': username },
{ 'accto.username': username }
);
}
if (groupname) {
orConditions.push(
{ 'accfrom.groupname': groupname },
{ 'accto.groupname': groupname }
);
}
if (contocom) {
orConditions.push(
{ 'accfrom.contocom': contocom },
{ 'accto.contocom': contocom }
);
}
// Aggiungi il match con OR
pipeline.push({
$match: {
$or: orConditions
}
});
// Conta i documenti
pipeline.push({
$count: 'total'
});
const result = await MyMovement.aggregate(pipeline);
// Se non ci sono risultati, ritorna 0
return result.length > 0 ? result[0].total : 0;
};
MovementSchema.statics.getLastN_Transactions = async function (
idapp,
numtransaz = 10,
numtransaz_uscita = 10,
username = '',
groupname = '',
contocom = ''
) {
const MyMovement = this;
// Determina se filtrare per un account specifico
let abilitaquerypersingolo = username || groupname || contocom;
// Costruisce i criteri di filtro base per identificare l'account
let matchCriteria = {};
if (username) {
matchCriteria['accfrom.username'] = username;
matchCriteria['accto.username'] = username;
}
if (groupname) {
matchCriteria['accfrom.groupname'] = groupname;
matchCriteria['accto.groupname'] = groupname;
}
if (contocom) {
matchCriteria['accfrom.contocom'] = contocom;
matchCriteria['accto.contocom'] = contocom;
}
// Pipeline comune per i lookup
const commonLookups = [
{
$lookup: {
from: 'accounts',
localField: 'accountFromId',
foreignField: '_id',
as: 'accfrom',
},
},
{ $unwind: '$accfrom' },
{
$lookup: {
from: 'accounts',
localField: 'accountToId',
foreignField: '_id',
as: 'accto',
},
},
{ $unwind: '$accto' },
];
// Funzione helper per costruire la pipeline completa
const buildPipeline = (isEntrata) => {
let pipeline = [
{
$match: { idapp },
},
{
$sort: {
transactionDate: -1,
},
},
...commonLookups,
];
// Filtro per entrata/uscita
if (abilitaquerypersingolo) {
let matchCondition = {};
if (username) {
matchCondition['username'] = isEntrata ? 'accto.username' : 'accfrom.username';
pipeline.push({
$match: {
[matchCondition['username']]: username,
},
});
} else if (groupname) {
matchCondition['groupname'] = isEntrata ? 'accto.groupname' : 'accfrom.groupname';
pipeline.push({
$match: {
[matchCondition['groupname']]: groupname,
},
});
} else if (contocom) {
matchCondition['contocom'] = isEntrata ? 'accto.contocom' : 'accfrom.contocom';
pipeline.push({
$match: {
[matchCondition['contocom']]: contocom,
},
});
}
}
// Limit appropriato
const limit = isEntrata ? numtransaz : numtransaz_uscita;
if (limit) {
pipeline.push({ $limit: limit });
}
// Aggiungi tutti i lookup rimanenti
pipeline.push(
{
$lookup: {
from: 'users',
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -834,15 +874,9 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -856,22 +890,15 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'circuits',
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -885,15 +912,6 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'accounts',
localField: 'accountToId',
foreignField: '_id',
as: 'accto',
},
},
{ $unwind: '$accto' },
{
$lookup: {
from: 'circuits',
@@ -922,15 +940,9 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
let: { username: '$accto.username', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$username', '$username'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -950,15 +962,9 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$groupname', '$groupname'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$groupname', '$groupname'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -978,15 +984,9 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$$contocom', '$path'] },
{ $eq: ['$$idapp', '$idapp'] },
],
$match: {
$expr: {
$and: [{ $eq: ['$$contocom', '$path'] }, { $eq: ['$$idapp', '$idapp'] }],
},
},
},
@@ -1000,17 +1000,8 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
preserveNullAndEmptyArrays: true,
},
},
];
if (querym2)
aggr1.push(querym2);
if (numtransaz)
aggr1.push({ $limit: numtransaz });
aggr1.push({
$project:
{
$project: {
transactionDate: 1,
amount: 1,
causal: 1,
@@ -1039,38 +1030,58 @@ MovementSchema.statics.getLastN_Transactions = async function (idapp, numtransaz
'contocomto.path': 1,
'contocomto.name': 1,
},
}
);
return pipeline;
};
// Esegui entrambe le query in parallelo se necessario
let transazioniEntrata = [];
let transazioniUscita = [];
if (abilitaquerypersingolo) {
// Esegui le query separate per entrata e uscita
[transazioniEntrata, transazioniUscita] = await Promise.all([
numtransaz ? MyMovement.aggregate(buildPipeline(true)) : Promise.resolve([]),
numtransaz_uscita ? MyMovement.aggregate(buildPipeline(false)) : Promise.resolve([]),
]);
} else {
// Se non c'è filtro specifico, prendi solo le ultime N transazioni totali
const aggr1 = buildPipeline(false); // usa la pipeline base
if (numtransaz) {
// Rimuovi l'ultimo limit e aggiungine uno nuovo
aggr1.splice(
aggr1.findIndex((stage) => stage.$limit),
1
);
aggr1.splice(3, 0, { $limit: numtransaz });
}
transazioniEntrata = await MyMovement.aggregate(aggr1);
}
// Combina e ordina i risultati
const allTransactions = [...transazioniEntrata, ...transazioniUscita];
allTransactions.sort((a, b) => b.transactionDate - a.transactionDate);
// Processa i risultati
allTransactions.forEach(function (mov) {
let ris = tools.getStringaConto(mov);
mov.userfrom = ris.userfrom;
mov.userto = ris.userto;
mov.tipocontofrom = ris.tipocontofrom;
mov.tipocontoto = ris.tipocontoto;
});
const lastNtransac = await MyMovement.aggregate(aggr1);
/*
transacDate: Date
mitt_username: string
mitt_group: string
dest_username: string
dest_group: string
circuito: string
amount: number
causale: string
*/
lastNtransac.forEach(function (mov) {
let ris = tools.getStringaConto(mov)
mov.userfrom = ris.userfrom
mov.userto = ris.userto
mov.tipocontofrom = ris.tipocontofrom
mov.tipocontoto = ris.tipocontoto
});
return lastNtransac;
return allTransactions;
};
const Movement = mongoose.model('Movement', MovementSchema);
Movement.createIndexes()
.then(() => { })
.catch((err) => { throw err; });
.then(() => {})
.catch((err) => {
throw err;
});
module.exports = { Movement };

View File

@@ -68,7 +68,7 @@ const StatSchema = new Schema({
StatSchema.statics.updateStats = async function (idapp, datastat) {
datastat.last_transactions = await Movement.getLastN_Transactions(idapp, 5);
datastat.last_transactions = await Movement.getLastN_Transactions(idapp, 5, 5);
return datastat;
};

View File

@@ -427,13 +427,14 @@ router.patch('/:id', authenticate, (req, res) => {
router.post('/lastmovs', authenticate, async (req, res) => {
const nummov = req.body.nummov;
const nummov_uscita = req.body.nummov_uscita;
const idapp = req.body.idapp;
try {
const { Movement } = require('../models/movement');
if (nummov) {
last_transactions = await Movement.getLastN_Transactions(idapp, nummov);
last_transactions = await Movement.getLastN_Transactions(idapp, nummov, nummov_uscita);
}
res.send({ code: server_constants.RIS_CODE_OK, last_transactions });

View File

@@ -1 +1 @@
1.2.76
1.2.77