Keep the TagID in Transaction endpoint
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
{
"$ref": "#/components/parameters/TagIDs"
},
+ {
+ "$ref": "#/components/parameters/VisualTagIDs"
+ },
{
"$ref": "#/components/parameters/SiteIDs"
},
"type": "string"
}
},
+ "VisualTagIDs": {
+ "in": "query",
+ "name": "VisualTagID",
+ "description": "Pipe separated Visual Tag IDs",
+ "required": false,
+ "schema": {
+ "type": "string"
+ }
+ },
"TagIDs": {
"in": "query",
"name": "TagID",

MODIFY
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
"UserID": {
"$ref": "common.json#/definitions/ids"
},
+ "TagID": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
"VisualTagID": {
"type": "string",
"sanitize": "mongo"

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -1111,6 +1111,7 @@ export default class TransactionService {
issuer: Utils.objectHasProperty(filteredRequest, 'Issuer') ? filteredRequest.Issuer : null,
userIDs: filteredRequest.UserID ? filteredRequest.UserID.split('|') : null,
visualTagIDs: filteredRequest.VisualTagID ? filteredRequest.VisualTagID.split('|') : null,
+ tagIDs: filteredRequest.TagID ? filteredRequest.TagID.split('|') : null,
ownerID: Authorizations.isBasic(req.user) ? req.user.id : null,
withSite: filteredRequest.WithSite,
withCompany: filteredRequest.WithCompany,

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -311,6 +311,8 @@ export default class TransactionStorage {
}
});
}
+ // Create Aggregation
+ const aggregation = [];
// Filter?
if (params.search) {
// Build filter
@@ -355,6 +357,14 @@ export default class TransactionStorage {
if (params.tagIDs) {
filters.tagID = { $in: params.tagIDs };
}
+ if (!Utils.isEmptyArray(params.visualTagIDs)) {
+ DatabaseUtils.pushTagLookupInAggregation({
+ tenantID, aggregation, localField: 'tagID', foreignField: '_id', asField: 'tag'
+ });
+ aggregation.push({
+ $match: { 'tag.visualID': { $in: params.visualTagIDs } }
+ });
+ }
// Has user ID?
if (params.hasUserID) {
filters.$and = [
@@ -445,16 +455,6 @@ export default class TransactionStorage {
if (params.reportIDs) {
filters['refundData.reportId'] = { $in: params.reportIDs };
}
- // Create Aggregation
- const aggregation = [];
- if (!Utils.isEmptyArray(params.visualTagIDs)) {
- DatabaseUtils.pushTagLookupInAggregation({
- tenantID, aggregation, localField: 'tagID', foreignField: '_id', asField: 'tag'
- });
- aggregation.push({
- $match: { 'tag.visualID': { $in: params.visualTagIDs } }
- });
- }
// Filters
if (ownerMatch.$or && ownerMatch.$or.length > 0) {
aggregation.push({

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

MODIFY
test/api/UserTest.ts
test/api/UserTest.ts
@@ -273,7 +273,7 @@ describe('User', function() {
expect(response.status).to.equal(StatusCodes.CREATED);
testData.createdTags.push(testData.newTag);
// Retrieve it
- response = await testData.userService.userApi.getDefaultTagCar(testData.newUser.id,testData.siteContext.getSite().id);
+ response = await testData.userService.userApi.getDefaultTagCar(testData.newUser.id);
expect(response.status).to.be.eq(StatusCodes.OK);
expect(response.data.tag.visualID).to.be.eq(testData.newTag.visualID);
expect(response.data.car).to.be.undefined;

MODIFY
test/api/client/UserApi.ts
test/api/client/UserApi.ts
@@ -80,8 +80,8 @@ export default class UserApi extends CrudApi {
return await super.read({}, url);
}
- public async getDefaultTagCar(userID: string, siteID: string) {
+ public async getDefaultTagCar(userID: string) {
const url = this.buildRestEndpointUrl(ServerRoute.REST_USER_DEFAULT_TAG_CAR, { });
- return await super.read({ UserID: userID, SiteID: siteID }, url);
+ return await super.read({ UserID: userID }, url);
}
}

Keep the TagID in Transaction endpoint