diff --git a/database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql b/database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql index 3688e3dcc..df88332e4 100644 --- a/database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql +++ b/database/mssql/scripts/sampledata/dbo.ORBC_FEATURE_FLAG.Table.sql @@ -118,6 +118,99 @@ VALUES GETUTCDATE() ); + INSERT INTO + [dbo].[ORBC_FEATURE_FLAG] ( + [FEATURE_ID], + [FEATURE_KEY], + [FEATURE_VALUE], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] + ) +VALUES + ( + '6', + 'TROS', + 'ENABLED', + NULL, + N'dbo', + GETUTCDATE(), + N'dbo', + GETUTCDATE() + ); + +INSERT INTO + [dbo].[ORBC_FEATURE_FLAG] ( + [FEATURE_ID], + [FEATURE_KEY], + [FEATURE_VALUE], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] + ) +VALUES + ( + '7', + 'TROW', + 'ENABLED', + NULL, + N'dbo', + GETUTCDATE(), + N'dbo', + GETUTCDATE() + ); + + INSERT INTO + [dbo].[ORBC_FEATURE_FLAG] ( + [FEATURE_ID], + [FEATURE_KEY], + [FEATURE_VALUE], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] + ) +VALUES + ( + '8', + 'STOS', + 'ENABLED', + NULL, + N'dbo', + GETUTCDATE(), + N'dbo', + GETUTCDATE() + ); + + +INSERT INTO + [dbo].[ORBC_FEATURE_FLAG] ( + [FEATURE_ID], + [FEATURE_KEY], + [FEATURE_VALUE], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] + ) +VALUES + ( + '9', + 'MFP', + 'ENABLED', + NULL, + N'dbo', + GETUTCDATE(), + N'dbo', + GETUTCDATE() + ); + SET IDENTITY_INSERT [dbo].[ORBC_FEATURE_FLAG] OFF GO \ No newline at end of file diff --git a/vehicles/src/modules/permit-application-payment/application/application.service.ts b/vehicles/src/modules/permit-application-payment/application/application.service.ts index 5cde7daa3..2cfddbe5d 100644 --- a/vehicles/src/modules/permit-application-payment/application/application.service.ts +++ b/vehicles/src/modules/permit-application-payment/application/application.service.ts @@ -87,6 +87,9 @@ import { ReadPermitLoaDto } from './dto/response/read-permit-loa.dto'; import { CreatePermitLoaDto } from './dto/request/create-permit-loa.dto'; import { PermitLoa } from './entities/permit-loa.entity'; import { LoaDetail } from 'src/modules/special-auth/entities/loa-detail.entity'; +import { getFromCache } from '../../../common/helper/cache.helper'; +import { CacheKey } from '../../../common/enum/cache-key.enum'; +import { FeatureFlagValue } from '../../../common/enum/feature-flag-value.enum'; @Injectable() export class ApplicationService { @@ -123,6 +126,16 @@ export class ApplicationService { currentUser: IUserJWT, companyId: number, ): Promise { + const permitTypeFeatureFlag = (await getFromCache( + this.cacheManager, + CacheKey.FEATURE_FLAG_TYPE, + createApplicationDto.permitType, + )) as FeatureFlagValue; + if (permitTypeFeatureFlag !== FeatureFlagValue.ENABLED) { + throwUnprocessableEntityException( + `Feature Disabled - ${createApplicationDto.permitType}`, + ); + } const id = createApplicationDto.permitId; let fetchExistingApplication: Permit; //If permit id exists assign it to null to create new application. diff --git a/vehicles/src/modules/permit-application-payment/application/company-application.controller.ts b/vehicles/src/modules/permit-application-payment/application/company-application.controller.ts index 5a4f7c6dd..b6da814b8 100644 --- a/vehicles/src/modules/permit-application-payment/application/company-application.controller.ts +++ b/vehicles/src/modules/permit-application-payment/application/company-application.controller.ts @@ -21,6 +21,7 @@ import { ApiOperation, ApiQuery, ApiTags, + ApiUnprocessableEntityResponse, } from '@nestjs/swagger'; import { IUserJWT } from 'src/common/interface/user-jwt.interface'; import { CreateApplicationDto } from './dto/request/create-application.dto'; @@ -142,6 +143,10 @@ export class CompanyApplicationController { description: 'The Permit Application Resource', type: ReadApplicationDto, }) + @ApiUnprocessableEntityResponse({ + description: 'The Application could not be processed.', + type: ExceptionDto, + }) @Permissions({ allowedBCeIDRoles: CLIENT_USER_ROLE_LIST, allowedIdirRoles: [