only count annonymuze transactions when userID is true
MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -1079,7 +1079,7 @@ export default class UserService {
});
}
// Get Tag
- const tag = await UserStorage.getTag(req.user.tenantID, tagId, { withNbrTransactions: true });
+ const tag = await UserStorage.getTag(req.user.tenantID, tagId, { withNbrTransactions: true, withUser: true });
UtilsService.assertObjectExists(action, tag, `Tag ID '${tagId}' does not exist`,
MODULE_NAME, 'handleDeleteTag', req.user);
// Only current organizations tags can be deleted
@@ -1257,7 +1257,7 @@ export default class UserService {
// Check
await Utils.checkIfUserTagIsValid(filteredRequest, req);
// Get Tag
- const tag = await UserStorage.getTag(req.user.tenantID, filteredRequest.id, { withNbrTransactions: true });
+ const tag = await UserStorage.getTag(req.user.tenantID, filteredRequest.id, { withNbrTransactions: true, withUser: true });
UtilsService.assertObjectExists(action, tag, `Tag ID '${filteredRequest.id}' does not exist`,
MODULE_NAME, 'handleUpdateTag', req.user);
// Only current organization Tag can be updated

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -843,13 +843,17 @@ export default class UserStorage {
});
// Transactions
if (params.withNbrTransactions) {
+ let additionalPipeline :Record<string, any>[] = [];
+ if (params.withUser) {
+ additionalPipeline = [{
+ '$match': { 'userID': { $exists: true, $ne: null } }
+ }];
+ }
DatabaseUtils.pushTransactionsLookupInAggregation({
tenantID, aggregation: aggregation, localField: '_id', foreignField: 'tagID',
count: true, asField: 'transactionsCount', oneToOneCardinality: false,
objectIDFields: ['createdBy', 'lastChangedBy']
- }, [{
- '$match': { 'userID': { $exists: true, $ne: null } }
- }]);
+ },additionalPipeline);
}
// Users
if (params.withUser) {

only count annonymuze transactions when userID is true