Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] simultaneous flow updates #1603

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface BizLicAppSubmitRequest {
reprint?: boolean | null;
serviceTypeCode?: ServiceTypeCode;
soleProprietorSWLAppId?: string | null;
soleProprietorSWLAppOriginTypeCode?: ApplicationOriginTypeCode;
submittedByPortalUserId?: string | null;
useDogs?: boolean | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface BizLicAppUpsertRequest {
privateInvestigatorSwlInfo?: PrivateInvestigatorSwlContactInfo;
serviceTypeCode?: ServiceTypeCode;
soleProprietorSWLAppId?: string | null;
soleProprietorSWLAppOriginTypeCode?: ApplicationOriginTypeCode;
submittedByPortalUserId?: string | null;
useDogs?: boolean | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface LicenceResponse {
licenceNumber?: string | null;
licenceStatusCode?: LicenceStatusCode;
licenceTermCode?: LicenceTermCode;
linkedSoleProprietorExpiryDate?: string | null;
linkedSoleProprietorLicenceId?: string | null;
nameOnCard?: string | null;
permitOtherRequiredReason?: string | null;
rationalDocumentInfos?: Array<Document> | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export class BaseWizardStepComponent implements LicenceStepperStepComponent {
this.cancelAndExit.emit(true);
}

onExit(): void {
this.commonApplicationService.cancelAndLoseChanges();
}

onNextReview(formNumber: number): void {
const isValid = this.dirtyForm(formNumber);
if (!isValid) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export const SPD_CONSTANTS = {
requestForFingerprintingForm: './assets/files/SPD Request for Fingerprinting Form.pdf',
},
address: {
provinceBC: 'British Columbia',
provinceBC: 'BC',
provinceBritishColumbia: 'British Columbia',
countryCA: 'CA',
countryCanada: 'Canada',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface MainApplicationResponse extends LicenceAppListResponse {
isExpiryWarning: boolean;
isExpiryError: boolean;
isControllingMemberWarning?: boolean;
isSoleProprietorSimultaneousFlow?: boolean;
isSimultaneousFlow: boolean;
}

export interface MainLicenceResponse extends LicenceResponse {
Expand All @@ -79,6 +79,7 @@ export interface MainLicenceResponse extends LicenceResponse {
dogAuthorizationExpiryDate: string | null;
restraintAuthorization: boolean;
restraintAuthorizationExpiryDate: string | null;
isSimultaneousFlow: boolean;
}

@Injectable({
Expand Down Expand Up @@ -253,13 +254,7 @@ export class ApplicationService {

const apis: Observable<any>[] = [];
basicLicenceResps.forEach((resp: LicenceBasicResponse) => {
if (
resp.licenceStatusCode === LicenceStatusCode.Active &&
resp.categoryCodes &&
resp.categoryCodes.findIndex(
(item: WorkerCategoryTypeCode) => item === WorkerCategoryTypeCode.SecurityGuard
) >= 0
) {
if (resp.licenceStatusCode === LicenceStatusCode.Active) {
apis.push(
this.licenceService.apiLicencesLicenceIdGet({
licenceId: resp.licenceId!,
Expand Down Expand Up @@ -340,7 +335,7 @@ export class ApplicationService {
.pipe(
switchMap((resp: BizLicAppResponse) => {
response.forEach((item: MainApplicationResponse) => {
item.isSoleProprietorSimultaneousFlow = !!resp.soleProprietorSWLAppId; // TODO populate Simultaneous
item.isSimultaneousFlow = !!resp.soleProprietorSWLAppId; // TODO populate Simultaneous
});

return of(response);
Expand Down Expand Up @@ -386,13 +381,7 @@ export class ApplicationService {

const apis: Observable<any>[] = [];
basicLicenceResps.forEach((resp: LicenceBasicResponse) => {
if (
resp.licenceStatusCode === LicenceStatusCode.Active &&
resp.categoryCodes &&
resp.categoryCodes.findIndex(
(item: WorkerCategoryTypeCode) => item === WorkerCategoryTypeCode.SecurityGuard
) >= 0
) {
if (resp.licenceStatusCode === LicenceStatusCode.Active) {
apis.push(
this.licenceService.apiLicencesLicenceIdGet({
licenceId: resp.licenceId!,
Expand Down Expand Up @@ -866,6 +855,7 @@ export class ApplicationService {
licence.isRenewalPeriod = false;
licence.isUpdatePeriod = false;
licence.isReplacementPeriod = false;
licence.isSimultaneousFlow = false;

const today = moment().startOf('day');

Expand All @@ -880,24 +870,28 @@ export class ApplicationService {
(item: WorkerCategoryTypeCode) => item === WorkerCategoryTypeCode.SecurityGuard
) >= 0;

if (licence.hasSecurityGuardCategory && matchingLicence) {
licence.dogAuthorization = matchingLicence.useDogs ?? false;
if (licence.dogAuthorization) {
const dogDocumentInfos = licence.dogDocumentInfos ?? [];
if (dogDocumentInfos.length > 0) {
// get first document with an expiry date
const doc = dogDocumentInfos.find((item: Document) => item.expiryDate);
licence.dogAuthorizationExpiryDate = doc?.expiryDate ?? null;
if (matchingLicence) {
licence.isSimultaneousFlow = matchingLicence.linkedSoleProprietorExpiryDate === licence.expiryDate;

if (licence.hasSecurityGuardCategory) {
licence.dogAuthorization = matchingLicence.useDogs ?? false;
if (licence.dogAuthorization) {
const dogDocumentInfos = licence.dogDocumentInfos ?? [];
if (dogDocumentInfos.length > 0) {
// get first document with an expiry date
const doc = dogDocumentInfos.find((item: Document) => item.expiryDate);
licence.dogAuthorizationExpiryDate = doc?.expiryDate ?? null;
}
}
}

licence.restraintAuthorization = matchingLicence.carryAndUseRestraints ?? false;
if (licence.restraintAuthorization) {
const restraintsDocumentInfos = licence.restraintsDocumentInfos ?? [];
if (restraintsDocumentInfos.length > 0) {
// get first document with an expiry date
const doc = restraintsDocumentInfos.find((item: Document) => item.expiryDate);
licence.restraintAuthorizationExpiryDate = doc?.expiryDate ?? null;
licence.restraintAuthorization = matchingLicence.carryAndUseRestraints ?? false;
if (licence.restraintAuthorization) {
const restraintsDocumentInfos = licence.restraintsDocumentInfos ?? [];
if (restraintsDocumentInfos.length > 0) {
// get first document with an expiry date
const doc = restraintsDocumentInfos.find((item: Document) => item.expiryDate);
licence.restraintAuthorizationExpiryDate = doc?.expiryDate ?? null;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,14 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
province: new FormControl('', [
FormControlValidators.required,
FormControlValidators.requiredValue(SPD_CONSTANTS.address.provinceBC),
FormControlValidators.requiredValue(SPD_CONSTANTS.address.provinceBritishColumbia),
]),
country: new FormControl('', [
FormControlValidators.required,
FormControlValidators.requiredValue(SPD_CONSTANTS.address.countryCA),
FormControlValidators.required,
FormControlValidators.requiredValue(SPD_CONSTANTS.address.countryCanada),
]),
country: new FormControl('', [FormControlValidators.required, FormControlValidators.requiredValue('Canada')]),
});

branchesInBcFormGroup: FormGroup = this.formBuilder.group({
Expand Down Expand Up @@ -315,6 +321,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
province: new FormControl('', [
FormControlValidators.required,
FormControlValidators.requiredValue(SPD_CONSTANTS.address.provinceBC),
FormControlValidators.requiredValue(SPD_CONSTANTS.address.provinceBritishColumbia),
]),
country: new FormControl('', [FormControlValidators.required, FormControlValidators.requiredValue('Canada')]),
branchManager: new FormControl('', [FormControlValidators.required]),
Expand Down Expand Up @@ -470,6 +477,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
const bizId = businessModelFormValue.bizId;
const licenceAppId = businessModelFormValue.licenceAppId;
const soleProprietorSWLAppId = businessModelFormValue.soleProprietorSWLAppId;
const soleProprietorSWLAppOriginTypeCode = businessModelFormValue.soleProprietorSWLAppOriginTypeCode;
const serviceTypeData = { ...businessModelFormValue.serviceTypeData };
const applicationTypeData = { ...businessModelFormValue.applicationTypeData };
const expiredLicenceData = { ...businessModelFormValue.expiredLicenceData };
Expand Down Expand Up @@ -548,6 +556,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
bizTypeCode,
licenceAppId,
soleProprietorSWLAppId,
soleProprietorSWLAppOriginTypeCode,
latestApplicationId: businessModelFormValue.latestApplicationId,
applicationTypeCode: applicationTypeData.applicationTypeCode,
serviceTypeCode: serviceTypeData.serviceTypeCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
isControllingMembersWithoutSwlExist: new FormControl(),

soleProprietorSWLAppId: new FormControl(), // placeholder for sole proprietor flow
soleProprietorSWLAppOriginTypeCode: new FormControl(), // placeholder for sole proprietor flow
isSoleProprietorSimultaneousSWLAnonymous: new FormControl(), // placeholder for sole proprietor flow
isSoleProprietorSimultaneousFlow: new FormControl(), // placeholder for sole proprietor flow - whether or not user can return to swl

Expand Down Expand Up @@ -147,18 +148,19 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
.subscribe((_resp: any) => {
if (this.initialized) {
const bizTypeCode = this.businessModelFormGroup.get('businessInformationData.bizTypeCode')?.value;
const isBusinessLicenceSoleProprietor = this.isSoleProprietor(bizTypeCode);

const isAddressTheSame = this.businessModelFormGroup.get('businessAddressData.isAddressTheSame')?.value;
const province = isAddressTheSame
? this.businessModelFormGroup.get('businessMailingAddressData.province')?.value
: this.businessModelFormGroup.get('businessAddressData.province')?.value;
const country = isAddressTheSame
? this.businessModelFormGroup.get('businessMailingAddressData.country')?.value
: this.businessModelFormGroup.get('businessAddressData.country')?.value;

const isBcBusinessAddress = this.utilService.isBcAddress(province, country);
const isBusinessLicenceSoleProprietor = this.isSoleProprietor(bizTypeCode);

let isControllingMembersWithoutSwlExist = false;

if (!isBusinessLicenceSoleProprietor) {
const membersWithoutSwl =
this.businessModelFormGroup.get('controllingMembersData.membersWithoutSwl')?.value ?? [];
Expand Down Expand Up @@ -708,13 +710,13 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
* Either create an empty licence or continue with the existing business lic app
* @returns
*/
getBusinessLicenceWithSwlCombinedFlow(
getNewBusinessLicenceWithSwlCombinedFlow(
soleProprietorSWLAppId: string | null | undefined, // one of these two must have a value
soleProprietorBizAppId: string | null | undefined // one of these two must have a value
): Observable<any> {
const bizId = this.authUserBceidService.bceidUserProfile?.bizId!;

if (soleProprietorSWLAppId) {
const bizId = this.authUserBceidService.bceidUserProfile?.bizId!;

return this.bizProfileService.apiBizIdGet({ id: bizId }).pipe(
switchMap((businessProfile: BizProfileResponse) => {
return this.createEmptyBusinessLicenceWithSwlCombinedFlow({
Expand Down Expand Up @@ -749,6 +751,32 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
);
}

/**
* Either create an empty licence or continue with the existing business lic app
* @returns
*/
getRenewBusinessLicenceWithSwlCombinedFlow(soleProprietorSWLAppId: string): Observable<any> {
const bizId = this.authUserBceidService.bceidUserProfile?.bizId!;

return this.bizProfileService.apiBizIdGet({ id: bizId }).pipe(
switchMap((businessProfile: BizProfileResponse) => {
return this.createEmptyBusinessLicenceWithSwlCombinedFlow({
soleProprietorSWLAppId,
businessProfile,
}).pipe(
tap((_resp: any) => {
this.setAsInitialized();

this.commonApplicationService.setApplicationTitle(
ServiceTypeCode.SecurityBusinessLicence,
ApplicationTypeCode.Renewal
);
})
);
})
);
}

/**
* Create an empty licence
* @returns
Expand Down Expand Up @@ -1716,12 +1744,18 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
}

const soleProprietorSWLAppId = businessLicenceAppl.soleProprietorSWLAppId ?? null;
const isSoleProprietorSimultaneousFlow = soleProprietorSWLAppId
? !!businessLicenceAppl.soleProprietorSWLAppId
: null;
const isSoleProprietorSimultaneousSWLAnonymous = isSoleProprietorSimultaneousFlow
? businessLicenceAppl.soleProprietorSWLAppOriginTypeCode != ApplicationOriginTypeCode.Portal
: null; // TODO populate Simultaneous

let isSoleProprietorSimultaneousFlow: boolean | null = null;
let isSoleProprietorSimultaneousSWLAnonymous: boolean | null = null;

if (associatedLicence) {
isSoleProprietorSimultaneousFlow = associatedLicence.isSimultaneousFlow;
} else {
isSoleProprietorSimultaneousFlow = !!soleProprietorSWLAppId;
isSoleProprietorSimultaneousSWLAnonymous = isSoleProprietorSimultaneousFlow
? businessLicenceAppl.soleProprietorSWLAppOriginTypeCode != ApplicationOriginTypeCode.Portal
: null;
}

this.businessModelFormGroup.patchValue(
{
Expand Down Expand Up @@ -1974,10 +2008,10 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
this.businessModelFormGroup.patchValue(
{
soleProprietorSWLAppId: licenceAppId,
soleProprietorSWLAppOriginTypeCode: resp.applicationOriginTypeCode,
isSoleProprietorSimultaneousFlow: true,
isSoleProprietorSimultaneousSWLAnonymous:
resp.applicationOriginTypeCode != ApplicationOriginTypeCode.Portal,

isBusinessLicenceSoleProprietor,
businessInformationData,
categoryData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ export class UtilService {
}

public isBcAddress(province: string | null | undefined, country: string | null | undefined): boolean {
return province === SPD_CONSTANTS.address.provinceBC && country === SPD_CONSTANTS.address.countryCanada;
return (
(province === SPD_CONSTANTS.address.provinceBC || province === SPD_CONSTANTS.address.provinceBritishColumbia) &&
(country === SPD_CONSTANTS.address.countryCA || country === SPD_CONSTANTS.address.countryCanada)
);
}

public getPermitShowAdditionalGovIdData(
Expand Down
Loading