Skip to content

Commit

Permalink
Merge pull request #1432 from bcgov/feature/ALCS-1698
Browse files Browse the repository at this point in the history
Bypass validation for OATS Submissions
  • Loading branch information
dhaselhan authored Feb 15, 2024
2 parents 189a065 + 1bf04be commit e96ef98
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ export class ReviewSubmitFngComponent implements OnInit, OnDestroy {
.beforeClosed()
.subscribe(async (didConfirm) => {
if (didConfirm) {
await this.applicationReviewService.complete(this.fileId!);
await this.router.navigateByUrl(`/application/${this.fileId}/review/success`);
const didComplete = await this.applicationReviewService.complete(this.fileId!);
if (didComplete) {
await this.router.navigateByUrl(`/application/${this.fileId}/review/success`);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ export class ReviewSubmitComponent implements OnInit, OnDestroy {
.beforeClosed()
.subscribe(async (didConfirm) => {
if (didConfirm) {
await this.applicationReviewService.complete(this.fileId!);
await this.router.navigateByUrl(`/application/${this.fileId}/review/success`);
const didComplete = await this.applicationReviewService.complete(this.fileId!);
if (didComplete) {
await this.router.navigateByUrl(`/application/${this.fileId}/review/success`);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,18 @@ export class ApplicationSubmissionReviewService {
}

async complete(fileId: string) {
let res;
try {
this.overlayService.showSpinner();
await firstValueFrom(this.httpClient.post<{}>(`${this.serviceUrl}/${fileId}/finish`, {}));
res = await firstValueFrom(this.httpClient.post<{}>(`${this.serviceUrl}/${fileId}/finish`, {}));
this.toastService.showSuccessToast('Application Review Submitted');
} catch (e) {
console.error(e);
this.toastService.showErrorToast('Failed to submit Application Review, please try again later');
} finally {
this.overlayService.hideSpinner();
}
return res;
}

async returnApplication(fileId: string, returnDto: ReturnApplicationSubmissionDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import { OWNER_TYPE } from '../../common/owner-type/owner-type.entity';
import { DOCUMENT_SOURCE } from '../../document/document.dto';
import { StatusEmailService } from '../../providers/email/status-email.service';
import { User } from '../../user/user.entity';
import { ApplicationSubmissionValidatorService } from '../application-submission/application-submission-validator.service';
import {
ApplicationSubmissionValidatorService,
ValidatedApplicationSubmission,
} from '../application-submission/application-submission-validator.service';
import { ApplicationSubmission } from '../application-submission/application-submission.entity';
import { ApplicationSubmissionService } from '../application-submission/application-submission.service';
import { APPLICATION_SUBMISSION_TYPES } from '../pdf-generation/generate-submission-document.service';
Expand Down Expand Up @@ -235,15 +238,15 @@ export class ApplicationSubmissionReviewController {
req.user.entity,
);

const application =
const submission =
await this.applicationSubmissionService.getForGovernmentByFileId(
fileNumber,
userLocalGovernment,
);

const applicationReview =
await this.applicationSubmissionReviewService.getByFileNumber(
application.fileNumber,
submission.fileNumber,
);

if (!applicationReview) {
Expand All @@ -261,42 +264,47 @@ export class ApplicationSubmissionReviewController {
userLocalGovernment.isFirstNation,
);

//If Submission was ETLd and never updated, we do not want to validate it
const requiresValidation = !(
submission.auditCreatedBy === 'oats_etl' && !submission.auditUpdatedBy
);

const validationResult =
await this.applicationValidatorService.validateSubmission(application);
await this.applicationValidatorService.validateSubmission(submission);

if (!validationResult.submission) {
if (requiresValidation && !validationResult.submission) {
throw new BaseServiceException(
`Invalid application found during LG Submission ${
application.fileNumber
submission.fileNumber
} ${validationResult.errors.toString()}`,
);
}

if (
application.status.statusTypeCode === SUBMISSION_STATUS.IN_REVIEW_BY_LG ||
application.status.statusTypeCode === SUBMISSION_STATUS.RETURNED_TO_LG
submission.status.statusTypeCode === SUBMISSION_STATUS.IN_REVIEW_BY_LG ||
submission.status.statusTypeCode === SUBMISSION_STATUS.RETURNED_TO_LG
) {
await this.applicationSubmissionService.submitToAlcs(
validationResult.submission,
submission as ValidatedApplicationSubmission,
req.user.entity,
completedReview,
);

const primaryContact = application.owners?.find(
(owner) => owner.uuid === application.primaryContactOwnerUuid,
const primaryContact = submission.owners?.find(
(owner) => owner.uuid === submission.primaryContactOwnerUuid,
);

if (completedReview.isAuthorized !== false) {
await this.applicationSubmissionService.updateStatus(
application,
submission,
SUBMISSION_STATUS.SUBMITTED_TO_ALC,
);

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateSUBMApplicationHtml,
status: SUBMISSION_STATUS.SUBMITTED_TO_ALC,
applicationSubmission: application,
applicationSubmission: submission,
government: userLocalGovernment,
parentType: PARENT_TYPE.APPLICATION,
primaryContact,
Expand All @@ -305,22 +313,25 @@ export class ApplicationSubmissionReviewController {
}
} else {
await this.applicationSubmissionService.updateStatus(
application,
submission,
SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG,
);

if (primaryContact) {
await this.statusEmailService.sendApplicationStatusEmail({
generateStatusHtml: generateRFFGHtml,
status: SUBMISSION_STATUS.REFUSED_TO_FORWARD_LG,
applicationSubmission: application,
applicationSubmission: submission,
government: userLocalGovernment,
parentType: PARENT_TYPE.APPLICATION,
primaryContact,
ccGovernment: true,
});
}
}
return {
success: 'true',
};
} else {
throw new BaseServiceException('Application not in correct status');
}
Expand Down

0 comments on commit e96ef98

Please sign in to comment.