Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18535 Amalgamating Businesses Part 1 Continuation #588

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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
Expand Up @@ -17,7 +17,7 @@
"@bcrs-shared-components/approval-type": "1.0.19",
"@bcrs-shared-components/base-address": "2.0.3",
"@bcrs-shared-components/breadcrumb": "2.1.15",
"@bcrs-shared-components/business-lookup": "1.2.3",
"@bcrs-shared-components/business-lookup": "1.2.4",
"@bcrs-shared-components/certify": "2.1.15",
"@bcrs-shared-components/completing-party": "2.1.30",
"@bcrs-shared-components/confirm-dialog": "1.2.1",
Expand Down
78 changes: 48 additions & 30 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
:showErrors="false"
:businessLookup="initialBusinessLookupObject"
:BusinessLookupServices="BusinessLookupServices"
legalTypes="BC,BEN,CC,ULC,A"
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
label="Business Name or Incorporation Number"
@setBusiness="saveAmalgamatingBusiness($event)"
/>
Expand Down Expand Up @@ -111,7 +112,8 @@
<template v-if="business.foundingDate">
Legal Name: {{ business.legalName }} <br>
Legal Type: {{ business.legalType }} <br>
Mailing Address: {{ business.officeAddress.mailingAddress }} <br>
Mailing Address: {{ business.officeAddress.registeredOffice.mailingAddress }} <br>
Email Address: {{ business.businessContact.email }} <br>
State: {{ business.state }} <br>
Good Standing: {{ business.goodStanding }} <br>
</template>
Expand Down Expand Up @@ -140,9 +142,10 @@ import { Component, Mixins } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import { useStore } from '@/store/store'
import { CommonMixin } from '@/mixins'
import { BusinessLookupServices, LegalServices } from '@/services'
import { AuthServices, BusinessLookupServices, LegalServices } from '@/services'
import { BusinessLookup } from '@bcrs-shared-components/business-lookup'
import { AmalgamatingBusinessIF, BusinessLookupIF, EmptyBusinessLookup } from '@/interfaces'
import { AmlRoles } from '@/enums'
import BusinessTable from '@/components/Amalgamation/BusinessTable.vue'

@Component({
Expand All @@ -153,11 +156,13 @@ import BusinessTable from '@/components/Amalgamation/BusinessTable.vue'
})
export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
@Getter(useStore) getAmalgamatingBusinesses!: AmalgamatingBusinessIF[]
@Getter(useStore) getAmalgamatingBusinessesValid!: boolean
@Getter(useStore) getShowErrors!: boolean
@Getter(useStore) isAmalgamationFilingHorizontal!: boolean
@Getter(useStore) isRoleStaff!: boolean

@Action(useStore) setAmalgamatingBusinesses!: (x: Array<any>) => void
@Action(useStore) setAmalgamatingBusinessesValid!: (x: boolean) => void

