From 4261f17f245348cc75a3c37050f851605fb76f93 Mon Sep 17 00:00:00 2001 From: Vysakh Menon Date: Thu, 1 Feb 2024 16:07:34 -0800 Subject: [PATCH] 19561 corpNumber to identifier in foreign amalgamating business (#644) --- package-lock.json | 4 +- package.json | 2 +- .../Amalgamation/AmalgamatingBusinesses.vue | 19 +++++----- src/components/Amalgamation/BusinessTable.vue | 4 +- .../Amalgamation/BusinessTableSummary.vue | 8 +--- .../amalgamation-state-interface.ts | 2 +- src/mixins/amalgamation-mixin.ts | 10 ++--- tests/unit/AmalgamatingBusinesses.spec.ts | 38 +++++++++---------- tests/unit/BusinessTable.spec.ts | 4 +- tests/unit/BusinessTableSummary.spec.ts | 4 +- 10 files changed, 43 insertions(+), 52 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0bc814265..630290929 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.8.5", + "version": "5.8.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.8.5", + "version": "5.8.6", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.0.19", diff --git a/package.json b/package.json index 20302f2d7..98f0b1a00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.8.5", + "version": "5.8.6", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/Amalgamation/AmalgamatingBusinesses.vue b/src/components/Amalgamation/AmalgamatingBusinesses.vue index 41d41e025..7efb29723 100644 --- a/src/components/Amalgamation/AmalgamatingBusinesses.vue +++ b/src/components/Amalgamation/AmalgamatingBusinesses.vue @@ -198,10 +198,10 @@ > boolean | string> { + get foreignBusinessIdentifierRules (): Array<(v: string) => boolean | string> { return [ v => (!this.isMrasJurisdiction || (!!v && /^[0-9a-zA-Z-]+$/.test(v))) || 'Corporate number is required', @@ -414,7 +414,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co country: JurisdictionLocation.CA }, legalName: businessLookup.name, - corpNumber: businessLookup.identifier + identifier: businessLookup.identifier } as AmalgamatingBusinessIF // Check for duplicate @@ -538,7 +538,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co country: this.isCan ? JurisdictionLocation.CA : this.jurisdiction.value }, legalName: this.legalName, - corpNumber: this.corpNumber + identifier: this.identifier } as AmalgamatingBusinessIF // Check for duplicate. @@ -585,8 +585,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co */ private checkForDuplicateInTable (business: any): boolean { const checkDuplication = this.getAmalgamatingBusinesses.find((b: AmalgamatingBusinessIF) => - (b.type === AmlTypes.LEAR && b.identifier === business.identifier) || - (b.type === AmlTypes.FOREIGN && b.corpNumber === business.corpNumber) + (b.identifier === business.identifier) ) if (checkDuplication) { @@ -601,7 +600,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co this.isForeignBusinessValid = ( !!this.jurisdiction && !!this.legalName && - (!this.isMrasJurisdiction || !!this.corpNumber) + (!this.isMrasJurisdiction || !!this.identifier) ) this.jurisdictionErrorMessage = this.jurisdiction ? '' : 'Home jurisdiction is required' this.$refs.foreignBusinessForm.validate() @@ -623,7 +622,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co this.isForeignBusinessValid = null this.jurisdiction = null this.legalName = null - this.corpNumber = null + this.identifier = null this.jurisdictionErrorMessage = '' this.isMrasJurisdiction = false } diff --git a/src/components/Amalgamation/BusinessTable.vue b/src/components/Amalgamation/BusinessTable.vue index b7a3e908b..368d5913e 100644 --- a/src/components/Amalgamation/BusinessTable.vue +++ b/src/components/Amalgamation/BusinessTable.vue @@ -196,9 +196,7 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) { key (item: AmalgamatingBusinessIF): string { // make the key depend on whether the more actions menu is shown (for reactivity) let x = this.showMoreActionsMenu(item) ? 'y' : 'n' - if (item?.type === AmlTypes.LEAR) return `${item.identifier}-${x}` - if (item?.type === AmlTypes.FOREIGN) return `${item.corpNumber}-${x}` - return null // should never happen + return `${item.identifier}-${x}` } name (item: AmalgamatingBusinessIF): string { diff --git a/src/components/Amalgamation/BusinessTableSummary.vue b/src/components/Amalgamation/BusinessTableSummary.vue index f6642a11b..0f8362c8b 100644 --- a/src/components/Amalgamation/BusinessTableSummary.vue +++ b/src/components/Amalgamation/BusinessTableSummary.vue @@ -20,7 +20,7 @@ @@ -72,12 +72,6 @@ export default class BusinessTableSummary extends Vue { @Getter(useStore) getAmalgamatingBusinesses!: AmalgamatingBusinessIF[] - key (item: AmalgamatingBusinessIF): string { - if (item?.type === AmlTypes.LEAR) return item.identifier - if (item?.type === AmlTypes.FOREIGN) return item.corpNumber - return null // should never happen - } - name (item: AmalgamatingBusinessIF): string { if (item?.type === AmlTypes.LEAR) return item.name if (item?.type === AmlTypes.FOREIGN) return item.legalName 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 7cc756949..1f0330dd6 100644 --- a/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts +++ b/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts @@ -36,7 +36,7 @@ interface AmalgamatingForeignIF { country: string } legalName: string - corpNumber: string + identifier: string // properties for UI only: status?: AmlStatuses diff --git a/src/mixins/amalgamation-mixin.ts b/src/mixins/amalgamation-mixin.ts index 324502019..7eab328ab 100644 --- a/src/mixins/amalgamation-mixin.ts +++ b/src/mixins/amalgamation-mixin.ts @@ -294,17 +294,17 @@ export default class AmalgamationMixin extends Vue { */ async refetchAmalgamatingBusinessesInfo (): Promise { const fetchTingInfo = async (item: any): Promise => { - 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) { + // check if foreign + if (item.foreignJurisdiction) { return { type: AmlTypes.FOREIGN, - role: AmlRoles.AMALGAMATING, // *** FUTURE: can we really assume this? - corpNumber: item.corpNumber, + role: AmlRoles.AMALGAMATING, + identifier: item.identifier, legalName: item.legalName, foreignJurisdiction: item.foreignJurisdiction } as AmalgamatingBusinessIF } else { + const tingBusiness = await this.fetchAmalgamatingBusinessInfo(item.identifier) return { type: AmlTypes.LEAR, role: item.role, // amalgamating or holding diff --git a/tests/unit/AmalgamatingBusinesses.spec.ts b/tests/unit/AmalgamatingBusinesses.spec.ts index 7be6edfcb..76af923fc 100644 --- a/tests/unit/AmalgamatingBusinesses.spec.ts +++ b/tests/unit/AmalgamatingBusinesses.spec.ts @@ -257,7 +257,7 @@ describe('Amalgamating Businesses - add amalgamating business', () => { expect(business.role).toBe(AmlRoles.AMALGAMATING) expect(business.foreignJurisdiction).toEqual({ country: 'CA', region: 'British Columbia' }) expect(business.legalName).toBe('Extra Pro Business') - expect(business.corpNumber).toBe('A1234567') + expect(business.identifier).toBe('A1234567') // verify panel is now closed expect(wrapper.vm.isAddingAmalgamatingBusiness).toBe(false) @@ -418,7 +418,7 @@ describe('Amalgamating Businesses - add amalgamating business', () => { role: AmlRoles.AMALGAMATING, foreignJurisdiction: { country: 'CA', region: 'British Columbia' }, legalName: 'Extra Pro Business', - corpNumber: 'A1234567' + identifier: 'A1234567' } ] expect(store.getAmalgamatingBusinesses.length).toBe(1) @@ -636,7 +636,7 @@ describe('Amalgamating Businesses - add amalgamating foreign business', () => { isCan: true, jurisdiction: { text: 'BC', value: 'CA' }, legalName: 'Foreign Business', - corpNumber: 'ABC-123' + identifier: 'ABC-123' }) // simulate Save button action @@ -652,7 +652,7 @@ describe('Amalgamating Businesses - add amalgamating foreign business', () => { expect(business.role).toBe(AmlRoles.AMALGAMATING) expect(business.foreignJurisdiction).toEqual({ country: 'CA', region: 'BC' }) expect(business.legalName).toBe('Foreign Business') - expect(business.corpNumber).toBe('ABC-123') + expect(business.identifier).toBe('ABC-123') // verify panel is now closed expect(wrapper.vm.isAddingAmalgamatingForeignBusiness).toBe(false) @@ -666,7 +666,7 @@ describe('Amalgamating Businesses - add amalgamating foreign business', () => { role: AmlRoles.AMALGAMATING, foreignJurisdiction: { country: 'CA', region: 'British Columbia' }, legalName: 'Foreign Business', - corpNumber: 'ABC-123' + identifier: 'ABC-123' } ] expect(store.getAmalgamatingBusinesses.length).toBe(1) @@ -679,7 +679,7 @@ describe('Amalgamating Businesses - add amalgamating foreign business', () => { isCan: true, jurisdiction: { text: 'British Columbia', value: 'CA' }, legalName: 'Foreign Business', - corpNumber: 'ABC-123' + identifier: 'ABC-123' }) // verify snackbar is not displayed @@ -730,39 +730,39 @@ describe('Amalgamating Businesses - add amalgamating foreign business', () => { // open panel await wrapper.find('#add-foreign-business-button').trigger('click') - const corpNumber = wrapper.find('#foreign-business-corp-number') + const identifier = wrapper.find('#foreign-business-corp-number') // verify empty legal name - MRAS jurisdiction await wrapper.setData({ isMrasJurisdiction: true }) - await corpNumber.setValue('') - await corpNumber.trigger('change') + await identifier.setValue('') + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').text()).toBe('Corporate number is required') // verify empty legal name - non-MRAS jurisdiction await wrapper.setData({ isMrasJurisdiction: false }) - await corpNumber.setValue('') - await corpNumber.trigger('change') + await identifier.setValue('') + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').text()).toBe('Corporate number is required') // verify invalid legal name - MRAS jurisdiction await wrapper.setData({ isMrasJurisdiction: true }) - await corpNumber.setValue('+++') - await corpNumber.trigger('change') + await identifier.setValue('+++') + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').text()).toBe('Corporate number is required') // verify legal name too short - await corpNumber.setValue('xx') - await corpNumber.trigger('change') + await identifier.setValue('xx') + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').text()).toBe('Must be at least 3 characters') // verify legal name too long - await corpNumber.setValue('x'.repeat(41)) - await corpNumber.trigger('change') + await identifier.setValue('x'.repeat(41)) + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').text()).toBe('Cannot exceed 40 characters') // verify valid legal name (max length) - await corpNumber.setValue('x'.repeat(40)) - await corpNumber.trigger('change') + await identifier.setValue('x'.repeat(40)) + await identifier.trigger('change') expect(wrapper.find('.v-messages__message').exists()).toBe(false) }) diff --git a/tests/unit/BusinessTable.spec.ts b/tests/unit/BusinessTable.spec.ts index 3115a8a69..f21b1eb74 100644 --- a/tests/unit/BusinessTable.spec.ts +++ b/tests/unit/BusinessTable.spec.ts @@ -97,7 +97,7 @@ describe('Business Table - display', () => { label: 'foreign business in Federal jurisdiction', amalgamationType: AmalgamationTypes.REGULAR, type: AmlTypes.FOREIGN, - corpNumber: 'CA-3333333', + identifier: 'CA-3333333', legalName: 'My Federal Business', expectedBusinessType: 'Foreign', foreignJurisdiction: { @@ -111,7 +111,7 @@ describe('Business Table - display', () => { label: 'foreign business in USA jurisdiction', amalgamationType: AmalgamationTypes.REGULAR, type: AmlTypes.FOREIGN, - corpNumber: 'US-4444444', + identifier: 'US-4444444', legalName: 'My USA Business', expectedBusinessType: 'Foreign', foreignJurisdiction: { diff --git a/tests/unit/BusinessTableSummary.spec.ts b/tests/unit/BusinessTableSummary.spec.ts index fdd70ec4f..841196520 100644 --- a/tests/unit/BusinessTableSummary.spec.ts +++ b/tests/unit/BusinessTableSummary.spec.ts @@ -86,7 +86,7 @@ describe('Business Table Summary', () => { label: 'foreign business in Federal jurisdiction', amalgamationType: AmalgamationTypes.REGULAR, type: AmlTypes.FOREIGN, - corpNumber: 'CA-3333333', + identifier: 'CA-3333333', legalName: 'Test Business 3', foreignJurisdiction: { country: 'CA', @@ -99,7 +99,7 @@ describe('Business Table Summary', () => { label: 'foreign business in USA jurisdiction', amalgamationType: AmalgamationTypes.REGULAR, type: AmlTypes.FOREIGN, - corpNumber: 'US-4444444', + identifier: 'US-4444444', legalName: 'Test Business 4', foreignJurisdiction: { country: 'US'