From dade3237aa00c7bbc220c24f2f6294fa97dda826 Mon Sep 17 00:00:00 2001 From: Krishnan Subramanian <84348052+krishnan-aot@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:55:02 -0800 Subject: [PATCH] ORV2-3166 Allow Amendments for staff (BE) (#1734) --- .../payment/payment.service.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/vehicles/src/modules/permit-application-payment/payment/payment.service.ts b/vehicles/src/modules/permit-application-payment/payment/payment.service.ts index 3b324b2bf..1d7e78242 100644 --- a/vehicles/src/modules/permit-application-payment/payment/payment.service.ts +++ b/vehicles/src/modules/permit-application-payment/payment/payment.service.ts @@ -274,13 +274,26 @@ export class PaymentService { this.cacheManager, CacheKey.FEATURE_FLAG_TYPE, ); + const isStaffCanPayEnabled = + featureFlags?.['STAFF-CAN-PAY'] && + (featureFlags['STAFF-CAN-PAY'] as FeatureFlagValue) === + FeatureFlagValue.ENABLED; + const isRefundOrNoPayment = + createTransactionDto.transactionTypeId == TransactionType.REFUND || + createTransactionDto.paymentMethodTypeCode === + PaymentMethodTypeEnum.NO_PAYMENT; + + // If the user is a staff user, + // transacation is NOT a refund or no payment and STAFF-CAN-PAY is disabled, + // throw an error if ( doesUserHaveRole(currentUser.orbcUserRole, IDIR_USER_ROLE_LIST) && - featureFlags?.['STAFF-CAN-PAY'] && - (featureFlags['STAFF-CAN-PAY'] as FeatureFlagValue) !== - FeatureFlagValue.ENABLED + !isRefundOrNoPayment && + !isStaffCanPayEnabled ) { - throwUnprocessableEntityException('Disabled feature'); + throwUnprocessableEntityException( + 'Disabled feature - Feature flag: STAFF-CAN-PAY', + ); } if ( !doesUserHaveRole(currentUser.orbcUserRole, IDIR_USER_ROLE_LIST) &&