Skip to content

Commit

Permalink
Business licence fixes (#1443)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- Business licence fixes
- Export class bug in Angular 18... move routes into a different class
  • Loading branch information
carolcarpenter authored Sep 26, 2024
1 parent de89aa8 commit 0283b77
Show file tree
Hide file tree
Showing 74 changed files with 601 additions and 542 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LandingComponent } from './landing.component';
import { ControllingMemberCrcRoutes } from './modules/controlling-member-crc/controlling-member-crc-routing.module';
import { PersonalLicenceApplicationRoutes } from './modules/personal-licence-application/personal-licence-application-routing.module';
import { AccessDeniedComponent } from './shared/components/access-denied.component';
import { BusinessLicenceApplicationRoutes } from './modules/business-licence-application/business-license-application-routes';
import { ControllingMemberCrcRoutes } from './modules/controlling-member-crc/controlling-member-crc-routes';
import { PersonalLicenceApplicationRoutes } from './modules/personal-licence-application/personal-licence-application-routes';
import { AccessDeniedComponent } from './shared/components/access-denied.component';

export class AppRoutes {
public static readonly PERSONAL_LICENCE_APPLICATION = PersonalLicenceApplicationRoutes.MODULE_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ApplicationInviteStatusCode,
ApplicationPortalStatusCode,
ApplicationTypeCode,
BizLicAppResponse,
BizProfileResponse,
BizTypeCode,
IdentityProviderTypeCode,
Expand All @@ -20,17 +19,15 @@ import {
PaymentLinkCreateRequest,
PaymentLinkResponse,
PaymentMethodCode,
PermitLicenceAppResponse,
WorkerCategoryTypeCode,
WorkerLicenceAppResponse,
WorkerLicenceTypeCode,
} from '@app/api/models';
import { BizMembersService, LicenceAppService, LicenceService, PaymentService } from '@app/api/services';
import { StrictHttpResponse } from '@app/api/strict-http-response';
import { AppRoutes } from '@app/app-routing.module';
import { SPD_CONSTANTS } from '@app/core/constants/constants';
import { BusinessLicenceApplicationRoutes } from '@app/modules/business-licence-application/business-license-application-routes';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routing.module';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routes';
import { DialogComponent, DialogOptions } from '@app/shared/components/dialog.component';
import { FormatDatePipe } from '@app/shared/pipes/format-date.pipe';
import { OptionsPipe } from '@app/shared/pipes/options.pipe';
Expand Down Expand Up @@ -58,16 +55,12 @@ export interface MainApplicationResponse extends LicenceAppListResponse {
isControllingMemberWarning?: boolean;
}

export interface MainLicenceResponse extends WorkerLicenceAppResponse, PermitLicenceAppResponse, BizLicAppResponse {
export interface MainLicenceResponse extends LicenceResponse {
hasLoginNameChanged: boolean;
cardHolderName?: null | string;
licenceCategoryCodes?: Array<WorkerCategoryTypeCode> | null;
licenceHolderName?: null | string;
licenceExpiryDate?: string;
licenceExpiryNumberOfDays?: null | number;
licenceStatusCode?: LicenceStatusCode;
licenceId?: null | string;
licenceNumber?: null | string;
licenceReprintFee: null | number;
isRenewalPeriod: boolean;
isUpdatePeriod: boolean;
Expand Down Expand Up @@ -398,10 +391,10 @@ export class ApplicationService {
const response: Array<MainLicenceResponse> = [];

basicLicenceResps.forEach((basicLicence: LicenceBasicResponse) => {
const matchingLicenceResp = licenceResps?.find(
const matchingLicence = licenceResps?.find(
(item: LicenceBasicResponse) => item.licenceId === basicLicence.licenceId
);
const licence = this.getLicence(basicLicence, businessProfile.bizTypeCode!, matchingLicenceResp);
const licence = this.getLicence(basicLicence, businessProfile.bizTypeCode!, matchingLicence);

response.push(licence);
});
Expand Down Expand Up @@ -828,7 +821,7 @@ export class ApplicationService {
bizTypeCode: BizTypeCode,
matchingLicence?: LicenceResponse | undefined
): MainLicenceResponse {
const licence = { ...basicLicence } as MainLicenceResponse;
const licence = { ...basicLicence, ...matchingLicence } as MainLicenceResponse;

const licenceReplacementPeriodPreventionDays = SPD_CONSTANTS.periods.licenceReplacementPeriodPreventionDays;
const licenceUpdatePeriodPreventionDays = SPD_CONSTANTS.periods.licenceUpdatePeriodPreventionDays;
Expand All @@ -842,12 +835,8 @@ export class ApplicationService {
const today = moment().startOf('day');

licence.cardHolderName = basicLicence.nameOnCard;
// licence.licenceHolderName = basicLicence.licenceHolderName;
// licence.licenceStatusCode = basicLicence.licenceStatusCode;
licence.licenceExpiryDate = basicLicence.expiryDate;
licence.licenceExpiryNumberOfDays = moment(licence.licenceExpiryDate).startOf('day').diff(today, 'days');
// licence.licenceId = basicLicence.licenceId;
// licence.licenceNumber = basicLicence.licenceNumber;
licence.hasLoginNameChanged = basicLicence.nameOnCard != licence.licenceHolderName;
licence.licenceCategoryCodes = basicLicence.categoryCodes ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { IdentityProviderTypeCode } from '@app/api/models';
import { AppRoutes } from '@app/app-routing.module';
import { BusinessLicenceApplicationRoutes } from '@app/modules/business-licence-application/business-license-application-routes';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routing.module';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routes';
import { OAuthService } from 'angular-oauth2-oidc';
import { BehaviorSubject } from 'rxjs';
import { AuthenticationService } from 'src/app/core/services/authentication.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,22 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
categorySecurityGuardFormGroup: FormGroup = this.formBuilder.group(
{
isInclude: new FormControl(false),
isRequestDogAuthorization: new FormControl(''),
useDogs: new FormControl(''),
dogsPurposeFormGroup: new FormGroup({
isDogsPurposeProtection: new FormControl(false),
isDogsPurposeDetectionDrugs: new FormControl(false),
isDogsPurposeDetectionExplosives: new FormControl(false),
}),
attachments: new FormControl([]),
},
{
validators: [
FormGroupValidators.conditionalDefaultRequiredValidator(
'isRequestDogAuthorization',
(form) => form.get('isInclude')?.value
),
FormGroupValidators.conditionalRequiredValidator('useDogs', (form) => form.get('isInclude')?.value ?? false),
FormGroupValidators.conditionalDefaultRequiredValidator(
'attachments',
(form) => form.get('isInclude')?.value && form.get('isRequestDogAuthorization')?.value === BooleanTypeCode.Yes
(form) => form.get('useDogs')?.value == this.booleanTypeCodes.Yes
),
FormGroupValidators.atLeastOneCheckboxWhenReqdValidator('dogsPurposeFormGroup', 'useDogs', BooleanTypeCode.Yes),
],
}
);
Expand Down Expand Up @@ -422,7 +425,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {

if (categoryData.SecurityGuard) {
const useDogs = this.utilService.booleanTypeToBoolean(
businessModelFormValue.categorySecurityGuardFormGroup.isRequestDogAuthorization
businessModelFormValue.categorySecurityGuardFormGroup.useDogs
);
if (useDogs) {
if (businessModelFormValue.categorySecurityGuardFormGroup.attachments) {
Expand Down Expand Up @@ -466,7 +469,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
const bizTypeCode = businessModelFormValue.businessInformationData.bizTypeCode;

let privateInvestigatorSwlInfo: SwlContactInfo = {};
let useDogs: boolean | null = null;
let dogsAuthorizationData = {};

const categoryCodes = this.getSaveBodyCategoryCodes(businessModelFormValue.categoryData);
const documentInfos = this.getSaveBodyDocumentInfos(businessModelFormValue);
Expand All @@ -492,9 +495,18 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
const categoryData = { ...businessModelFormValue.categoryData };

if (categoryData.SecurityGuard) {
useDogs = this.utilService.booleanTypeToBoolean(
businessModelFormValue.categorySecurityGuardFormGroup.isRequestDogAuthorization
);
const categorySecurityGuardFormGroup = businessModelFormValue.categorySecurityGuardFormGroup.dogsPurposeFormGroup;
const isDetectionDrugs = categorySecurityGuardFormGroup.isDogsPurposeDetectionDrugs ?? false;
const isDetectionExplosives = categorySecurityGuardFormGroup.isDogsPurposeDetectionExplosives ?? false;
const isProtection = categorySecurityGuardFormGroup.isDogsPurposeProtection ?? false;
const useDogs = this.utilService.booleanTypeToBoolean(categorySecurityGuardFormGroup.useDogs);

dogsAuthorizationData = {
useDogs,
isDogsPurposeDetectionDrugs: useDogs ? isDetectionDrugs : null,
isDogsPurposeDetectionExplosives: useDogs ? isDetectionExplosives : null,
isDogsPurposeProtection: useDogs ? isProtection : null,
};
}

if (categoryData.PrivateInvestigator) {
Expand Down Expand Up @@ -533,10 +545,10 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
originalApplicationId: originalLicenceData ? originalLicenceData.originalApplicationId : null,
originalLicenceId: originalLicenceData ? originalLicenceData.originalLicenceId : null,
//-----------------------------------
categoryCodes: [...categoryCodes],
documentInfos: [...documentInfos],
categoryCodes,
documentInfos,
privateInvestigatorSwlInfo,
useDogs,
dogsAuthorizationData,
};

console.debug('[getSaveBodyBase] body returned', body);
Expand Down Expand Up @@ -635,7 +647,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {

if (categoryData.SecurityGuard) {
const useDogs = this.utilService.booleanTypeToBoolean(
businessModelFormValue.categorySecurityGuardFormGroup.isRequestDogAuthorization
businessModelFormValue.categorySecurityGuardFormGroup.useDogs
);
if (useDogs) {
if (businessModelFormValue.categorySecurityGuardFormGroup.attachments) {
Expand Down Expand Up @@ -681,7 +693,7 @@ export abstract class BusinessApplicationHelper extends ApplicationHelper {
return applicationTypeCode === ApplicationTypeCode.Update;
}

clearPrivateInvestigatorModelData(): void {
private clearPrivateInvestigatorModelData(): void {
// clear out any old data
this.categoryPrivateInvestigatorFormGroup.patchValue(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,13 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
if (categoryData.SecurityGuard) {
categorySecurityGuardFormGroup = {
isInclude: true,
isRequestDogAuthorization: this.utilService.booleanToBooleanType(businessLicenceAppl.useDogs),
useDogs: this.utilService.booleanToBooleanType(businessLicenceAppl.useDogs),
dogsPurposeFormGroup: {
isDogsPurposeDetectionDrugs: null, //businessLicenceAppl.isDogsPurposeDetectionDrugs,
isDogsPurposeDetectionExplosives: null, //businessLicenceAppl.isDogsPurposeDetectionExplosives,
isDogsPurposeProtection: null, //businessLicenceAppl.isDogsPurposeProtection,
// TODO populate dog info
},
attachments: dogAuthorizationAttachments,
};
}
Expand Down Expand Up @@ -1850,7 +1856,12 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
if (categoryData.SecurityGuard) {
categorySecurityGuardFormGroup = {
isInclude: true,
isRequestDogAuthorization: null,
useDogs: null,
dogsPurposeFormGroup: {
isDogsPurposeDetectionDrugs: null,
isDogsPurposeDetectionExplosives: null,
isDogsPurposeProtection: null,
},
attachments: [],
};
}
Expand Down Expand Up @@ -1904,7 +1915,12 @@ export class BusinessApplicationService extends BusinessApplicationHelper {
if (categoryData.SecurityGuard) {
categorySecurityGuardFormGroup = {
isInclude: true,
isRequestDogAuthorization: null,
useDogs: null,
dogsPurposeFormGroup: {
isDogsPurposeDetectionDrugs: null,
isDogsPurposeDetectionExplosives: null,
isDogsPurposeProtection: null,
},
attachments: [],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { BooleanTypeCode } from '@app/core/code-types/model-desc.models';
import { AuthenticationService } from '@app/core/services/authentication.service';
import { FileUtilService, SpdFile } from '@app/core/services/file-util.service';
import { FormControlValidators } from '@app/core/validators/form-control.validators';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routing.module';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routes';
import { OptionsPipe } from '@app/shared/pipes/options.pipe';
import { HotToastService } from '@ngxpert/hot-toast';
import moment from 'moment';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,8 @@ export abstract class WorkerApplicationHelper extends ApplicationHelper {
}

getSummaryshowPhotographOfYourself(workerLicenceModelData: any): boolean {
return (
this.getSummaryhasGenderChanged(workerLicenceModelData) &&
this.getSummaryphotoOfYourselfAttachments(workerLicenceModelData).length > 0
);
const att = this.getSummaryphotoOfYourselfAttachments(workerLicenceModelData);
return this.getSummaryhasGenderChanged(workerLicenceModelData) && !!att && att.length > 0;
}

getSummaryhasBcscNameChanged(workerLicenceModelData: any): boolean {
Expand Down Expand Up @@ -1489,14 +1487,14 @@ export abstract class WorkerApplicationHelper extends ApplicationHelper {
return workerLicenceModelData.characteristicsData.weightUnitCode ?? '';
}

getSummaryphotoOfYourselfAttachments(workerLicenceModelData: any): File[] {
getSummaryphotoOfYourselfAttachments(workerLicenceModelData: any): File[] | null {
const applicationTypeCode = this.getSummaryapplicationTypeCode(workerLicenceModelData);
if (applicationTypeCode === ApplicationTypeCode.New) {
return workerLicenceModelData.photographOfYourselfData.attachments ?? [];
return workerLicenceModelData.photographOfYourselfData.attachments ?? null;
} else {
const updatePhoto = workerLicenceModelData.photographOfYourselfData.updatePhoto === BooleanTypeCode.Yes;
const updateAttachments = workerLicenceModelData.photographOfYourselfData.updateAttachments ?? [];
return updatePhoto ? updateAttachments : [];
const updateAttachments = workerLicenceModelData.photographOfYourselfData.updateAttachments ?? null;
return updatePhoto ? updateAttachments : null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { StrictHttpResponse } from '@app/api/strict-http-response';
import { BooleanTypeCode } from '@app/core/code-types/model-desc.models';
import { SPD_CONSTANTS } from '@app/core/constants/constants';
import { FormControlValidators } from '@app/core/validators/form-control.validators';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routing.module';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routes';
import { FileUploadComponent } from '@app/shared/components/file-upload.component';
import { FormatDatePipe } from '@app/shared/pipes/format-date.pipe';
import { HotToastService } from '@ngxpert/hot-toast';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { BusinessLicenceApplicationRoutes } from '@app/modules/business-licence-application/business-license-application-routes';
import { PersonalLicenceApplicationRoutes } from '@app/modules/personal-licence-application/personal-licence-application-routes';
import { PermitApplicationService } from '@core/services/permit-application.service';
import { take, tap } from 'rxjs';
import { WorkerLicenceTypeCode } from './api/models';
import { SPD_CONSTANTS } from './core/constants/constants';
import { ApplicationService } from './core/services/application.service';
import { AuthProcessService } from './core/services/auth-process.service';
import { WorkerApplicationService } from './core/services/worker-application.service';
import { BusinessLicenceApplicationRoutes } from '@app/modules/business-licence-application/business-license-application-routes';
import { PersonalLicenceApplicationRoutes } from './modules/personal-licence-application/personal-licence-application-routing.module';
import { DialogComponent, DialogOptions } from './shared/components/dialog.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export class BusinessLicenceApplicationRoutes {
public static readonly BUSINESS_LICENCE_APPLICATION = 'business-licence';

Expand Down
Loading

0 comments on commit 0283b77

Please sign in to comment.