From 493406525a838cd56fa5c066063005a490007146 Mon Sep 17 00:00:00 2001 From: Ross McEwen Date: Wed, 22 Apr 2026 09:00:01 -0500 Subject: [PATCH] fix: exclude withdrawn/cancelled requests from duplicate check When multipleRequestsPerPeriod is false, the duplicate request check was counting withdrawn and cancelled requests, preventing users from submitting a new request after withdrawing a previous one. --- api/src/appRequest/appRequest.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/appRequest/appRequest.service.ts b/api/src/appRequest/appRequest.service.ts index 042ba5d..55ab235 100644 --- a/api/src/appRequest/appRequest.service.ts +++ b/api/src/appRequest/appRequest.service.ts @@ -235,9 +235,10 @@ export class AppRequestService extends AuthService { if (!this.mayCreate() && user.login === this.login) return { message: 'You may not create a request.' } if (!this.mayCreateOther() && user.login !== this.login) return { message: 'You may not create requests for other people.' } if (!appConfig.multipleRequestsPerPeriod) { + const activeStatuses = Object.values(AppRequestStatus).filter(s => s !== AppRequestStatus.WITHDRAWN && s !== AppRequestStatus.CANCELLED) const requests = 'internalId' in user - ? await this.svc(AppRequestServiceInternal).find({ periodIds: [period.id], userInternalIds: [user.internalId] }) - : await this.svc(AppRequestServiceInternal).find({ periodIds: [period.id], logins: [user.login] }) + ? await this.svc(AppRequestServiceInternal).find({ periodIds: [period.id], userInternalIds: [user.internalId], status: activeStatuses }) + : await this.svc(AppRequestServiceInternal).find({ periodIds: [period.id], logins: [user.login], status: activeStatuses }) if (requests.length > 0) return { message: `A request already exists in ${period.name}.`, arg: 'login' } } return undefined