Skip to content

Commit

Permalink
Merge branch 'main' into ORV2-2161
Browse files Browse the repository at this point in the history
  • Loading branch information
cberg-aot authored Apr 9, 2024
2 parents d1b17b2 + 0fd58f3 commit 6c0b061
Show file tree
Hide file tree
Showing 26 changed files with 1,408 additions and 853 deletions.
1 change: 0 additions & 1 deletion database/mssql/scripts/versions/revert/v_26_ddl_revert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ ELSE BEGIN
PRINT 'The database update failed'
END
GO

2 changes: 1 addition & 1 deletion dops/src/modules/common/cdogs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class CdogsService {
if (error.response) {
const errorData = error.response.data;
this.logger.error(
`Error response from CDOGS: ${JSON.stringify(errorData, null, 2)}`,
`Error response from CDOGS - status: ${error.response?.status} data: ${JSON.stringify(errorData, null, 2)}`,
);
} else {
this.logger.error(error?.message, error?.stack);
Expand Down
4 changes: 4 additions & 0 deletions vehicles/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { CompanySuspendModule } from './modules/company-user-management/company-
import { PermitModule } from './modules/permit-application-payment/permit/permit.module';
import { ApplicationModule } from './modules/permit-application-payment/application/application.module';
import { PaymentModule } from './modules/permit-application-payment/payment/payment.module';
import { PermitReceiptDocumentModule } from './modules/permit-application-payment/permit-receipt-document/permit-receipt-document.module';
import { ShoppingCartModule } from './modules/shopping-cart/shopping-cart.module';

const envPath = path.resolve(process.cwd() + '/../');

Expand Down Expand Up @@ -91,6 +93,8 @@ const envPath = path.resolve(process.cwd() + '/../');
PendingUsersModule,
AuthModule,
PaymentModule,
ShoppingCartModule,
PermitReceiptDocumentModule,
ApplicationModule, //! Application Module should be imported before PermitModule to avoid URI conflict
PermitModule,
FeatureFlagsModule,
Expand Down
4 changes: 4 additions & 0 deletions vehicles/src/common/enum/notification-type.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum NotificationType {
EMAIL_PERMIT = 'EMAIL_PERMIT',
EMAIL_RECEIPT = 'EMAIL_RECEIPT',
}
37 changes: 37 additions & 0 deletions vehicles/src/common/helper/permit-application.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import { callDatabaseSequence } from './database.helper';
import { PermitApplicationOrigin as PermitApplicationOriginEnum } from '../enum/permit-application-origin.enum';
import { PermitApprovalSource as PermitApprovalSourceEnum } from '../enum/permit-approval-source.enum';
import { randomInt } from 'crypto';
import { Directory } from '../enum/directory.enum';
import { doesUserHaveAuthGroup } from './auth.helper';
import {
IDIR_USER_AUTH_GROUP_LIST,
UserAuthGroup,
} from '../enum/user-auth-group.enum';
import { PPC_FULL_TEXT } from '../constants/api.constant';
import { User } from '../../modules/company-user-management/users/entities/user.entity';

/**
* Fetches and resolves various types of names associated with a permit using cache.
Expand Down Expand Up @@ -189,3 +197,32 @@ export const generatePermitNumber = async (
const permitNumber = `P${approvalSourceId}-${sequence}-${randomNumber}${revision}`;
return permitNumber;
};

/**
* Determines the appropriate display name for the applicant based on their directory type and the
* current user's authorization group.
* - For users from the IDIR directory, it returns the user's username if the current user has the
* correct authorization group. Otherwise, it returns a predefined full text constant.
* - For users from other directories, it returns the user's first and last name, concatenated.
* @param applicationOwner The user object representing the owner of the application.
* @param currentUserAuthGroup The authorization group of the current user.
* @returns The display name of the application owner as a string.
*/
export const getApplicantDisplay = (
applicationOwner: User,
currentUserAuthGroup: UserAuthGroup,
): string => {
if (applicationOwner?.directory === Directory.IDIR) {
if (
doesUserHaveAuthGroup(currentUserAuthGroup, IDIR_USER_AUTH_GROUP_LIST)
) {
return applicationOwner?.userName;
} else {
return PPC_FULL_TEXT;
}
} else {
const firstName = applicationOwner?.userContact?.firstName ?? '';
const lastName = applicationOwner?.userContact?.lastName ?? '';
return (firstName + ' ' + lastName).trim();
}
};
26 changes: 10 additions & 16 deletions vehicles/src/modules/common/dto/request/create-notification.dto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import {
ArrayMinSize,
IsEmail,
IsOptional,
IsString,
Length,
} from 'class-validator';
import { ArrayMinSize, IsEmail, IsEnum } from 'class-validator';
import { NotificationType } from '../../../../common/enum/notification-type.enum';

export class CreateNotificationDto {
@ApiProperty({
Expand All @@ -21,14 +16,13 @@ export class CreateNotificationDto {

@AutoMap()
@ApiProperty({
description: 'The fax number to send the notification to.',
required: false,
maxLength: 20,
minLength: 10,
example: '9999999999',
enum: NotificationType,
required: true,
description: 'The type of notification.',
isArray: true,
example: [NotificationType.EMAIL_PERMIT, NotificationType.EMAIL_RECEIPT],
})
@IsOptional()
@IsString()
@Length(10, 20)
fax?: string;
@IsEnum(NotificationType, { each: true })
@ArrayMinSize(1)
notificationType: NotificationType[];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { NotificationType } from '../../../../common/enum/notification-type.enum';

export class ReadNotificationDto {
notificationType?: NotificationType;
message: string;
transactionId: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { DeleteDto } from '../../common/dto/response/delete.dto';
import { PermitApplicationOrigin } from '../../../common/enum/permit-application-origin.enum';
import { ReadApplicationMetadataDto } from './dto/response/read-application-metadata.dto';
import { doesUserHaveAuthGroup } from '../../../common/helper/auth.helper';
import { PermitReceiptDocumentService } from '../permit-receipt-document/permit-receipt-document.service';

@ApiBearerAuth()
@ApiTags('Permit Application')
Expand All @@ -63,7 +64,10 @@ import { doesUserHaveAuthGroup } from '../../../common/helper/auth.helper';
type: ExceptionDto,
})
export class ApplicationController {
constructor(private readonly applicationService: ApplicationService) {}
constructor(
private readonly applicationService: ApplicationService,
private readonly permitReceiptDocumentService: PermitReceiptDocumentService,
) {}
/**
* Create Permit application
* @param request
Expand Down Expand Up @@ -268,12 +272,12 @@ export class ApplicationController {

if (result?.success?.length) {
await Promise.allSettled([
this.applicationService.generatePermitDocuments(
this.permitReceiptDocumentService.generatePermitDocuments(
currentUser,
result.success,
issuePermitDto.companyId,
),
this.applicationService.generateReceiptDocuments(
this.permitReceiptDocumentService.generateReceiptDocuments(
currentUser,
result.success,
issuePermitDto.companyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PaymentModule } from '../payment/payment.module';
import { PermitData } from '../permit/entities/permit-data.entity';
import { PermitType } from '../permit/entities/permit-type.entity';
import { Permit } from '../permit/entities/permit.entity';
import { PermitReceiptDocumentModule } from '../permit-receipt-document/permit-receipt-document.module';

@Module({
imports: [
Expand All @@ -20,6 +21,7 @@ import { Permit } from '../permit/entities/permit.entity';
PermitApprovalSource,
]),
PaymentModule,
PermitReceiptDocumentModule,
],
controllers: [ApplicationController],
providers: [ApplicationService, ApplicationProfile],
Expand Down
Loading

0 comments on commit 6c0b061

Please sign in to comment.