Skip to content

Commit

Permalink
Code format, REVOKED template, Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot committed Oct 5, 2023
1 parent 796c378 commit 3106ec9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 35 deletions.
1 change: 1 addition & 0 deletions backend/dops/src/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum TemplateName {
PERMIT_TROS = 'PERMIT_TROS',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
PERMIT_TROS_VOID = 'PERMIT_TROS_VOID',
PERMIT_TROS_REVOKED = 'PERMIT_TROS_REVOKED',
}
1 change: 1 addition & 0 deletions backend/vehicles/src/common/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum TemplateName {
PERMIT_TROS = 'PERMIT_TROS',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
PERMIT_TROS_VOID = 'PERMIT_TROS_VOID',
PERMIT_TROS_REVOKED = 'PERMIT_TROS_REVOKED',
}
42 changes: 25 additions & 17 deletions backend/vehicles/src/modules/payment/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,18 @@ export class PaymentService {
}

private isWebTransactionPurchase(
paymentMethod: PaymentMethodType,
transactionType: TransactionType
paymentMethod: PaymentMethodType,
transactionType: TransactionType,
) {
return paymentMethod == PaymentMethodType.WEB &&
transactionType == TransactionType.PURCHASE;
return (
paymentMethod == PaymentMethodType.WEB &&
transactionType == TransactionType.PURCHASE
);
}

