Add flag hasUserID to getTransactions()
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -175,7 +175,7 @@ export default class TagService {
});
}
const transactions = await TransactionStorage.getTransactions(req.user.tenantID,
- { tagIDs: [filteredRequest.id.toUpperCase()] }, Constants.DB_PARAMS_SINGLE_RECORD);
+ { tagIDs: [filteredRequest.id.toUpperCase()], hasUserID: true }, Constants.DB_PARAMS_SINGLE_RECORD);
if (!Utils.isEmptyArray(transactions.result)) {
throw new AppError({
source: Constants.CENTRAL_SERVER,

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -271,7 +271,7 @@ export default class TransactionStorage {
endDateTime?: Date; stop?: any; minimalPrice?: boolean; reportIDs?: string[]; tagIDs?: string[]; inactivityStatus?: string[];
ocpiSessionID?: string; ocpiSessionDateFrom?: Date; ocpiSessionDateTo?: Date; ocpiCdrDateFrom?: Date; ocpiCdrDateTo?: Date;
ocpiSessionChecked?: boolean; ocpiCdrChecked?: boolean; oicpSessionID?: string;
- statistics?: 'refund' | 'history'; refundStatus?: string[]; withTag?: boolean;
+ statistics?: 'refund' | 'history'; refundStatus?: string[]; withTag?: boolean; hasUserID?: boolean;
},
dbParams: DbParams, projectFields?: string[]):
Promise<{
@@ -347,6 +347,13 @@ export default class TransactionStorage {
if (params.tagIDs) {
filters.tagID = { $in: params.tagIDs };
}
+ // Has user ID?
+ if (params.hasUserID) {
+ filters.$and = [
+ { 'userID': { '$exists': true } },
+ { 'userID': { '$ne': null } }
+ ];
+ }
// Connector
if (!Utils.isEmptyArray(params.connectorIDs)) {
filters.connectorId = {

Add flag hasUserID to getTransactions()