Skip to content

Commit

Permalink
[FE] various bug fixes (#2000)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- Private Investigator bug fixes.
- Ignore 'expired licence' data when not in Resume flow.
- Simultaneous bugs
- Minor ui updates
  • Loading branch information
carolcarpenter authored Dec 19, 2024
1 parent ec1ea9d commit 45a743b
Show file tree
Hide file tree
Showing 22 changed files with 1,409 additions and 1,331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export abstract class BusinessApplicationHelper extends CommonApplicationHelper
soleProprietorLicenceAppId: new FormControl(''),
soleProprietorCategoryCodes: new FormControl(''),
soleProprietorLicenceHolderName: new FormControl(''),
soleProprietorLicenceHolderId: new FormControl(''),
soleProprietorLicenceNumber: new FormControl(''),
soleProprietorLicenceExpiryDate: new FormControl(''),
soleProprietorLicenceStatusCode: new FormControl(''),
Expand Down Expand Up @@ -329,7 +330,7 @@ export abstract class BusinessApplicationHelper extends CommonApplicationHelper
FormControlValidators.requiredValue(SPD_CONSTANTS.address.countryCA, SPD_CONSTANTS.address.countryCanada),
]),
branchManager: new FormControl('', [FormControlValidators.required]),
branchPhoneNumber: new FormControl(''),
branchPhoneNumber: new FormControl('', [FormControlValidators.required]),
branchEmailAddr: new FormControl('', [FormControlValidators.email]),
});

Expand Down Expand Up @@ -540,11 +541,20 @@ export abstract class BusinessApplicationHelper extends CommonApplicationHelper
}

