Skip to content

Commit

Permalink
19019 Add extra-pro A TING companies (#605)
Browse files Browse the repository at this point in the history
* Add extra-pro TING companies

* Updated in response to Sev's comments

* updated package version after rebasing

* Fixed in response to Sev's comments

* fixed name

* removed unneeded comment

* extra empty line
  • Loading branch information
JazzarKarim authored Dec 28, 2023
1 parent 724ff5e commit b4cadcc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 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.6.19",
"version": "5.6.20",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
52 changes: 50 additions & 2 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ import { AmalgamationMixin, CommonMixin } from '@/mixins'
import { BusinessLookupServices } from '@/services'
import { BusinessLookup } from '@bcrs-shared-components/business-lookup'
import { Jurisdiction } from '@bcrs-shared-components/jurisdiction'
import { MrasJurisdictions } from '@bcrs-shared-components/jurisdiction/list-data'
import { CanJurisdictions, MrasJurisdictions } from '@bcrs-shared-components/jurisdiction/list-data'
import { AmalgamatingBusinessIF, BusinessLookupResultIF, EmptyBusinessLookup } from '@/interfaces'
import { AmlRoles, AmlTypes, EntityStates } from '@/enums'
import { JurisdictionLocation } from '@bcrs-shared-components/enums'
Expand Down Expand Up @@ -276,6 +276,40 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
// Show spinner since the network calls below can take a few seconds.
this.$root.$emit('showSpinner', true)
// Special case to handle Extra-pro A companies
if ((businessLookup.legalType as any) === CorpTypeCd.EXTRA_PRO_A) {
const region = CanJurisdictions.find(jurisdiction => jurisdiction.value === JurisdictionLocation.BC)
const tingBusiness = {
type: AmlTypes.FOREIGN,
role: AmlRoles.AMALGAMATING,
foreignJurisdiction: {
region: region.text,
country: JurisdictionLocation.CA
},
legalName: businessLookup.name,
corpNumber: businessLookup.identifier
} as AmalgamatingBusinessIF
// Check for duplicate
if (this.checkForDuplicateInTable(tingBusiness)) {
this.snackbarText = 'Business is already in table.'
this.snackbar = true
// Hide spinner.
this.$root.$emit('showSpinner', false)
return
}
this.pushAmalgamatingBusiness(tingBusiness)
// Close the "Add an Amalgamating Business" panel.
this.isAddingAmalgamatingBusiness = false
// Hide spinner.
this.$root.$emit('showSpinner', false)
return
}
// Get the business information
const business = await this.fetchAmalgamatingBusinessInfo(businessLookup)
Expand Down Expand Up @@ -322,7 +356,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
}
// Check for duplicate.
if (this.getAmalgamatingBusinesses.find((b: any) => b.identifier === business.businessInfo.identifier)) {
if (this.checkForDuplicateInTable(business)) {
this.snackbarText = 'Business is already in table.'
this.snackbar = true
Expand Down Expand Up @@ -381,6 +415,20 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
this.isAddingAmalgamatingForeignBusiness = false
}
/**
* Check if business is already in table.
* @param business The business being added.
*/
checkForDuplicateInTable (business: any): boolean {
const checkDuplication = this.getAmalgamatingBusinesses.find((b: any) =>
(business.type === AmlTypes.LEAR && b.identifier === business.businessInfo.identifier) ||
(business.type === AmlTypes.FOREIGN && b.corpNumber === business.corpNumber)
)
if (checkDuplication) return true
return false
}
/** Validate Add Amalgamating Foreign Business. */
validateAddAmalgamatingForeignBusiness (): void {
this.isForeignBusinessValid = (
Expand Down
15 changes: 1 addition & 14 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export default class AmalgamationMixin extends Vue {
if (!this.isRoleStaff && business.type === AmlTypes.FOREIGN) {
return AmlStatuses.ERROR_FOREIGN
}
if (!this.isRoleStaff && business.type === AmlTypes.LEAR && business.legalType === CorpTypeCd.EXTRA_PRO_A) {
return AmlStatuses.ERROR_FOREIGN
}
return null
}

Expand Down Expand Up @@ -121,8 +118,7 @@ export default class AmalgamationMixin extends Vue {
/** Disallow extra-pro (A company) into ULC or CCC. */
xproUlcCcc (business: AmalgamatingBusinessIF): AmlStatuses {
if (
business.type === AmlTypes.LEAR &&
business.legalType === CorpTypeCd.EXTRA_PRO_A &&
business.type === AmlTypes.FOREIGN &&
(!this.isTypeBcUlcCompany || !this.isTypeBcCcc)
) {
return AmlStatuses.ERROR_XPRO_ULC_CCC
Expand Down Expand Up @@ -250,15 +246,6 @@ export default class AmalgamationMixin extends Vue {
return this.getAmalgamatingBusinesses.every(business => (business.type === AmlTypes.FOREIGN))
}

/** True if all companies in the table are foreign or extra-provincial. */
get isAllForeignOrEp (): boolean {
return this.getAmalgamatingBusinesses.every(business =>
(business.type === AmlTypes.FOREIGN ||
(business.type === AmlTypes.LEAR && business.legalType === CorpTypeCd.EXTRA_PRO_A)
)
)
}

/** True if there a foreign company in the table. */
get isAnyForeign (): boolean {
return this.getAmalgamatingBusinesses.some(business => (business.type === AmlTypes.FOREIGN))
Expand Down

0 comments on commit b4cadcc

Please sign in to comment.