diff --git a/package-lock.json b/package-lock.json index 931f0fbfc..0bc814265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.8.4", + "version": "5.8.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.8.4", + "version": "5.8.5", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.0.19", diff --git a/package.json b/package.json index 1bd2180fb..20302f2d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.8.4", + "version": "5.8.5", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/Amalgamation/AmalgamatingBusinesses.vue b/src/components/Amalgamation/AmalgamatingBusinesses.vue index ddec7a033..41d41e025 100644 --- a/src/components/Amalgamation/AmalgamatingBusinesses.vue +++ b/src/components/Amalgamation/AmalgamatingBusinesses.vue @@ -491,7 +491,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co role: AmlRoles.AMALGAMATING, identifier: business.businessInfo.identifier, name: business.businessInfo.legalName, - email: business.authInfo.contacts[0].email, + authInfo: business.authInfo, legalType: business.businessInfo.legalType, addresses: business.addresses, isNotInGoodStanding: (business.businessInfo.goodStanding === false), diff --git a/src/components/Amalgamation/BusinessTable.vue b/src/components/Amalgamation/BusinessTable.vue index 02107d1bb..b7a3e908b 100644 --- a/src/components/Amalgamation/BusinessTable.vue +++ b/src/components/Amalgamation/BusinessTable.vue @@ -208,7 +208,7 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) { } email (item: AmalgamatingBusinessIF): string { - if (item?.type === AmlTypes.LEAR) return item.email + if (item?.type === AmlTypes.LEAR) return item.authInfo?.contacts[0]?.email return null // should never happen } diff --git a/src/components/Amalgamation/BusinessTableSummary.vue b/src/components/Amalgamation/BusinessTableSummary.vue index c8ace4a2a..f6642a11b 100644 --- a/src/components/Amalgamation/BusinessTableSummary.vue +++ b/src/components/Amalgamation/BusinessTableSummary.vue @@ -85,7 +85,7 @@ export default class BusinessTableSummary extends Vue { } email (item: AmalgamatingBusinessIF): string { - if (item?.type === AmlTypes.LEAR) return item.email + if (item?.type === AmlTypes.LEAR) return item.authInfo?.contacts[0]?.email return null // should never happen } 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 efd997160..7cc756949 100644 --- a/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts +++ b/src/interfaces/store-interfaces/state-interfaces/amalgamation-state-interface.ts @@ -1,4 +1,4 @@ -import { RegisteredRecordsAddressesIF } from '@/interfaces' +import { AuthInformationIF, RegisteredRecordsAddressesIF } from '@/interfaces' import { AmlStatuses, AmalgamationTypes, AmlRoles, AmlTypes } from '@/enums' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' @@ -12,7 +12,7 @@ interface AmalgamatingLearIF { // properties for UI only: name?: string - email?: string + authInfo?: AuthInformationIF legalType?: CorpTypeCd addresses?: RegisteredRecordsAddressesIF status?: AmlStatuses // computed status (base on business rules) diff --git a/src/mixins/amalgamation-mixin.ts b/src/mixins/amalgamation-mixin.ts index f466fa693..324502019 100644 --- a/src/mixins/amalgamation-mixin.ts +++ b/src/mixins/amalgamation-mixin.ts @@ -5,8 +5,8 @@ import { AmlRoles, AmlStatuses, AmlTypes, EntityStates, FilingStatus, RestorationTypes, RoleTypes } from '@/enums' import { - AmalgamatingBusinessIF, ContactPointIF, EmptyNameRequest, NameRequestIF, NameTranslationIF, - OrgPersonIF, PeopleAndRoleIF, RegisteredRecordsAddressesIF, ShareClassIF + AmalgamatingBusinessIF, ContactPointIF, EmptyContactPoint, EmptyNameRequest, NameRequestIF, + NameTranslationIF, OrgPersonIF, PeopleAndRoleIF, RegisteredRecordsAddressesIF, ShareClassIF } from '@/interfaces' import { CorrectNameOptions } from '@bcrs-shared-components/enums/' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' @@ -216,6 +216,7 @@ export default class AmalgamationMixin extends Vue { /** * Fetches the business' auth information, business info, addresses, first task, and first filing. * @param identifier The business identifier. + * @returns An object of business information sub-objects, some of which may be null. */ async fetchAmalgamatingBusinessInfo (identifier: string): Promise { // Make all API calls concurrently without rejection. @@ -309,7 +310,7 @@ export default class AmalgamationMixin extends Vue { role: item.role, // amalgamating or holding identifier: tingBusiness.businessInfo.identifier, name: tingBusiness.businessInfo.legalName, - email: tingBusiness.authInfo?.contacts[0].email, + authInfo: tingBusiness.authInfo, legalType: tingBusiness.businessInfo.legalType, addresses: tingBusiness.addresses, isNotInGoodStanding: (tingBusiness.businessInfo.goodStanding === false), @@ -344,21 +345,19 @@ export default class AmalgamationMixin extends Vue { throw new Error('updatePrepopulatedData(): invalid business') } - // first, fetch new directors/share structure/auth info - // NB - business addresses have already been fetched + // first, fetch directors and share structure + // NB - addresses and auth info have already been fetched // NB - make all API calls concurrently without rejection // NB - if any call failed, that item will be null - const [ directors, shareStructure, authInfo ] = + const [ directors, shareStructure ] = await Promise.allSettled([ LegalServices.fetchDirectors(business.identifier), - LegalServices.fetchShareStructure(business.identifier), - AuthServices.fetchAuthInfo(business.identifier) + LegalServices.fetchShareStructure(business.identifier) ]).then(results => results.map((result: any) => result.value || null)) // check for errors before changing anything if (!directors) throw new Error('Unable to fetch directors') if (!shareStructure) throw new Error('Unable to fetch share structure') - if (!authInfo) throw new Error('Unable to fetch auth info') // unset previous holding/primary business, if any const previous = this.getAmalgamatingBusinesses.find((b: AmalgamatingBusinessIF) => @@ -388,12 +387,17 @@ export default class AmalgamationMixin extends Vue { // overwrite business contact -- only when user has marked new holding/primary business, // otherwise leave existing data from restored draft if (isNew) { - this.setBusinessContact({ - email: authInfo.contacts[0].email, - confirmEmail: authInfo.contacts[0].email, - phone: authInfo.contacts[0].phone, - extension: authInfo.contacts[0].extension - }) + if (business.authInfo?.contacts[0]) { + this.setBusinessContact({ + email: business.authInfo.contacts[0].email, + confirmEmail: business.authInfo.contacts[0].email, + phone: business.authInfo.contacts[0].phone, + extension: business.authInfo.contacts[0].extension + }) + } else { + // safety check - clear old business contact + this.setBusinessContact({ ...EmptyContactPoint }) + } } // set new resulting business name and type diff --git a/src/mixins/filing-template-mixin.ts b/src/mixins/filing-template-mixin.ts index 08c2f30c6..8bdd8497e 100644 --- a/src/mixins/filing-template-mixin.ts +++ b/src/mixins/filing-template-mixin.ts @@ -248,7 +248,7 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM // (eg, became historical) since the last draft save. const holdingPrimary = await this.refetchAmalgamatingBusinessesInfo() // If there's a holding or primary business, fetch its data and update the prepopulated data. - // This will overwrite office addresses, directors and share structure from above. + // This will overwrite office addresses, directors and share structure that were set above. if (holdingPrimary) await this.updatePrepopulatedData(holdingPrimary) } diff --git a/tests/unit/AmalgamatingBusinesses.spec.ts b/tests/unit/AmalgamatingBusinesses.spec.ts index dac68b94f..7be6edfcb 100644 --- a/tests/unit/AmalgamatingBusinesses.spec.ts +++ b/tests/unit/AmalgamatingBusinesses.spec.ts @@ -497,9 +497,9 @@ describe('Amalgamating Businesses - add amalgamating business', () => { expect(business.role).toBe(AmlRoles.AMALGAMATING) expect(business.identifier).toBe('BC1234567') expect(business.name).toBe('My BC Business') - expect(business.email).toBe('email@example.com') + expect(business.authInfo.contacts[0].email).toBe('email@example.com') expect(business.legalType).toBe(CorpTypeCd.BC_COMPANY) - expect(business.address.streetAddress).toBe('123 Main St') + expect(business.addresses.registeredOffice.mailingAddress.streetAddress).toBe('123 Main St') expect(business.isNotInGoodStanding).toBe(false) expect(business.isFrozen).toBe(false) expect(business.isFutureEffective).toBe(false) diff --git a/tests/unit/BusinessTable.spec.ts b/tests/unit/BusinessTable.spec.ts index 0eac76cd4..3115a8a69 100644 --- a/tests/unit/BusinessTable.spec.ts +++ b/tests/unit/BusinessTable.spec.ts @@ -45,12 +45,16 @@ describe('Business Table - display', () => { type: AmlTypes.LEAR, identifier: 'BC1111111', name: 'My BC Limited Company', - email: 'bc1111111@example.com', - address: { - streetAddress: '123 Main St', - addressCity: 'Victoria', - addressCountry: 'CA', - postalCode: 'V8V 8V8' + authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] }, + addresses: { + registeredOffice: { + mailingAddress: { + streetAddress: '123 Main St', + addressCity: 'Victoria', + addressCountry: 'CA', + postalCode: 'V8V 8V8' + } + } }, legalType: CorpTypeCd.BC_COMPANY, expectedBusinessType: 'BC Limited Company', @@ -62,12 +66,16 @@ describe('Business Table - display', () => { type: AmlTypes.LEAR, identifier: 'BC1111111', name: 'My BC Limited Company', - email: 'bc1111111@example.com', - address: { - streetAddress: '123 Main St', - addressCity: 'Victoria', - addressCountry: 'CA', - postalCode: 'V8V 8V8' + authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] }, + addresses: { + registeredOffice: { + mailingAddress: { + streetAddress: '123 Main St', + addressCity: 'Victoria', + addressCountry: 'CA', + postalCode: 'V8V 8V8' + } + } }, legalType: CorpTypeCd.BC_COMPANY, expectedBusinessType: 'BC Limited Company', @@ -79,7 +87,7 @@ describe('Business Table - display', () => { type: AmlTypes.LEAR, identifier: 'BC2222222', name: 'My Benefit Company', - email: 'bc2222222@example.com', + authInfo: { contacts: [ { email: 'bc2222222@example.com' } ] }, address: undefined, legalType: CorpTypeCd.BENEFIT_COMPANY, expectedBusinessType: 'BC Benefit Company', @@ -156,15 +164,15 @@ describe('Business Table - display', () => { if ((business.type === AmlTypes.LEAR)) { expect(td.at(0).text()).toContain(business.name) - expect(td.at(0).text()).toContain(business.email) + expect(td.at(0).text()).toContain(business.authInfo.contacts[0].email) expect(td.at(1).text()).toContain(business.expectedBusinessType) - if (business.address) { - expect(td.at(2).text()).toContain(business.address.streetAddress) - expect(td.at(2).text()).toContain(business.address.addressCity) + if (business.addresses) { + expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.streetAddress) + expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.addressCity) expect(td.at(2).text()).toContain('Canada') - expect(td.at(2).text()).toContain(business.address.postalCode) + expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.postalCode) } else { expect(td.at(2).text()).toBe('Affiliate to view') } @@ -181,7 +189,10 @@ describe('Business Table - display', () => { expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests - expect(td.at(5).find('.v-btn').exists()).toBe(true) + if (business.role === AmlRoles.AMALGAMATING) { + // button only exists on amalgamating businesses (not holding or primary) + expect(td.at(5).find('.v-btn').exists()).toBe(true) + } } if ((business.type === AmlTypes.FOREIGN)) { @@ -243,12 +254,12 @@ describe('Business Table - validity', () => { amalgamatingBusinesses: [ // both of these will be status "OK" { - address: {}, + addresses: {}, legalType: CorpTypeCd.BC_COMPANY, type: AmlTypes.LEAR }, { - address: {}, + addresses: {}, legalType: CorpTypeCd.BC_COMPANY, type: AmlTypes.LEAR } diff --git a/tests/unit/BusinessTableSummary.spec.ts b/tests/unit/BusinessTableSummary.spec.ts index de90b6149..fdd70ec4f 100644 --- a/tests/unit/BusinessTableSummary.spec.ts +++ b/tests/unit/BusinessTableSummary.spec.ts @@ -40,12 +40,16 @@ describe('Business Table Summary', () => { type: AmlTypes.LEAR, identifier: 'BC1111111', name: 'Test Business 1', - email: 'bc1111111@example.com', - address: { - streetAddress: '123 Main St', - addressCity: 'Victoria', - addressCountry: 'CA', - postalCode: 'V8V 8V8' + authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] }, + addresses: { + registeredOffice: { + mailingAddress: { + streetAddress: '123 Main St', + addressCity: 'Victoria', + addressCountry: 'CA', + postalCode: 'V8V 8V8' + } + } }, role: AmlRoles.PRIMARY }, @@ -55,12 +59,16 @@ describe('Business Table Summary', () => { type: AmlTypes.LEAR, identifier: 'BC1111111', name: 'Test Business 1', - email: 'bc1111111@example.com', - address: { - streetAddress: '123 Main St', - addressCity: 'Victoria', - addressCountry: 'CA', - postalCode: 'V8V 8V8' + authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] }, + addresses: { + registeredOffice: { + mailingAddress: { + streetAddress: '123 Main St', + addressCity: 'Victoria', + addressCountry: 'CA', + postalCode: 'V8V 8V8' + } + } }, role: AmlRoles.HOLDING }, @@ -70,7 +78,7 @@ describe('Business Table Summary', () => { type: AmlTypes.LEAR, identifier: 'BC2222222', name: 'Test Business 2', - email: 'bc2222222@example.com', + authInfo: { contacts: [ { email: 'bc2222222@example.com' } ] }, address: undefined, role: AmlRoles.AMALGAMATING }, @@ -134,13 +142,13 @@ describe('Business Table Summary', () => { if ((business.type === AmlTypes.LEAR)) { expect(td.at(0).text()).toContain(business.name) - expect(td.at(0).text()).toContain(business.email) + expect(td.at(0).text()).toContain(business.authInfo.contacts[0].email) - if (business.address) { - expect(td.at(1).text()).toContain(business.address.streetAddress) - expect(td.at(1).text()).toContain(business.address.addressCity) + if (business.addresses) { + expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.streetAddress) + expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.addressCity) expect(td.at(1).text()).toContain('Canada') - expect(td.at(1).text()).toContain(business.address.postalCode) + expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.postalCode) } else { expect(td.at(1).text()).toBe('Affiliate to view') } diff --git a/tests/unit/amalgamation-mixin.spec.ts b/tests/unit/amalgamation-mixin.spec.ts index 468f69043..7ac605486 100644 --- a/tests/unit/amalgamation-mixin.spec.ts +++ b/tests/unit/amalgamation-mixin.spec.ts @@ -29,18 +29,18 @@ describe('Amalgamation Mixin - rules', () => { store.setKeycloakRoles([]) // verify rule - expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: null })).toBe(AmlStatuses.ERROR_NOT_AFFILIATED) + expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: null })).toBe(AmlStatuses.ERROR_NOT_AFFILIATED) // verify staff only store.setKeycloakRoles(['staff']) - expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: null })).toBeNull() + expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: null })).toBeNull() store.setKeycloakRoles([]) // verify not LEAR only - expect(wrapper.vm.notAffiliated({ type: AmlTypes.FOREIGN, address: null })).toBeNull() + expect(wrapper.vm.notAffiliated({ type: AmlTypes.FOREIGN, addresses: null })).toBeNull() // verify address exists only - expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: {} })).toBeNull() + expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: {} })).toBeNull() }) it('correctly evaluates "notHistorical" rule', () => {