// Local properties
amalgamatingBusinessesValid = false
Expand All @@ -174,60 +179,73 @@ export default class AmalgamatingBusinesses extends Mixins(CommonMixin) {
// Cancel button in "Add an Amalgamating Business" is pressed.
addAmalgamatingBusinessCancel (): void {
this.isAddingAmalgamatingBusiness = false
this.setAmalgamatingBusinessesValid(true)
}

// "Add an Amalgamating Business" button is pressed.
onAddBusinessClick (): void {
this.isAddingAmalgamatingBusiness = true
this.isAddingAmalgamatingForeignBusiness = false
this.setAmalgamatingBusinessesValid(false)
}

// "Add an Amalgamating Foreign Business" button is pressed.
onAddForeignBusinessClick (): void {
this.isAddingAmalgamatingBusiness = false
this.isAddingAmalgamatingForeignBusiness = true
this.setAmalgamatingBusinessesValid(false)
}

async saveAmalgamatingBusiness (businessLookup: BusinessLookupIF): Promise<void> {
// Get the amalgamating business information
// Will have a different format depending on the business
let business = await LegalServices.fetchBusinessInfo(businessLookup.identifier)
.then((response) => {
return response?.data?.business
}).catch(() => {
return businessLookup
})

// Get the address of the amalgamating business
if (businessLookup.identifier && business.foundingDate) {
const addresses = await LegalServices.fetchAddresses(businessLookup.identifier)
.then((data) => {
// SP and GP have businessOffice instead of registeredOffice
return data?.registeredOffice || data?.businessOffice
}).catch(() => {
return undefined
})
if (addresses) {
business.officeAddress = addresses
}
let business = null

// Get the amalgamating business information, mailing address, and email if in LEAR.
// Otherwise, return the businesslookup object.
const data = await Promise.all([
LegalServices.fetchBusinessInfo(businessLookup.identifier),
AuthServices.fetchAuthInfo(businessLookup.identifier),
LegalServices.fetchAddresses(businessLookup.identifier)
]).catch((error) => {
return error
})

if (data.length === 3) {
business = data[0].data?.business
business.businessContact = data[1].contacts[0]
business.officeAddress = data[2]
}

const tingBusiness = {
type: 'lear',
role: AmlRoles.AMALGAMATING,
identifier: business.identifier,
name: business.legalName,
email: business.businessContact.email,
legalType: business.legalType,
address: business.officeAddress.registeredOffice.mailingAddress,
goodStanding: business.goodStanding
} as AmalgamatingBusinessIF

// If the business is not null (LEAR Entity)
// If the amalgamating businesses array is not empty, check if identifier already exists.
// If identifier already exists, don't add the business to the array.
if (this.amalgamatingBusinesses.length > 0) {
const businessExists = this.amalgamatingBusinesses.find(function (id) {
return id.identifier === business.identifier
})
if (!businessExists) this.amalgamatingBusinesses.push(business)
} else {
this.amalgamatingBusinesses.push(business)
if (business) {
Copy link
Collaborator Author

@JazzarKarim JazzarKarim Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only adding if the entity is not null (not a COLIN entity as per my discussion with Yui).

if (this.amalgamatingBusinesses) {
const businessExists = this.amalgamatingBusinesses.find(
(id) => id.identifier === business.identifier
)
if (!businessExists) this.amalgamatingBusinesses.push(tingBusiness)
} else {
this.amalgamatingBusinesses.push(tingBusiness)
}
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
}

// Set the amalgamated businesses array in the store.
this.setAmalgamatingBusinesses(this.amalgamatingBusinesses)

// Close the "Add an Amalgamating Business" Panel.
this.isAddingAmalgamatingBusiness = false
this.setAmalgamatingBusinessesValid(true)
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export type AmalgamatingBusinessIF = AmalgamatingLearIF | AmalgamatingForeignIF
export interface AmalgamationStateIF {
amalgamatingBusinesses: Array<AmalgamatingBusinessIF>
courtApproval: boolean
amalgamatingBusinessesValid: boolean
type: AmalgamationTypes
}
5 changes: 2 additions & 3 deletions src/services/business-lookup-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ export default class BusinessLookupServices {
* @param query code or words to search
* @returns a promise to return the search results
*/
static async search (query: string): Promise<BusinessLookupResultIF[]> {
const legalType = 'BC,A,ULC,C,S,XP,GP,LP,CUL,XS,LLC,LL,BEN,CP,CC,XL,FI,XCP,PA'
static async search (query: string, searchStatus: string, legalTypes: string): Promise<BusinessLookupResultIF[]> {
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
const url = this.businessApiUrl +
`businesses/search/facets?start=0&rows=20&categories=legalType:${legalType}::status:ACTIVE` +
`businesses/search/facets?start=0&rows=20&categories=legalType:${legalTypes}::status:ACTIVE` +
`&query=value:${encodeURIComponent(query)}`

return axios.get(url, {
Expand Down
1 change: 1 addition & 0 deletions src/store/state/state-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export const stateModel: StateModelIF = {
},
amalgamation: {
amalgamatingBusinesses: cloneDeep(AMALGAMATING_BUSINESSES),
amalgamatingBusinessesValid: false,
courtApproval: null,
type: null
},
Expand Down
8 changes: 8 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,11 @@ export const useStore = defineStore('store', {
return this.stateModel.amalgamation.amalgamatingBusinesses
},

/** The amalgamating businesses validity. */
getAmalgamatingBusinessesValid (): boolean {
return this.stateModel.amalgamation.amalgamatingBusinessesValid
},

//
// Dissolution getters
//
Expand Down Expand Up @@ -1224,6 +1229,9 @@ export const useStore = defineStore('store', {
setAmalgamatingBusinesses (amalgamatingBusinesses: Array<AmalgamatingBusinessIF>) {
this.stateModel.amalgamation.amalgamatingBusinesses = amalgamatingBusinesses
},
setAmalgamatingBusinessesValid (valid: boolean) {
this.stateModel.amalgamation.amalgamatingBusinessesValid = valid
},
setAmalgamationType (type: AmalgamationTypes) {
this.stateModel.amalgamation.type = type
},
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/business-lookup-services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ describe('Business Lookup Services', () => {
.returns(new Promise(resolve => resolve({ data: { searchResults: { results: [result] } } })))

// search and look at results
const results = await BusinessLookupServices.search('FM1000002')
const results = await BusinessLookupServices.search(
'FM1000002', 'ACTIVE', 'BC,A,ULC,C,S,XP,GP,LP,CUL,XS,LLC,LL,BEN,CP,CC,XL,FI,XCP,PA'
)
expect(results.length).toBe(1)
expect(results[0]).toEqual(result)

Expand All @@ -39,7 +41,9 @@ describe('Business Lookup Services', () => {
.returns(new Promise(resolve => resolve({ data: { searchResults: { results: [] } } })))

// search and look at results
const results = await BusinessLookupServices.search('FM1000003')
const results = await BusinessLookupServices.search(
'FM1000003', 'ACTIVE', 'BC,A,ULC,C,S,XP,GP,LP,CUL,XS,LLC,LL,BEN,CP,CC,XL,FI,XCP,PA'
)
expect(results.length).toBe(0)

sinon.restore()
Expand Down
Loading