Rolled back transactions to URI based status filtering
MODIFY
src/server/rest/v1/router/api/TransactionRouter.ts
src/server/rest/v1/router/api/TransactionRouter.ts
@@ -14,6 +14,11 @@ export default class TransactionRouter {
public buildRoutes(): express.Router {
this.buildRouteTransactions();
+ this.buildRouteTransactionsCompleted();
+ this.buildRouteTransactionsActive();
+ this.buildRouteTransactionsInError();
+ this.buildRouteTransactionsUnassignedCount();
+ this.buildRouteTransactionsGetRefund();
this.buildRouteTransaction();
this.buildRouteTransactionConsumption();
this.buildRouteDeleteTransaction();
@@ -33,26 +38,37 @@ export default class TransactionRouter {
protected buildRouteTransactions(): void {
this.router.get(`/${ServerRoute.REST_TRANSACTIONS}`, async (req: Request, res: Response, next: NextFunction) => {
- switch (req.query.Status) {
- case 'in-error':
+ await RouterUtils.handleServerAction(TransactionService.handleGetTransactions.bind(this), ServerAction.TRANSACTIONS, req, res, next);
+ });
+ }
+
+ protected buildRouteTransactionsInError(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_IN_ERROR}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(TransactionService.handleGetTransactionsInError.bind(this), ServerAction.TRANSACTIONS_IN_ERROR, req, res, next);
- break;
- case 'completed':
+ });
+ }
+
+ protected buildRouteTransactionsCompleted(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_COMPLETED}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(TransactionService.handleGetTransactionsCompleted.bind(this), ServerAction.TRANSACTIONS_COMPLETED, req, res, next);
- break;
- case 'to-refund':
- await RouterUtils.handleServerAction(TransactionService.handleGetTransactionsToRefund.bind(this), ServerAction.TRANSACTIONS_TO_REFUND, req, res, next);
- break;
- case 'active':
+ });
+ }
+
+ protected buildRouteTransactionsActive(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_ACTIVE}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(TransactionService.handleGetTransactionsActive.bind(this), ServerAction.TRANSACTIONS_ACTIVE, req, res, next);
- break;
- case 'not-assigned-to-user':
+ });
+ }
+
+ protected buildRouteTransactionsUnassignedCount(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_UNASSIGNED_COUNT}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(TransactionService.handleGetUnassignedTransactionsCount.bind(this), ServerAction.UNASSIGNED_TRANSACTIONS_COUNT, req, res, next);
- break;
- default:
- await RouterUtils.handleServerAction(TransactionService.handleGetTransactions.bind(this), ServerAction.TRANSACTIONS, req, res, next);
- break;
+ });
}
+
+ protected buildRouteTransactionsGetRefund(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_REFUND}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TransactionService.handleGetTransactionsToRefund.bind(this), ServerAction.TRANSACTIONS_TO_REFUND, req, res, next);
});
}
@@ -112,7 +128,7 @@ export default class TransactionRouter {
}
protected buildRouteTransactionsRefund(): void {
- this.router.post(`/${ServerRoute.REST_TRANSACTIONS_REFUND}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.post(`/${ServerRoute.REST_TRANSACTIONS_REFUND_ACTION}`, async (req: Request, res: Response, next: NextFunction) => {
req.body.transactionsIDs = req.body.transactionIds;
await RouterUtils.handleServerAction(TransactionService.handleRefundTransactions.bind(this), ServerAction.TRANSACTIONS_REFUND, req, res, next);
});

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -493,6 +493,10 @@ export enum ServerRoute {
REST_CHARGING_PROFILE = 'charging-profiles/:id',
REST_TRANSACTIONS = 'transactions',
+ REST_TRANSACTIONS_IN_ERROR = 'transactions/status/in-error',
+ REST_TRANSACTIONS_ACTIVE = 'transactions/status/active',
+ REST_TRANSACTIONS_COMPLETED = 'transactions/status/completed',
+ REST_TRANSACTIONS_UNASSIGNED_COUNT = '/transactions/status/unassigned/count',
REST_TRANSACTION = 'transactions/:id',
REST_TRANSACTIONS_EXPORT = 'transactions/action/export',
REST_TRANSACTION_CDR = 'transactions/:id/ocpi/cdr',
@@ -500,7 +504,8 @@ export enum ServerRoute {
REST_TRANSACTION_CONSUMPTION = 'transactions/:id/consumptions',
REST_TRANSACTION_CONSUMPTIONS_REBUILD = 'transactions/:id/consumptions/rebuild',
REST_TRANSACTION_SOFT_STOP = 'transactions/:id/soft-stop',
- REST_TRANSACTIONS_REFUND = 'transactions/action/refund',
+ REST_TRANSACTIONS_REFUND_ACTION = 'transactions/action/refund',
+ REST_TRANSACTIONS_REFUND = 'transactions/status/refund',
REST_TRANSACTIONS_REFUND_EXPORT = 'transactions/status/refund/export',
REST_TRANSACTIONS_ASSIGN_USER = 'transactions/action/assign-user',
REST_TRANSACTIONS_SYNCHRONIZE_REFUNDED = 'transactions/status/refund/synchronize',

MODIFY
test/api/client/TransactionApi.ts
test/api/client/TransactionApi.ts
@@ -12,15 +12,15 @@ export default class TransactionApi extends CrudApi {
}
public async readAllActive(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll({ ...params, Status: 'active' }, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS));
+ return await super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS_ACTIVE));
}
public async readAllCompleted(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll({ ...params, Status: 'completed' }, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS));
+ return await super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS_COMPLETED));
}
public async readAllInError(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll({ ...params, Status: 'in-error' }, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS));
+ return await super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS_IN_ERROR));
}
public async readAllConsumption(params) {
@@ -46,7 +46,7 @@ export default class TransactionApi extends CrudApi {
}
public async readAllToRefund(params) {
- return await super.readAll({ ...params, Status: 'to-refund' }, TestConstants.ADVANCED_PAGING, TestConstants.DEFAULT_ORDERING, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS));
+ return await super.readAll(params, TestConstants.ADVANCED_PAGING, TestConstants.DEFAULT_ORDERING, this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTIONS_REFUND));
}
public async readAllRefundReports(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {

Rolled back transactions to URI based status filtering