Skip to content

Commit

Permalink
feat: ORV2-2070 Bulk Issuance - Iteration 1 (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot authored Apr 5, 2024
1 parent d628937 commit fd0d545
Show file tree
Hide file tree
Showing 17 changed files with 736 additions and 285 deletions.
7 changes: 7 additions & 0 deletions dops/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ export class AppService {
CacheKey.EMAIL_TEMPLATE_ISSUE_PERMIT,
this.convertFiletoString(assetsPath + 'templates/issue-permit.email.hbs'),
);
await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_PAYMENT_RECEIPT,
this.convertFiletoString(
assetsPath + 'templates/payment-receipt.email.hbs',
),
);
await addToCache(
this.cacheManager,
CacheKey.EMAIL_TEMPLATE_COMPANY_SUSPEND,
Expand Down
19 changes: 3 additions & 16 deletions dops/src/assets/templates/issue-permit.email.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@
<br />

<hr class='solid' style='border-top: 1px solid #dbdcdc;' />
<div class='flex-container' style='margin: 1em 0;'>
<h3
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 24px;
color: #313132;
margin: 0px;'
>
onRouteBC Permits -
{{companyName}}
</h3>
</div>

<div class='flex-container' style='margin: 1em 0;'>
<p
style='font-family: BC Sans, sans-serif;
Expand All @@ -36,9 +23,9 @@
color: #313132;
margin: 0px;'
>
Attached is the permit you requested and/or a copy of the payment
receipt for your records. Please ensure that this document is forwarded
to the appropriate staff in your company.
Attached is the permit you purchased for your records. Please ensure
that this document is forwarded to the appropriate staff in your
company.
</p>
</div>

Expand Down
122 changes: 122 additions & 0 deletions dops/src/assets/templates/payment-receipt.email.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<head>
<meta charset='UTF-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<title>Permit</title>
</head>

<div>
<div class='container' style='margin: 0 2em;'>
<br />
<div>
<img src='{{whiteHeaderLogo}}' alt='motiBCLogo' />
</div>

<br />

<hr class='solid' style='border-top: 1px solid #dbdcdc;' />
<div class='flex-container' style='margin: 1em 0;'>
<p
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 16px;
color: #313132;
margin: 0px;'
>
Attached is receipt
{{receiptNumber}}
for your records.
</p>
</div>

<div class='flex-container' style='margin: 1em 0;'>
<p
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 16px;
color: #313132;
margin: 0px;'
>
You can apply for additional permits online at
<a
href='https://www.onroutebc.gov.bc.ca/'
style='color: #1a5a96;'
>https://onroutebc.gov.bc.ca/</a>.
</p>
</div>

<div class='flex-container' style='margin: 1em 0;'>
<p
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 16px;
color: #313132;
margin: 0px;'
>
<b>
THIS EMAIL BOX IS NOT MONITORED AND ANY EMAILS SENT TO IT WILL NOT BE
ANSWERED. IF YOU HAVE ANY QUESTIONS, REQUESTS, PLEASE EMAIL:
</b>
<a
href='mailto:[email protected]'
style='color: #1a5a96;'
>[email protected]</a>. If you have received this message in error,
then please contact
<a
href='mailto:[email protected]'
style='color: #1a5a96;'
>[email protected]</a>
and then immediately delete/discard this transmission, including all
attachments, without copying, distributing or disclosing same.
</p>
</div>

<hr class='solid' style='border-top: 1px solid #dbdcdc;' />
<div class='flex-container' style='margin: 1em 0;'>
<br />
<div>
<img
src='{{whiteFooterLogo}}'
alt='onRouteBCLogo'
style='margin: 0px;'
/>
</div>

<br />

<p
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 16px;
color: #313132;
margin: 0px;'
>
Have questions or need help? Check out the
<a
href='https://www2.gov.bc.ca/gov/content/transportation/vehicle-safety-enforcement/services/permitting/commercial-transport-permits'
style='color: #1a5a96;'
>Commercial Vehicle Permits</a>
page or email us at
<a
href='mailto:[email protected]'
style='color: #1a5a96;'
>[email protected]</a>.
</p>

<br />

<p
style='font-family: BC Sans, sans-serif;
font-style: normal;
font-size: 16px;
color: #313132;
margin: 0px;'
>
<a href='#' style='color: #1a5a96;'>Terms of Service</a>
and
<a href='#' style='color: #1a5a96;'>Privacy Policy</a>
</p>
</div>
<hr class='solid' style='border-top: 1px solid #dbdcdc;' />
</div>
</div>
1 change: 1 addition & 0 deletions dops/src/enum/cache-key.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum CacheKey {
TRAILER_TYPE = 'TRAILER_TYPE',
EMAIL_TEMPLATE_PROFILE_REGISTRATION = 'EMAIL_TEMPLATE_PROFILE_REGISTRATION',
EMAIL_TEMPLATE_ISSUE_PERMIT = 'EMAIL_TEMPLATE_ISSUE_PERMIT',
EMAIL_TEMPLATE_PAYMENT_RECEIPT = 'EMAIL_TEMPLATE_PAYMENT_RECEIPT',
EMAIL_TEMPLATE_COMPANY_SUSPEND = 'EMAIL_TEMPLATE_COMPANY_SUSPEND',
EMAIL_TEMPLATE_COMPANY_UNSUSPEND = 'EMAIL_TEMPLATE_COMPANY_UNSUSPEND',
EMAIL_TEMPLATE_ORBC_STYLE = 'EMAIL_TEMPLATE_ORBC_STYLE',
Expand Down
1 change: 1 addition & 0 deletions dops/src/enum/notification-template.enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum NotificationTemplate {
PROFILE_REGISTRATION = 'PROFILE_REGISTRATION',
ISSUE_PERMIT = 'ISSUE_PERMIT',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
COMPANY_SUSPEND = 'COMPANY_SUSPEND',
COMPANY_UNSUSPEND = 'COMPANY_UNSUSPEND',
}
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 CHES: ${JSON.stringify(errorData, null, 2)}`,
`Error response from CDOGS: ${JSON.stringify(errorData, null, 2)}`,
);
} else {
this.logger.error(error?.message, error?.stack);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import {
Allow,
ArrayMinSize,
IsEmail,
IsEnum,
Expand Down Expand Up @@ -52,6 +51,6 @@ export class NotificationDto {
},
description: 'Data to be inserted into the template',
})
@Allow()
@IsOptional()
data: object;
}
2 changes: 2 additions & 0 deletions dops/src/modules/notification/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export class NotificationService {
switch (templateName) {
case NotificationTemplate.ISSUE_PERMIT:
return CacheKey.EMAIL_TEMPLATE_ISSUE_PERMIT;
case NotificationTemplate.PAYMENT_RECEIPT:
return CacheKey.EMAIL_TEMPLATE_PAYMENT_RECEIPT;
case NotificationTemplate.PROFILE_REGISTRATION:
return CacheKey.EMAIL_TEMPLATE_PROFILE_REGISTRATION;
case NotificationTemplate.COMPANY_SUSPEND:
Expand Down
1 change: 1 addition & 0 deletions vehicles/src/common/enum/notification-template.enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum NotificationTemplate {
PROFILE_REGISTRATION = 'PROFILE_REGISTRATION',
ISSUE_PERMIT = 'ISSUE_PERMIT',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
COMPANY_SUSPEND = 'COMPANY_SUSPEND',
COMPANY_UNSUSPEND = 'COMPANY_UNSUSPEND',
}
4 changes: 2 additions & 2 deletions vehicles/src/common/helper/format-template-data.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const formatTemplateData = (
permit: Permit,
fullNames: FullNamesForDgen,
companyInfo: Company,
revisitionHisotry: Permit[],
revisionHistory?: Permit[],
) => {
// Create a new template object that includes the formatted values used in the templated word documents
const template: PermitTemplateData = {
Expand Down Expand Up @@ -89,7 +89,7 @@ export const formatTemplateData = (
template.permitData.feeSummary =
template.permitData.permitDuration.toString(); // TODO: get from frontend

revisitionHisotry.forEach((revision) => {
revisionHistory?.forEach((revision) => {
if (
revision.permitStatus == ApplicationStatus.ISSUED ||
revision.permitStatus == ApplicationStatus.VOIDED ||
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions vehicles/src/common/interface/notification.interface.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { NotificationTemplate } from '../enum/notification-template.enum';
import { CompanyDataNotification } from './company-data.notification.interface';
import { IssuePermitDataNotification } from './issue-permit-data.notification.interface';
import { ProfileRegistrationDataNotification } from './profile-registration-data.notification.interface';

export interface INotification {
subject: string;
to: string[];
cc?: string[];
templateName: NotificationTemplate;
data:
| CompanyDataNotification
| ProfileRegistrationDataNotification
| IssuePermitDataNotification;
data?: CompanyDataNotification | ProfileRegistrationDataNotification;
}
2 changes: 1 addition & 1 deletion vehicles/src/modules/common/dops.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class DopsService {
this.logger.error(error?.message, error?.stack);
}
throw new InternalServerErrorException(
'Error generating while sending notification',
'Error while sending notification',
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,26 @@ export class ApplicationController {
);
}

/**Bulk issuance would require changes in issuePermit service method with
* respect to Document generation etc. At the moment, it is not handled and
* only single permit Id must be passed.
*
*/
const result = await this.applicationService.issuePermit(
const result = await this.applicationService.issuePermits(
currentUser,
issuePermitDto.applicationIds[0],
issuePermitDto.applicationIds,
issuePermitDto.companyId,
);

if (result?.success?.length) {
await Promise.allSettled([
this.applicationService.generatePermitDocuments(
currentUser,
result.success,
issuePermitDto.companyId,
),
this.applicationService.generateReceiptDocuments(
currentUser,
result.success,
issuePermitDto.companyId,
),
]);
}
return result;
}

Expand Down
Loading

0 comments on commit fd0d545

Please sign in to comment.