Skip to content

Commit

Permalink
feat: ORV2 2070 : Document generation and notification services - Fin…
Browse files Browse the repository at this point in the history
…al Iteration (#1322)
  • Loading branch information
praju-aot authored Apr 9, 2024
1 parent ba076e0 commit 581ecf3
Show file tree
Hide file tree
Showing 12 changed files with 668 additions and 821 deletions.
2 changes: 2 additions & 0 deletions vehicles/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ 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 @@ -93,6 +94,7 @@ const envPath = path.resolve(process.cwd() + '/../');
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',
}
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 581ecf3

Please sign in to comment.