private assertApplicationInProgress(
paymentMethod: PaymentMethodType,
transactionType: TransactionType,
paymentMethod: PaymentMethodType,
transactionType: TransactionType,
permitStatus: ApplicationStatus,
) {
if (
Expand All @@ -165,8 +167,10 @@ export class PaymentService {
}

private isRefundOrZero(transactionType: TransactionType) {
return transactionType == TransactionType.REFUND ||
transactionType == TransactionType.ZERO_AMOUNT;
return (
transactionType == TransactionType.REFUND ||
transactionType == TransactionType.ZERO_AMOUNT
);
}

/**
Expand Down Expand Up @@ -222,7 +226,7 @@ export class PaymentService {
this.assertApplicationInProgress(
newTransaction.paymentMethodId,
newTransaction.transactionTypeId,
existingApplication.permitStatus
existingApplication.permitStatus,
);

let newPermitTransactions = new PermitTransaction();
Expand All @@ -241,10 +245,12 @@ export class PaymentService {
newPermitTransactions,
);

if (this.isWebTransactionPurchase(
newTransaction.paymentMethodId,
newTransaction.transactionTypeId
)) {
if (
this.isWebTransactionPurchase(
newTransaction.paymentMethodId,
newTransaction.transactionTypeId,
)
) {
existingApplication.permitStatus = ApplicationStatus.WAITING_PAYMENT;
existingApplication.updatedDateTime = new Date();
existingApplication.updatedUser = currentUser.userName;
Expand All @@ -264,10 +270,12 @@ export class PaymentService {
);

let url: string = undefined;
if (this.isWebTransactionPurchase(
createdTransaction.paymentMethodId,
createdTransaction.transactionTypeId
)) {
if (
this.isWebTransactionPurchase(
createdTransaction.paymentMethodId,
createdTransaction.transactionTypeId,
)
) {
url = this.generateUrl(createdTransaction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,19 @@ export class TransactionProfile extends AutomapperProfile {
),
forMember(
(d) => d.transactionOrderNumber,
mapWithArguments((createTransactionDto, { transactionOrderNumber }) => {
return transactionOrderNumber;
}),
mapWithArguments(
(createTransactionDto, { transactionOrderNumber }) => {
return transactionOrderNumber;
},
),
),
forMember(
(d) => d.totalTransactionAmount,
mapWithArguments((createTransactionDto, { totalTransactionAmount }) => {
return totalTransactionAmount;
}),
mapWithArguments(
(createTransactionDto, { totalTransactionAmount }) => {
return totalTransactionAmount;
},
),
),
);

Expand Down
2 changes: 1 addition & 1 deletion backend/vehicles/src/modules/permit/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ export class ApplicationService {
const id = !permitId ? oldPermitId : permitId;
const permit = await this.findOne(id);
let seq: string;
const approvalSourceId = 9;
const approvalSourceId = 9;
let rnd: number | string;
if (permitId) {
seq = await callDatabaseSequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export class PermitHistoryDto {
@AutoMap()
@ApiProperty({
example: 'This permit was amended because of so-and-so reason.',
description: 'Any comment/reason that was made for modification of the permit',
description:
'Any comment/reason that was made for modification of the permit',
})
comment: string;

Expand Down
7 changes: 2 additions & 5 deletions backend/vehicles/src/modules/permit/permit.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,13 @@ export class PermitController {
type: ReadPermitDto,
isArray: true,
})
@Public()
@Get("/:permitId")
@Get('/:permitId')
async getByPermitId(
@Param('permitId') permitId: string,
): Promise<ReadPermitDto> {
console.log("PermitId");
return this.permitService.findByPermitId(permitId);
}

/**
* A POST method defined with the @Post() decorator and a route of /:permitId/void
* that Voids or revokes a permit for given @param permitId by changing it's status to VOIDED|REVOKED.
Expand All @@ -262,7 +260,6 @@ export class PermitController {
@Body()
voidPermitDto: VoidPermitDto,
): Promise<ResultDto> {
console.log(voidPermitDto);
const currentUser = request.user as IUserJWT;
const directory = getDirectory(currentUser);
const permit = await this.permitService.voidPermit(
Expand Down
11 changes: 6 additions & 5 deletions backend/vehicles/src/modules/permit/permit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ export class PermitService {
* @param permitId permit id
* @returns permit with data
*/
public async findByPermitId(
permitId: string,
): Promise<ReadPermitDto> {
public async findByPermitId(permitId: string): Promise<ReadPermitDto> {
const permit = await this.findOne(permitId);
return this.classMapper.mapAsync(permit, Permit, ReadPermitDto);
}
}

/**
* Finds permits by permit number.
Expand Down Expand Up @@ -484,7 +482,10 @@ export class PermitService {
);

let dopsRequestData: DopsGeneratedDocument = {
templateName: TemplateName.PERMIT_TROS_VOID,
templateName:
voidPermitDto.status == ApplicationStatus.VOIDED
? TemplateName.PERMIT_TROS_VOID
: TemplateName.PERMIT_TROS_REVOKED,
generatedDocumentFileName: permitDataForTemplate.permitNumber,
templateData: permitDataForTemplate,
documentsToMerge: permitDataForTemplate.permitData.commodities.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET IDENTITY_INSERT [dops].[ORBC_DOCUMENT] ON
INSERT [dops].[ORBC_DOCUMENT] ([ID], [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (1, N'bcc0644f-9076-41e0-9841-4ee23e109e7a', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/bcc0644f-9076-41e0-9841-4ee23e109e7a', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'tros-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT] ([ID], [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (2, N'de4229ce-4d4a-4129-8a6b-1f7a469ab667', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/de4229ce-4d4a-4129-8a6b-1f7a469ab667', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'Payment Receipt Template.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT] ([ID], [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (3, N'D33C4B65-955F-4BBF-88B0-D59787E62A79', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/d33c4b65-955f-4bbf-88b0-d59787e62a79', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'tros-template-void-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT] ([ID], [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (4, N'95E8660A-74FC-411B-ACBD-5D43E447A5B4', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/95e8660a-74fc-411b-acbd-5d43e447a5b4', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'tros-template-revoked-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
GO

SET IDENTITY_INSERT [dops].[ORBC_DOCUMENT] OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SET IDENTITY_INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ON
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ([TEMPLATE_ID], [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (1, N'PERMIT_TROS', 1, 1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ([TEMPLATE_ID], [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (2, N'PAYMENT_RECEIPT', 1, 2, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ([TEMPLATE_ID], [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (3, N'PERMIT_TROS_VOID', 1, 3, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ([TEMPLATE_ID], [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (4, N'PERMIT_TROS_REVOKED', 1, 4, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
GO

SET IDENTITY_INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] OFF
Expand Down

0 comments on commit 3106ec9

Please sign in to comment.