Skip to content

Commit

Permalink
19561 corpNumber to identifier in foreign amalgamating business (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Feb 2, 2024
1 parent 267c612 commit 4261f17
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 52 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
19 changes: 9 additions & 10 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@
>
<v-text-field
id="foreign-business-corp-number"
v-model="corpNumber"
v-model="identifier"
filled
label="Corporate number in home jurisdiction"
:rules="foreignBusinessCorpNumberRules"
:rules="foreignBusinessIdentifierRules"
/>
</v-col>
<v-col
Expand Down Expand Up @@ -309,7 +309,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
// Foreign business properties
jurisdiction = null
legalName = null
corpNumber = null
identifier = null
isCan = false
isMrasJurisdiction = false
jurisdictionErrorMessage = ''
Expand All @@ -327,7 +327,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
]
}
get foreignBusinessCorpNumberRules (): Array<(v: string) => boolean | string> {
get foreignBusinessIdentifierRules (): Array<(v: string) => boolean | string> {
return [
v => (!this.isMrasJurisdiction || (!!v && /^[0-9a-zA-Z-]+$/.test(v))) ||
'Corporate number is required',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
Expand All @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Amalgamation/BusinessTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 1 addition & 7 deletions src/components/Amalgamation/BusinessTableSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<tr
v-for="item in getAmalgamatingBusinesses"
:key="key(item)"
:key="item.identifier"
>
<td class="business-name">
<v-icon color="gray9">
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface AmalgamatingForeignIF {
country: string
}
legalName: string
corpNumber: string
identifier: string

// properties for UI only:
status?: AmlStatuses
Expand Down
10 changes: 5 additions & 5 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,17 @@ export default class AmalgamationMixin extends Vue {
*/
async refetchAmalgamatingBusinessesInfo (): Promise<AmalgamatingBusinessIF> {
const fetchTingInfo = async (item: any): Promise<AmalgamatingBusinessIF> => {
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
Expand Down
38 changes: 19 additions & 19 deletions tests/unit/AmalgamatingBusinesses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
})

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/BusinessTableSummary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'
Expand Down

0 comments on commit 4261f17

Please sign in to comment.