Skip to content

Commit

Permalink
[FE] Simultaneous flow bugs (#2110)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- SPDBT-3547 - fix validation
- SPDBT-3535 - disable when existing appl
- SPDBT-3536 - fix model for simultaneous with diff expiry dates
- SPDBT-3539 - routing cleanup
- a couple files moved/renamed
- hide driver licence when no data
  • Loading branch information
carolcarpenter authored Jan 21, 2025
1 parent 3f694ee commit 2150968
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { LandingComponent } from './landing.component';
import { AccessDeniedComponent } from './shared/components/access-denied.component';

const routes: Routes = [
{
path: '',
component: LandingComponent,
},
{
path: AppRoutes.PERSONAL_LICENCE_APPLICATION,
loadChildren: () =>
Expand Down Expand Up @@ -51,7 +55,8 @@ const routes: Routes = [
},
{
path: '**',
component: LandingComponent,
redirectTo: AppRoutes.path(AppRoutes.LANDING),
pathMatch: 'full',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ export class CommonApplicationService {
getApplicationIsInProgress(appls: Array<MainApplicationResponse>): boolean {
return !!appls.find(
(item: MainApplicationResponse) =>
(item.applicationPortalStatusCode === ApplicationPortalStatusCode.Draft &&
item.applicationTypeCode != ApplicationTypeCode.New) ||
item.applicationPortalStatusCode === ApplicationPortalStatusCode.AwaitingPayment ||
item.applicationPortalStatusCode === ApplicationPortalStatusCode.AwaitingThirdParty ||
item.applicationPortalStatusCode === ApplicationPortalStatusCode.InProgress ||
Expand Down Expand Up @@ -992,7 +994,9 @@ export class CommonApplicationService {

if (matchingLicence) {
// expiry dates of both licences must match to be simultaneous
licence.isSimultaneousFlow = matchingLicence.linkedSoleProprietorExpiryDate === licence.expiryDate;
licence.isSimultaneousFlow =
!!matchingLicence.linkedSoleProprietorLicenceId &&
matchingLicence.linkedSoleProprietorExpiryDate === licence.expiryDate;

if (licence.hasSecurityGuardCategory) {
licence.dogAuthorization = matchingLicence.useDogs ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
// if the sole proprietor flag is 'No', then set the bizTypeCode. This is not user selected.
const soleProprietorData = {
isSoleProprietor: isSoleProprietorYesNo,
bizTypeCode: BizTypeCode.None,
bizTypeCode: null,
};

this.workerModelFormGroup.patchValue(
Expand Down Expand Up @@ -1477,34 +1477,33 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
const serviceTypeData = { serviceTypeCode: workerLicenceAppl.serviceTypeCode };
const applicationTypeData = { applicationTypeCode: workerLicenceAppl.applicationTypeCode };

const bizTypeCode = workerLicenceAppl.bizTypeCode ?? BizTypeCode.None;
let bizTypeCode = workerLicenceAppl.bizTypeCode ?? BizTypeCode.None;

const originalLicenceData = this.originalLicenceFormGroup.value;
originalLicenceData.originalBizTypeCode = bizTypeCode;

let isSoleProprietor = !!associatedLicence?.linkedSoleProprietorLicenceId;
if (!isSoleProprietor) {
isSoleProprietor = this.commonApplicationService.isBusinessLicenceSoleProprietor(bizTypeCode);
}

const soleProprietorData = {
isSoleProprietor: this.utilService.booleanToBooleanType(isSoleProprietor),
bizTypeCode,
};
let soleProprietorData = {};

let isSoleProprietorSimultaneousFlow: boolean | null = null;
if (associatedLicence) {
isSoleProprietorSimultaneousFlow = !!associatedLicence.linkedSoleProprietorLicenceId;
// Check if in a simultaneous flow
const isSoleProprietorSimultaneousFlow = this.isSimultaneousFlow(bizTypeCode, associatedLicence);
if (isSoleProprietorSimultaneousFlow) {
soleProprietorData = {
isSoleProprietor: BooleanTypeCode.Yes,
bizTypeCode,
};
} else {
isSoleProprietorSimultaneousFlow = isSoleProprietor;
// Check not a simultaneous flow, clear out any bad data
bizTypeCode = BizTypeCode.None;
soleProprietorData = {
isSoleProprietor: BooleanTypeCode.No,
bizTypeCode: null,
};
}

const originalLicenceData = this.originalLicenceFormGroup.value;
originalLicenceData.originalBizTypeCode = bizTypeCode;

console.debug('[applyLicenceIntoModel] applyLicenceIntoModel');
console.debug('[applyLicenceIntoModel] workerLicenceAppl', workerLicenceAppl);
console.debug('[applyLicenceIntoModel] associatedLicence', associatedLicence);
console.debug('[applyLicenceIntoModel] associatedExpiredLicence', associatedExpiredLicence);
console.debug('[applyLicenceIntoModel] isSoleProprietor', isSoleProprietor);
console.debug('[applyLicenceIntoModel] isSoleProprietorSimultaneousFlow', isSoleProprietorSimultaneousFlow);
console.debug('[applyLicenceIntoModel] soleProprietorData', soleProprietorData);

const hasExpiredLicence = workerLicenceAppl.hasExpiredLicence ?? false;
Expand Down Expand Up @@ -1901,7 +1900,7 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
licenceAppId: workerLicenceAppl.licenceAppId,
latestApplicationId: workerLicenceAppl.licenceAppId,
caseNumber: workerLicenceAppl.caseNumber,
soleProprietorBizAppId: workerLicenceAppl.soleProprietorBizAppId,
soleProprietorBizAppId: isSoleProprietorSimultaneousFlow ? workerLicenceAppl.soleProprietorBizAppId : null,
isSoleProprietorSimultaneousFlow,
serviceTypeData,
applicationTypeData,
Expand Down Expand Up @@ -2046,15 +2045,29 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
): Observable<any> {
const applicationTypeData = { applicationTypeCode: ApplicationTypeCode.Renewal };

// Remove data that should be re-prompted for
const soleProprietorData = {
isSoleProprietor: null,
bizTypeCode: resp.soleProprietorData.bizTypeCode,
};
const licenceTermData = {
licenceTermCode: null,
licenceTermCode: null, // Remove data that should be re-prompted for
};

// Check if in a simultaneous flow
const isSoleProprietorSimultaneousFlow = this.isSimultaneousFlow(
resp.soleProprietorData.bizTypeCode,
associatedLicence
);

let soleProprietorData = {};
if (isSoleProprietorSimultaneousFlow) {
soleProprietorData = {
isSoleProprietor: null, // Remove data that should be re-prompted for
bizTypeCode: resp.soleProprietorData.bizTypeCode,
};
} else {
soleProprietorData = {
isSoleProprietor: null, // Remove data that should be re-prompted for
bizTypeCode: null,
};
}

const [
categoryArmouredCarGuardFormGroup,
categoryBodyArmourSalesFormGroup,
Expand Down Expand Up @@ -2141,6 +2154,13 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
};
}

// If not a simultaneous flow, clear out any bad data
if (!isSoleProprietorSimultaneousFlow) {
originalLicenceData.originalBizTypeCode = BizTypeCode.None;
originalLicenceData.linkedSoleProprietorExpiryDate = null;
originalLicenceData.linkedSoleProprietorLicenceId = null;
}

this.workerModelFormGroup.patchValue(
{
licenceAppId: null,
Expand Down Expand Up @@ -2199,6 +2219,30 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
const originalLicenceData = resp.originalLicenceData;
originalLicenceData.originalLicenceTermCode = resp.licenceTermData.licenceTermCode;

// Check if in a simultaneous flow
const isSoleProprietorSimultaneousFlow = this.isSimultaneousFlow(
resp.soleProprietorData.bizTypeCode,
associatedLicence
);

let soleProprietorData = {};
if (isSoleProprietorSimultaneousFlow) {
soleProprietorData = {
isSoleProprietor: BooleanTypeCode.Yes,
bizTypeCode: resp.soleProprietorData.bizTypeCode,
};
} else {
// If not a simultaneous flow, clear out any bad data
originalLicenceData.originalBizTypeCode = BizTypeCode.None;
originalLicenceData.linkedSoleProprietorExpiryDate = null;
originalLicenceData.linkedSoleProprietorLicenceId = null;

soleProprietorData = {
isSoleProprietor: BooleanTypeCode.No,
bizTypeCode: null,
};
}

const mentalHealthConditionsData = {
isTreatedForMHC: null,
attachments: [],
Expand Down Expand Up @@ -2264,6 +2308,7 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
categorySecurityAlarmResponseFormGroup,
categorySecurityAlarmSalesFormGroup,
categorySecurityConsultantFormGroup,
soleProprietorData,
},
{
emitEvent: false,
Expand Down Expand Up @@ -2345,4 +2390,20 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
console.debug('[applyReplacementDataUpdatesToModel] licenceModel', this.workerModelFormGroup.value);
return of(this.workerModelFormGroup.value);
}

private isSimultaneousFlow(
bizTypeCode: BizTypeCode | undefined,
associatedLicence: MainLicenceResponse | LicenceResponse | undefined
): boolean {
if (!bizTypeCode && !associatedLicence) return false;

if (!associatedLicence) {
return this.commonApplicationService.isBusinessLicenceSoleProprietor(bizTypeCode!);
}

return (
!!associatedLicence?.linkedSoleProprietorLicenceId &&
associatedLicence.linkedSoleProprietorExpiryDate === associatedLicence.expiryDate
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const routes: Routes = [
component: BusinessFirstTimeUserTermsOfUseComponent,
},
{
path: '',
path: '**',
redirectTo: BusinessLicenceApplicationRoutes.path(),
pathMatch: 'full',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ControllingMemberCrcService } from '@app/core/services/controlling-memb
import { UtilService } from '@app/core/services/util.service';

@Component({
selector: 'app-step-controlling-member-summary-review',
template: `
selector: 'app-step-controlling-member-summary-review',
template: `
<app-step-section title="Application Summary" subtitle="Review your information before submitting your application">
<div class="row">
<div class="col-xl-10 col-lg-12 col-md-12 col-sm-12 mb-3 mx-auto">
Expand All @@ -20,8 +20,8 @@ import { UtilService } from '@app/core/services/util.service';
mat-mini-fab
color="primary"
class="go-to-step-button"
matTooltip="Go to Step 3"
aria-label="Go to Step 3"
matTooltip="Go to Step 1"
aria-label="Go to Step 1"
(click)="$event.stopPropagation(); onEditStep(0)"
>
<mat-icon>edit</mat-icon>
Expand Down Expand Up @@ -115,8 +115,8 @@ import { UtilService } from '@app/core/services/util.service';
mat-mini-fab
color="primary"
class="go-to-step-button"
matTooltip="Go to Step 3"
aria-label="Go to Step 3"
matTooltip="Go to Step 2"
aria-label="Go to Step 2"
(click)="$event.stopPropagation(); onEditStep(1)"
>
<mat-icon>edit</mat-icon>
Expand Down Expand Up @@ -181,7 +181,7 @@ import { UtilService } from '@app/core/services/util.service';
</div>
</div>
<ng-container *ngIf="isNew">
<ng-container *ngIf="isNew && bcDriversLicenceNumber">
<mat-divider class="mt-3 mb-2"></mat-divider>
<div class="text-minor-heading-small">BC Driver's Licence</div>
Expand All @@ -204,8 +204,8 @@ import { UtilService } from '@app/core/services/util.service';
mat-mini-fab
color="primary"
class="go-to-step-button"
matTooltip="Go to Step 2"
aria-label="Go to Step 2"
matTooltip="Go to Step 3"
aria-label="Go to Step 3"
(click)="$event.stopPropagation(); onEditStep(2)"
>
<mat-icon>edit</mat-icon>
Expand Down Expand Up @@ -296,8 +296,8 @@ import { UtilService } from '@app/core/services/util.service';
</div>
</app-step-section>
`,
styles: [
`
styles: [
`
.mat-expansion-panel {
border-radius: 0;
}
Expand Down Expand Up @@ -334,8 +334,8 @@ import { UtilService } from '@app/core/services/util.service';
height: 35px;
}
`,
],
standalone: false
],
standalone: false,
})
export class StepControllingMemberSummaryReviewComponent implements OnInit {
controllingMemberModelData: any = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const routes: Routes = [
path: ControllingMemberCrcRoutes.CONTROLLING_MEMBER_UPDATE,
component: ControllingMemberWizardUpdateComponent,
},
{
path: '**',
redirectTo: ControllingMemberCrcRoutes.CONTROLLING_MEMBER_INVITATION,
pathMatch: 'full',
},
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const routes: Routes = [
],
},
{
path: '',
path: '**',
redirectTo: MetalDealersAndRecyclersRoutes.pathMetalDealersAndRecyclers(),
pathMatch: 'full',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { CommonApplicationService } from '@app/core/services/common-application.
import { PermitApplicationService } from '@app/core/services/permit-application.service';

@Component({
selector: 'app-step-permit-summary-anonymous',
template: `
selector: 'app-step-permit-summary-anonymous',
template: `
<app-step-section title="Application Summary" subtitle="Review your information before submitting your application">
<div class="row">
<div class="col-xl-10 col-lg-12 col-md-12 col-sm-12 mb-3 mx-auto">
Expand Down Expand Up @@ -251,7 +251,7 @@ import { PermitApplicationService } from '@app/core/services/permit-application.
</div>
</div>
<div class="col-lg-6 col-md-12">
<div class="col-lg-6 col-md-12" *ngIf="bcDriversLicenceNumber">
<div class="text-label d-block text-muted">BC Driver's Licence</div>
<div class="summary-text-data">{{ bcDriversLicenceNumber | default }}</div>
</div>
Expand Down Expand Up @@ -333,8 +333,8 @@ import { PermitApplicationService } from '@app/core/services/permit-application.
</div>
</app-step-section>
`,
styles: [
`
styles: [
`
.mat-expansion-panel {
border-radius: 0;
}
Expand Down Expand Up @@ -369,8 +369,8 @@ import { PermitApplicationService } from '@app/core/services/permit-application.
height: 35px;
}
`,
],
standalone: false
],
standalone: false,
})
export class StepPermitSummaryAnonymousComponent implements OnInit {
permitModelData: any = {};
Expand Down

This file was deleted.

Loading

0 comments on commit 2150968

Please sign in to comment.