From 5d5cc193f747a56471e21e7541cb54f1555ff28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9verin=20Beauvais?= Date: Fri, 19 Jan 2024 15:43:44 -0800 Subject: [PATCH] - app version = 5.6.42 (#629) - added isDraftTask to Amalgamating Business interface - added business status tooltip for Draft Task error - added amalgamation enum value - added new test to amalgamation rules - added fetch of first task - added helper function to amalgamation mixin - updated / added unit tests - minor cleanup Co-authored-by: Severin Beauvais --- package-lock.json | 4 +- package.json | 2 +- .../Amalgamation/AmalgamatingBusinesses.vue | 4 +- .../Amalgamation/BusinessStatus.vue | 3 ++ src/enums/amalgamationEnums.ts | 1 + .../amalgamation-state-interface.ts | 1 + src/mixins/amalgamation-mixin.ts | 44 ++++++++++++++----- src/mixins/filing-template-mixin.ts | 6 +-- src/services/legal-services.ts | 13 +++--- tests/unit/BusinessStatus.spec.ts | 9 +++- tests/unit/BusinessTable.spec.ts | 5 ++- tests/unit/amalgamation-mixin.spec.ts | 13 +++++- 12 files changed, 74 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 99218187e..6e6b98278 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.6.41", + "version": "5.6.42", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.6.41", + "version": "5.6.42", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.0.19", diff --git a/package.json b/package.json index ad24adf0a..d4a6caa44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.6.41", + "version": "5.6.42", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/Amalgamation/AmalgamatingBusinesses.vue b/src/components/Amalgamation/AmalgamatingBusinesses.vue index 5479eccac..422ad4c83 100644 --- a/src/components/Amalgamation/AmalgamatingBusinesses.vue +++ b/src/components/Amalgamation/AmalgamatingBusinesses.vue @@ -316,7 +316,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co } // Get the business information - const business = await this.fetchAmalgamatingBusinessInfo(businessLookup) + const business = await this.fetchAmalgamatingBusinessInfo(businessLookup.identifier) // Check for unaffiliated business. if (!business.authInfo) { @@ -350,6 +350,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co } // Check for Legal API fetch issues. + // NB - don't check for null firstTask since that's valid if (!business.businessInfo || !business.addresses || !business.firstFiling) { this.snackbarText = 'Unable to add that business.' this.snackbar = true @@ -372,6 +373,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co isNotInGoodStanding: (business.businessInfo.goodStanding === false), isFrozen: (business.businessInfo.adminFreeze === true), isFutureEffective: this.isFutureEffective(business), + isDraftTask: this.isDraftTask(business), isPendingFiling: this.isPendingFiling(business), isLimitedRestoration: await this.isLimitedRestoration(business), isHistorical: (business.businessInfo.state === EntityStates.HISTORICAL) diff --git a/src/components/Amalgamation/BusinessStatus.vue b/src/components/Amalgamation/BusinessStatus.vue index fffc76c9e..4e989c156 100644 --- a/src/components/Amalgamation/BusinessStatus.vue +++ b/src/components/Amalgamation/BusinessStatus.vue @@ -50,6 +50,9 @@ export default class BusinessStatus extends Vue { return 'A BC community contribution company must amalgamate to form a new BC community ' + 'contribution company.' + case AmlStatuses.ERROR_DRAFT_TASK: + return 'This business has a draft task. It cannot be part of an amalgamation.' + case AmlStatuses.ERROR_FROZEN: return 'This business is frozen. Frozen businesses cannot be part of an amalgamation.' diff --git a/src/enums/amalgamationEnums.ts b/src/enums/amalgamationEnums.ts index 661f01c55..a6ce64cc9 100644 --- a/src/enums/amalgamationEnums.ts +++ b/src/enums/amalgamationEnums.ts @@ -1,6 +1,7 @@ export enum AmlStatuses { OK, ERROR_CCC_MISMATCH, + ERROR_DRAFT_TASK, ERROR_FROZEN, ERROR_FOREIGN, ERROR_FOREIGN_HORIZONTAL, diff --git a/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts b/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts index c1712b054..877402507 100644 --- a/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts +++ b/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts @@ -19,6 +19,7 @@ interface AmalgamatingLearIF { isNotInGoodStanding?: boolean // whether business is in good standing isFrozen?: boolean // whether business is frozen isFutureEffective?: boolean // whether business has a future effective filing + isDraftTask?: boolean // whether business has a draft task isPendingFiling?: boolean // whether business has a pending filing isLimitedRestoration?: boolean // whether business is in limited restoration isHistorical?: boolean // whether business is historical diff --git a/src/mixins/amalgamation-mixin.ts b/src/mixins/amalgamation-mixin.ts index 9909e1009..8ea7be459 100644 --- a/src/mixins/amalgamation-mixin.ts +++ b/src/mixins/amalgamation-mixin.ts @@ -34,6 +34,7 @@ export default class AmalgamationMixin extends Vue { this.notInGoodStanding, this.limitedRestoration, this.futureEffectiveFiling, + this.draftTask, this.pendingFiling, this.foreign, this.foreignUnlimited, @@ -96,6 +97,14 @@ export default class AmalgamationMixin extends Vue { return null } + /** Disallow if a draft task exists. */ + draftTask (business: AmalgamatingBusinessIF): AmlStatuses { + if (business.type === AmlTypes.LEAR && business.isDraftTask) { + return AmlStatuses.ERROR_DRAFT_TASK + } + return null + } + /** Disallow if a pending filing exists. */ pendingFiling (business: AmalgamatingBusinessIF): AmlStatuses { if (business.type === AmlTypes.LEAR && business.isPendingFiling) { @@ -192,21 +201,22 @@ export default class AmalgamationMixin extends Vue { } /** - * Get the business information, mailing address, email, and first filing if in LEAR. - * Otherwise, return error. + * Fetches the business' auth information, business info, addresses, first task, and first filing. + * @param identifier The business identifier. */ - async fetchAmalgamatingBusinessInfo (item: any): Promise { - // Get the auth info, business info, addresses and filings concurrently. + async fetchAmalgamatingBusinessInfo (identifier: string): Promise { + // Make all API calls concurrently without rejection. // NB - if any call failed, that item will be null. - const [ authInfo, businessInfo, addresses, firstFiling ] = + const [ authInfo, businessInfo, addresses, firstTask, firstFiling ] = await Promise.allSettled([ - AuthServices.fetchAuthInfo(item.identifier), - LegalServices.fetchBusinessInfo(item.identifier), - LegalServices.fetchAddresses(item.identifier), - LegalServices.fetchFirstOrOnlyFiling(item.identifier) + AuthServices.fetchAuthInfo(identifier), + LegalServices.fetchBusinessInfo(identifier), + LegalServices.fetchAddresses(identifier), + LegalServices.fetchFirstTask(identifier), + LegalServices.fetchFirstOrOnlyFiling(identifier) ]).then(results => results.map((result: any) => result.value || null)) - return { authInfo, businessInfo, addresses, firstFiling } + return { authInfo, businessInfo, addresses, firstTask, firstFiling } } /** @@ -241,6 +251,17 @@ export default class AmalgamationMixin extends Vue { ) } + /** + * This business is draft task if the first task in the Todo List is still draft (or pending). + * @param business The business to check if is Draft Task or not. + */ + isDraftTask (business: any): boolean { + return ( + business.firstTask?.header.status === FilingStatus.DRAFT || + business.firstTask?.header.status === FilingStatus.PENDING + ) + } + /** * This business is pending filing if the first filing in the ledger is still not complete or corrected * (ie, it's paid or pending). @@ -259,7 +280,7 @@ export default class AmalgamationMixin extends Vue { */ async refetchAmalgamatingBusinessesInfo (): Promise { const fetchTingInfo = async (item: any): Promise => { - const tingBusiness = await this.fetchAmalgamatingBusinessInfo(item) + const tingBusiness = await this.fetchAmalgamatingBusinessInfo(item.identifier) // no auth info and business info means foreign, otherwise LEAR (affiliated or non-affiliated) if (!tingBusiness.authInfo && !tingBusiness.businessInfo) { return { @@ -281,6 +302,7 @@ export default class AmalgamationMixin extends Vue { isNotInGoodStanding: (tingBusiness.businessInfo.goodStanding === false), isFrozen: (tingBusiness.businessInfo.adminFreeze === true), isFutureEffective: this.isFutureEffective(tingBusiness), + isDraftTask: this.isDraftTask(tingBusiness), isPendingFiling: this.isPendingFiling(tingBusiness), isLimitedRestoration: await this.isLimitedRestoration(tingBusiness), isHistorical: (tingBusiness.businessInfo.state === EntityStates.HISTORICAL) diff --git a/src/mixins/filing-template-mixin.ts b/src/mixins/filing-template-mixin.ts index 1a3ca9bbf..b10969706 100644 --- a/src/mixins/filing-template-mixin.ts +++ b/src/mixins/filing-template-mixin.ts @@ -76,7 +76,7 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM @Action(useStore) setBusinessContact!: (x: ContactPointIF) => void @Action(useStore) setCertifyState!: (x: CertifyIF) => void @Action(useStore) setCooperativeType!: (x: CoopTypes) => void - @Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void + // @Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void @Action(useStore) setCourtOrderFileNumber!: (x: string) => void @Action(useStore) setCustodianOfRecords!: (x: OrgPersonIF) => void @Action(useStore) setDissolutionDate!: (x: string) => void @@ -94,8 +94,8 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM @Action(useStore) setFoundingDate!: (x: string) => void @Action(useStore) setLegalName!: (x: string) => void @Action(useStore) setMemorandum!: (x: CreateMemorandumIF) => void - @Action(useStore) setNameRequestApprovedName!: (x: string) => void - @Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void + // @Action(useStore) setNameRequestApprovedName!: (x: string) => void + // @Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void @Action(useStore) setOfficeAddresses!: (x: RegisteredRecordsAddressesIF) => void @Action(useStore) setOrgPersonList!: (x: OrgPersonIF[]) => void @Action(useStore) setRegistrationBusinessAddress!: (x: BusinessAddressIF) => void diff --git a/src/services/legal-services.ts b/src/services/legal-services.ts index 4f91bee21..57e21be75 100644 --- a/src/services/legal-services.ts +++ b/src/services/legal-services.ts @@ -1,7 +1,6 @@ import { AxiosInstance as axios } from '@/utils' import { StatusCodes } from 'http-status-codes' -import { AmalgamationFilingIF, BusinessIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF, - RegistrationFilingIF, RestorationFilingIF } from '@/interfaces' +import { BusinessIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF } from '@/interfaces' import { FilingTypes } from '@/enums' /** @@ -29,12 +28,11 @@ export default class LegalServices { /** * Fetches the first or only filing. - * This is expected to be a draft IA or Registration. + * This is probably a draft Amalgamation, IA or Registration. * @param tempId the temp registration number * @returns a promise to return the draft filing, else exception */ - // eslint-disable-next-line max-len - static async fetchFirstOrOnlyFiling (tempId: string): Promise { + static async fetchFirstOrOnlyFiling (tempId: string): Promise { const url = `businesses/${tempId}/filings` return axios.get(url) @@ -65,12 +63,11 @@ export default class LegalServices { /** * Fetches the first task. - * This is expected to be a draft Dissolution or Restoration. + * This is probably a draft Dissolution or Restoration. * @param businessId the business identifier * @returns a promise to return the draft filing, else exception */ - // eslint-disable-next-line max-len - static async fetchFirstTask (businessId: string): Promise { + static async fetchFirstTask (businessId: string): Promise { const url = `businesses/${businessId}/tasks` return axios.get(url) .then(response => { diff --git a/tests/unit/BusinessStatus.spec.ts b/tests/unit/BusinessStatus.spec.ts index 7b057b2ff..c2c03836e 100644 --- a/tests/unit/BusinessStatus.spec.ts +++ b/tests/unit/BusinessStatus.spec.ts @@ -15,7 +15,12 @@ describe('Business Status', () => { tooltip: 'A BC community contribution company must amalgamate to form a new BC community' }, { - label: 'Error FROZEN', + label: 'Error Draft Task', + status: AmlStatuses.ERROR_DRAFT_TASK, + tooltip: 'This business has a draft task. It cannot be part of an amalgamation.' + }, + { + label: 'Error Frozen', status: AmlStatuses.ERROR_FROZEN, tooltip: 'This business is frozen. Frozen businesses cannot be part of an amalgamation.' }, @@ -87,7 +92,7 @@ describe('Business Status', () => { ] it('has the expected number of tests', () => { - expect(tests.length).toBe(1 + 15) // OK + 14 errors + expect(tests.length).toBe(1 + 16) // OK + 16 errors }) for (const test of tests) { diff --git a/tests/unit/BusinessTable.spec.ts b/tests/unit/BusinessTable.spec.ts index ff2265640..daba23698 100644 --- a/tests/unit/BusinessTable.spec.ts +++ b/tests/unit/BusinessTable.spec.ts @@ -183,6 +183,7 @@ describe.skip('Business Table - rule evaluation', () => { { methodName: 'notInGoodStanding', error: AmlStatuses.ERROR_NOT_IN_GOOD_STANDING }, { methodName: 'limitedRestoration', error: AmlStatuses.ERROR_LIMITED_RESTORATION }, { methodName: 'futureEffectiveFiling', error: AmlStatuses.ERROR_FUTURE_EFFECTIVE_FILING }, + { methodName: 'draftTask', error: AmlStatuses.ERROR_DRAFT_TASK }, { methodName: 'pendingFiling', error: AmlStatuses.ERROR_PENDING_FILING }, { methodName: 'foreign', error: AmlStatuses.ERROR_FOREIGN }, { methodName: 'foreignUnlimited', error: AmlStatuses.ERROR_FOREIGN_UNLIMITED }, @@ -222,8 +223,8 @@ describe.skip('Business Table - rule evaluation', () => { }) it('has the expected number of rules', () => { - expect(rules.length).toBe(15) - expect(wrapper.vm.rules.length).toBe(15) + expect(rules.length).toBe(16) + expect(wrapper.vm.rules.length).toBe(16) }) // check each rule sequentially diff --git a/tests/unit/amalgamation-mixin.spec.ts b/tests/unit/amalgamation-mixin.spec.ts index 14dacb9fe..35bc2908a 100644 --- a/tests/unit/amalgamation-mixin.spec.ts +++ b/tests/unit/amalgamation-mixin.spec.ts @@ -21,7 +21,7 @@ describe('Amalgamation Mixin - rules', () => { }) it('has the expected number of rules', () => { - expect(wrapper.vm.rules.length).toBe(15) + expect(wrapper.vm.rules.length).toBe(16) }) it('correctly evaluates "notAffiliated" rule', () => { @@ -114,6 +114,17 @@ describe('Amalgamation Mixin - rules', () => { expect(wrapper.vm.futureEffectiveFiling({ type: AmlTypes.LEAR, isFutureEffective: false })).toBeNull() }) + it('correctly evaluates "draftTask" rule', () => { + // verify rule + expect(wrapper.vm.draftTask({ type: AmlTypes.LEAR, isDraftTask: true })).toBe(AmlStatuses.ERROR_DRAFT_TASK) + + // verify not LEAR only + expect(wrapper.vm.draftTask({ type: AmlTypes.FOREIGN, isDraftTask: true })).toBeNull() + + // verify not draft task only + expect(wrapper.vm.draftTask({ type: AmlTypes.LEAR, isDraftTask: false })).toBeNull() + }) + it('correctly evaluates "pendingFiling" rule', () => { // verify rule expect(wrapper.vm.pendingFiling({ type: AmlTypes.LEAR, isPendingFiling: true })).toBe(AmlStatuses.ERROR_PENDING_FILING)