Skip to content

Commit

Permalink
Add extra-pro TING companies
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Dec 21, 2023
1 parent d98100d commit b27605a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 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.17",
"version": "5.6.18",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
58 changes: 53 additions & 5 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,34 @@ 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 === 'A') {
const tingBusiness = {
type: AmlTypes.FOREIGN,
role: AmlRoles.AMALGAMATING,
foreignJurisdiction: {
region: 'British Columbia',
country: 'CA'
},
legalName: businessLookup.name,
corpNumber: businessLookup.identifier
} as AmalgamatingBusinessIF
// Check for duplicate
if (this.checkForDuplicateInTable(tingBusiness, 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,13 +350,9 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
}
// Check for duplicate.
if (this.getAmalgamatingBusinesses.find((b: any) => b.identifier === business.businessInfo.identifier)) {
this.snackbarText = 'Business is already in table.'
this.snackbar = true
if (this.checkForDuplicateInTable(business, false)) {
// Hide spinner.
this.$root.$emit('showSpinner', false)
return
}
Expand Down Expand Up @@ -381,6 +405,30 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
this.isAddingAmalgamatingForeignBusiness = false
}
/**
* Check if business is already in table and display snackbar text.
* @param business The business being added.
* @param extraPro Whether we are adding an extra provincial company or not (A companies).
*/
checkForDuplicateInTable (business: any, extraPro: boolean): boolean {
// Check if duplicate exists for a company that is not an extra-provincial.
const duplicateNonExtraPro = !extraPro &&
this.getAmalgamatingBusinesses.find(
(b: any) => (b.identifier && b.identifier === business.businessInfo.identifier))
// Check if duplicate exists for a company that is an extra-provincial (A company).
const duplicateExtraPro = extraPro &&
this.getAmalgamatingBusinesses.find(
(b: any) => (b.corpNumber && b.corpNumber === business.corpNumber))
if (duplicateNonExtraPro || duplicateExtraPro) {
this.snackbarText = 'Business is already in table.'
this.snackbar = true
return true
}
return false
}
/** Validate Add Amalgamating Foreign Business. */
validateAddAmalgamatingForeignBusiness (): void {
this.isForeignBusinessValid = (
Expand Down
15 changes: 3 additions & 12 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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) {
if (!this.isRoleStaff && business.type === AmlTypes.FOREIGN && business.corpNumber[0] === CorpTypeCd.EXTRA_PRO_A) {
return AmlStatuses.ERROR_FOREIGN
}
return null
Expand Down Expand Up @@ -121,8 +121,8 @@ 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 &&
business.corpNumber[0] === CorpTypeCd.EXTRA_PRO_A &&
(!this.isTypeBcUlcCompany || !this.isTypeBcCcc)
) {
return AmlStatuses.ERROR_XPRO_ULC_CCC
Expand Down Expand Up @@ -248,15 +248,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 b27605a

Please sign in to comment.