Add Tag ID filter in transaction endpoints
MODIFY
src/server/rest/service/TransactionService.ts
src/server/rest/service/TransactionService.ts
@@ -855,6 +855,7 @@ export default class TransactionService {
chargeBoxIDs: filteredRequest.ChargeBoxID ? filteredRequest.ChargeBoxID.split('|') : null,
issuer: Utils.objectHasProperty(filteredRequest, 'Issuer') ? filteredRequest.Issuer : null,
userIDs: filteredRequest.UserID ? filteredRequest.UserID.split('|') : null,
+ tagIDs: filteredRequest.TagID ? filteredRequest.TagID.split('|') : null,
ownerID: Authorizations.isBasic(req.user) ? req.user.id : null,
siteAreaIDs: filteredRequest.SiteAreaID ? filteredRequest.SiteAreaID.split('|') : null,
siteIDs: filteredRequest.SiteID ? Authorizations.getAuthorizedSiteAdminIDs(req.user, filteredRequest.SiteID.split('|')) : null,

MODIFY
src/server/rest/service/security/TransactionSecurity.ts
src/server/rest/service/security/TransactionSecurity.ts
@@ -80,6 +80,7 @@ export default class TransactionSecurity {
filteredRequest.StartDateTime = sanitize(request.StartDateTime);
filteredRequest.EndDateTime = sanitize(request.EndDateTime);
filteredRequest.SiteID = sanitize(request.SiteID);
+ filteredRequest.TagID = sanitize(request.TagID);
filteredRequest.SiteAreaID = sanitize(request.SiteAreaID);
filteredRequest.Search = sanitize(request.Search);
filteredRequest.InactivityStatus = sanitize(request.InactivityStatus);

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -257,7 +257,7 @@ export default class TransactionStorage {
params: {
transactionIDs?: number[]; issuer?: boolean; search?: string; ownerID?: string; userIDs?: string[]; siteAdminIDs?: string[];
chargeBoxIDs?: string[]; siteAreaIDs?: string[]; siteIDs?: string[]; connectorId?: number; startDateTime?: Date;
- endDateTime?: Date; stop?: any; minimalPrice?: boolean; reportIDs?: string[]; inactivityStatus?: string[];
+ 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;
statistics?: 'refund' | 'history'; refundStatus?: string[];
@@ -328,6 +328,10 @@ export default class TransactionStorage {
if (params.chargeBoxIDs) {
filters.chargeBoxID = { $in: params.chargeBoxIDs };
}
+ // Tag
+ if (params.tagIDs) {
+ filters.tagID = { $in: params.tagIDs };
+ }
// Connector
if (params.connectorId) {
filters.connectorId = Utils.convertToInt(params.connectorId);

MODIFY
src/types/requests/HttpTransactionRequest.ts
src/types/requests/HttpTransactionRequest.ts
@@ -27,6 +27,7 @@ export interface HttpTransactionsRequest extends HttpDatabaseRequest {
SiteAreaID?: string;
SiteID?: string;
UserID?: string;
+ TagID?: string;
StartDateTime?: Date;
EndDateTime?: Date;
Search?: string;

Add Tag ID filter in transaction endpoints