if (categoryData.PrivateInvestigator) {
const privateInvestigatorData = businessModelFormValue.categoryPrivateInvestigatorFormGroup;
privateInvestigatorSwlInfo = {
contactId: privateInvestigatorData.managerContactId,
licenceId: privateInvestigatorData.managerLicenceId,
};
const isSoleProprietorSimultaneousFlow = businessModelFormValue.isSoleProprietorSimultaneousFlow;
if (!isSoleProprietorSimultaneousFlow && this.isSoleProprietor(bizTypeCode)) {
// if sole proprietor, populate the PI info from the associated swl in the profile
privateInvestigatorSwlInfo = {
contactId: businessInformationData.soleProprietorLicenceHolderId,
licenceId: businessInformationData.soleProprietorLicenceId,
};
} else {
const privateInvestigatorData = businessModelFormValue.categoryPrivateInvestigatorFormGroup;
privateInvestigatorSwlInfo = {
contactId: privateInvestigatorData.managerContactId,
licenceId: privateInvestigatorData.managerLicenceId,
};
}
} else {
this.clearPrivateInvestigatorModelData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
soleProprietorLicenceId: null,
soleProprietorLicenceAppId: null,
soleProprietorLicenceHolderName: null,
soleProprietorLicenceHolderId: null,
soleProprietorLicenceNumber: null,
soleProprietorLicenceExpiryDate: null,
soleProprietorLicenceStatusCode: null,
Expand Down Expand Up @@ -1126,9 +1127,10 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
const associatedLicence = resps[1];
const businessLicenceAppl = resps[2];

// console.debug('************* businessProfile', businessProfile);
// console.debug('************* associatedLicence', associatedLicence);
// console.debug('************* businessLicenceAppl', businessLicenceAppl);
// remove reference to expired licence - data is only used in the Resume flow.
businessLicenceAppl.expiredLicenceId = null;
businessLicenceAppl.expiredLicenceNumber = null;
businessLicenceAppl.hasExpiredLicence = false;

return this.applyLicenceProfileIntoModel({
businessProfile,
Expand Down Expand Up @@ -1350,6 +1352,11 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
const businessProfile = resps[1];
const businessMembers = isSoleProprietor ? undefined : resps[2];

// remove reference to expired licence - data is only used in the Resume flow.
businessLicenceAppl.expiredLicenceId = null;
businessLicenceAppl.expiredLicenceNumber = null;
businessLicenceAppl.hasExpiredLicence = false;

return this.loadBusinessApplAndProfile({
applicationTypeCode,
businessLicenceAppl,
Expand Down Expand Up @@ -1445,7 +1452,10 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
}

let soleProprietorSwlLicence: LicenceResponse | undefined = undefined;
if (businessProfile.soleProprietorSwlContactInfo?.licenceId) {
if (
this.isSoleProprietor(businessProfile.bizTypeCode) &&
businessProfile.soleProprietorSwlContactInfo?.licenceId
) {
soleProprietorSwlLicence = licenceResponses.find(
(item: LicenceResponse) => item.licenceId === businessProfile.soleProprietorSwlContactInfo?.licenceId
);
Expand All @@ -1460,6 +1470,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {

return this.applyLicenceAndProfileIntoModel({
businessLicenceAppl,
applicationTypeCode,
businessProfile,
associatedLicence,
associatedExpiredLicence,
Expand All @@ -1473,6 +1484,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {

return this.applyLicenceAndProfileIntoModel({
businessLicenceAppl,
applicationTypeCode,
businessProfile,
associatedLicence,
brandingDocumentInfos,
Expand Down Expand Up @@ -1538,6 +1550,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
*/
private applyLicenceAndProfileIntoModel({
businessLicenceAppl,
applicationTypeCode,
businessProfile,
associatedLicence,
associatedExpiredLicence,
Expand All @@ -1546,6 +1559,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
brandingDocumentInfos,
}: {
businessLicenceAppl: BizLicAppResponse;
applicationTypeCode: ApplicationTypeCode;
businessProfile: BizProfileResponse;
associatedLicence?: LicenceResponse | MainLicenceResponse;
associatedExpiredLicence?: LicenceResponse;
Expand All @@ -1558,7 +1572,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {

return this.applyLicenceProfileIntoModel({
businessProfile,
applicationTypeCode: businessLicenceAppl.applicationTypeCode,
applicationTypeCode,
soleProprietorSwlLicence,
soleProprietorSWLAppId: businessLicenceAppl.soleProprietorSWLAppId ?? undefined,
}).pipe(
Expand Down Expand Up @@ -1799,6 +1813,10 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
isSoleProprietorSimultaneousFlow = !!soleProprietorSWLAppId;
}

// console.debug('*********** isSoleProprietorSimultaneousFlow', isSoleProprietorSimultaneousFlow);
// console.debug('*********** associatedLicence', associatedLicence);
// console.debug('*********** soleProprietorSWLAppId', soleProprietorSWLAppId);

const isSoleProprietorSimultaneousSWLAnonymous = isSoleProprietorSimultaneousFlow
? businessLicenceAppl.soleProprietorSWLAppOriginTypeCode != ApplicationOriginTypeCode.Portal
: null;
Expand Down Expand Up @@ -1871,6 +1889,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
soleProprietorLicenceAppId: null,
soleProprietorCategoryCodes: null,
soleProprietorLicenceHolderName: null,
soleProprietorLicenceHolderId: null,
soleProprietorLicenceNumber: null,
soleProprietorLicenceExpiryDate: null,
soleProprietorLicenceStatusCode: null,
Expand All @@ -1884,6 +1903,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
businessInformationData.soleProprietorLicenceAppId = soleProprietorSwlLicence.licenceAppId;
businessInformationData.soleProprietorCategoryCodes = soleProprietorSwlLicence.categoryCodes;
businessInformationData.soleProprietorLicenceHolderName = soleProprietorSwlLicence.licenceHolderName;
businessInformationData.soleProprietorLicenceHolderId = soleProprietorSwlLicence.licenceHolderId;
businessInformationData.soleProprietorLicenceNumber = soleProprietorSwlLicence.licenceNumber;
businessInformationData.soleProprietorLicenceExpiryDate = soleProprietorSwlLicence.expiryDate;
businessInformationData.soleProprietorLicenceStatusCode = soleProprietorSwlLicence.licenceStatusCode;
Expand Down Expand Up @@ -1983,14 +2003,18 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
});
}

// console.debug('applicationTypeCode', applicationTypeCode);
// console.debug('soleProprietorSwlLicence?.licenceAppId', soleProprietorSwlLicence?.licenceAppId);
// console.debug('soleProprietorSWLAppId', soleProprietorSWLAppId);

// if there is no applicationTypeCode, then we are supporting just loading the profile
if (applicationTypeCode) {
if (soleProprietorSwlLicence?.licenceAppId) {
// business licence is sole proprietor
return this.applyBusinessLicenceSoleProprietorSelection(soleProprietorSwlLicence);
} else if (soleProprietorSWLAppId) {
if (soleProprietorSWLAppId && applicationTypeCode != ApplicationTypeCode.Update) {
// using sole proprietor simultaneous flow
return this.applyBusinessLicenceSoleProprietorSwl(soleProprietorSWLAppId);
} else if (soleProprietorSwlLicence?.licenceAppId) {
// business licence is sole proprietor (licence selected in profile)
return this.applyBusinessLicenceSoleProprietorSelection(soleProprietorSwlLicence);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ export class PermitApplicationService extends PermitApplicationHelper {
const permitLicenceAppl = resps[0];
const applicantProfile = resps[1];

// remove reference to expired licence - data is only used in the Resume authenticated flow.
permitLicenceAppl.expiredLicenceId = null;
permitLicenceAppl.expiredLicenceNumber = null;
permitLicenceAppl.hasExpiredLicence = false;

return this.applyPermitAndProfileIntoModel({
permitLicenceAppl,
applicantProfile,
Expand Down Expand Up @@ -976,8 +981,13 @@ export class PermitApplicationService extends PermitApplicationHelper {
this.reset();

return this.permitService.apiPermitApplicationGet().pipe(
switchMap((resp: PermitLicenceAppResponse) => {
return this.applyPermitAndProfileIntoModel({ permitLicenceAppl: resp, associatedLicence });
switchMap((permitLicenceAppl: PermitLicenceAppResponse) => {
// remove reference to expired licence - data is only used in the Resume authenticated flow.
permitLicenceAppl.expiredLicenceId = null;
permitLicenceAppl.expiredLicenceNumber = null;
permitLicenceAppl.hasExpiredLicence = false;

return this.applyPermitAndProfileIntoModel({ permitLicenceAppl, associatedLicence });
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,11 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
const workerLicenceAppl = resps[0];
const applicantProfile = resps[1];

// remove reference to expired licence - data is only used in the Resume authenticated flow.
workerLicenceAppl.expiredLicenceId = null;
workerLicenceAppl.expiredLicenceNumber = null;
workerLicenceAppl.hasExpiredLicence = false;

return this.loadLicenceAppAndProfile(workerLicenceAppl, applicantProfile, associatedLicence);
})
);
Expand Down Expand Up @@ -1138,6 +1143,11 @@ export class WorkerApplicationService extends WorkerApplicationHelper {
associatedLicence
).pipe(
switchMap((_resp: any) => {
// remove reference to expired licence - data is only used in the Resume authenticated flow.
workerLicenceAppl.expiredLicenceId = null;
workerLicenceAppl.expiredLicenceNumber = null;
workerLicenceAppl.hasExpiredLicence = false;

return this.applyLicenceIntoModel(workerLicenceAppl, associatedLicence);
})
);
Expand Down Expand Up @@ -1472,11 +1482,7 @@ export class WorkerApplicationService extends WorkerApplicationHelper {

let isSoleProprietorSimultaneousFlow: boolean | null = null;
if (associatedLicence) {
if ('isSimultaneousFlow' in associatedLicence) {
isSoleProprietorSimultaneousFlow = associatedLicence.isSimultaneousFlow;
} else {
isSoleProprietorSimultaneousFlow = !!associatedLicence.linkedSoleProprietorLicenceId;
}
isSoleProprietorSimultaneousFlow = !!associatedLicence.linkedSoleProprietorLicenceId;
} else {
isSoleProprietorSimultaneousFlow = isSoleProprietor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MainApplicationResponse } from '@app/core/services/common-application.s
<div class="mb-3" *ngIf="applicationsDataSource.data.length > 0">
<div class="text-primary-color fs-5 py-3">Applications</div>
<div class="row summary-card-section summary-card-section__orange m-0">
<div class="row summary-card-section summary-card-section__orange m-0 pt-2">
<div class="col-12">
<mat-table [dataSource]="applicationsDataSource" class="draft-table" [multiTemplateDataRows]="true">
<ng-container matColumnDef="serviceTypeCode">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import { StepsBusinessLicenceSelectionComponent } from './steps-business-licence
></app-steps-business-licence-review>
</mat-step>
<mat-step completed="false">
<mat-step completed="false" *ngIf="showPayStep">
<ng-template matStepLabel>Pay</ng-template>
</mat-step>
</mat-stepper>
Expand All @@ -127,6 +127,7 @@ export class BusinessLicenceWizardRenewalComponent extends BaseWizardComponent i
bizTypeCode!: BizTypeCode;
isBusinessLicenceSoleProprietor!: boolean;
isControllingMembersWithoutSwlExist!: boolean;
showPayStep!: boolean;

private businessModelValueChangedSubscription!: Subscription;

Expand Down Expand Up @@ -180,6 +181,10 @@ export class BusinessLicenceWizardRenewalComponent extends BaseWizardComponent i
'isControllingMembersWithoutSwlExist'
)?.value;

this.showPayStep =
this.isBusinessLicenceSoleProprietor ||
(!this.isBusinessLicenceSoleProprietor && !this.isControllingMembersWithoutSwlExist);

this.isFormValid = _resp;

this.updateCompleteStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ import { BooleanTypeCode } from 'src/app/core/code-types/model-desc.models';
</div>
</div>
<ng-container *ngIf="isPrivateInvestigator">
<ng-container *ngIf="isPrivateInvestigator && !isBusinessLicenceSoleProprietor">
<mat-divider class="mt-3 mb-2"></mat-divider>
<div class="text-minor-heading-small">Private Investigator Information</div>
<div class="row mt-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ export class CommonControllingMembersComponent implements OnInit, LicenceChildSt
}

isAllowUpdateInvitation(inviteStatusCode?: ApplicationInviteStatusCode): boolean {
return inviteStatusCode === ApplicationInviteStatusCode.Completed;
return this.canSendUpdateInvitations && inviteStatusCode === ApplicationInviteStatusCode.Completed;
}

onSendUpdateInvitation(member: NonSwlContactInfo): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import { BranchResponse } from './business-bc-branches.component';
<div class="col-md-6">
<mat-form-field>
<mat-label>Manager's Phone Number <span class="optional-label">(optional)</span></mat-label>
<mat-label>Manager's Phone Number</mat-label>
<input
matInput
formControlName="branchPhoneNumber"
[errorStateMatcher]="matcher"
maxlength="30"
appPhoneNumberTransform
/>
<mat-error *ngIf="form.get('branchPhoneNumber')?.hasError('required')">This is required</mat-error>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ export class StepBusinessLicenceCategoryComponent implements OnInit, LicenceChil
valid2 = this.categoryArmouredCarGuardFormGroup.valid;
}
let valid3 = true;
if (this.PrivateInvestigator.value) {
if (!this.isBusinessLicenceSoleProprietor && this.PrivateInvestigator.value) {
this.categoryPrivateInvestigatorFormGroup.markAllAsTouched();
valid3 = this.categoryPrivateInvestigatorFormGroup.valid;
}
Expand Down
Loading

0 comments on commit 45a743b

Please sign in to comment.