Skip to content

Commit

Permalink
19201+19275+19216 More Amalgamation Fixes (bcgov#623)
Browse files Browse the repository at this point in the history
* Lots and lots of amalgamation fixes

* fixed rebase issue + updated package version

* added unit test for frozen rule

* fixed rebase issue

* Fixed in response to Sev's comments

* updated package version after rebase
  • Loading branch information
JazzarKarim committed Jan 26, 2024
1 parent d8bd0ef commit 58c1909
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 29 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.36",
"version": "5.6.37",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
10 changes: 7 additions & 3 deletions src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
legalType: business.businessInfo.legalType,
address: business.addresses.registeredOffice.mailingAddress,
isNotInGoodStanding: (business.businessInfo.goodStanding === false),
isFrozen: (business.businessInfo.adminFreeze === true),
isFutureEffective: this.isFutureEffective(business),
isPendingFiling: this.isPendingFiling(business),
isLimitedRestoration: await this.isLimitedRestoration(business),
Expand Down Expand Up @@ -422,11 +423,14 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
*/
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)
(b.type === AmlTypes.LEAR && b.identifier === business.businessInfo?.identifier) ||
(b.type === AmlTypes.FOREIGN && b.corpNumber === business.corpNumber)
)
if (checkDuplication) return true
if (checkDuplication) {
this.isAddingAmalgamatingBusiness = false
return true
}
return false
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Amalgamation/BusinessStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default class BusinessStatus extends Vue {
return 'A BC community contribution company must amalgamate to form a new BC community ' +
'contribution company.'
case AmlStatuses.ERROR_FROZEN:
return 'This business is frozen. Frozen businesses cannot be part of an amalgamation.'
case AmlStatuses.ERROR_FOREIGN:
return 'A foreign corporation cannot be amalgamated except by Registries staff.'
Expand Down
10 changes: 9 additions & 1 deletion src/components/Amalgamation/BusinessTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<script lang="ts">
import { Component, Emit, Mixins, Watch } from 'vue-property-decorator'
import { Action } from 'pinia-class'
import { Action, Getter } from 'pinia-class'
import { getName } from 'country-list'
import { useStore } from '@/store/store'
import { AmlStatuses, AmlRoles, AmlTypes } from '@/enums'
Expand All @@ -99,6 +99,8 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) {
readonly AmlTypes = AmlTypes
readonly GetCorpFullDescription = GetCorpFullDescription
@Getter(useStore) getNameRequestApprovedName!: string
@Action(useStore) spliceAmalgamatingBusiness!: (x: number) => void
/**
Expand Down Expand Up @@ -165,6 +167,12 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) {
}
removeBusiness (index: number): void {
// If the company to be deleted is selected as the resulting business name, reset values.
const business = this.getAmalgamatingBusinesses[index] as any
if (this.getNameRequestApprovedName && this.getNameRequestApprovedName === business.name) {
this.resetValues()
}
// Delete this item from amalgamating businesses list.
this.spliceAmalgamatingBusiness(index)
}
Expand Down
19 changes: 5 additions & 14 deletions src/components/Amalgamation/ResultingBusinessName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import { Getter, Action } from 'pinia-class'
import { Getter } from 'pinia-class'
import { useStore } from '@/store/store'
import { NameRequestMixin } from '@/mixins/'
import { AmalgamatingBusinessIF, EmptyNameRequest, NameRequestIF, NameTranslationIF } from '@/interfaces/'
import { AmalgamationMixin, NameRequestMixin } from '@/mixins/'
import { NameRequestIF } from '@/interfaces/'
import { LegalServices } from '@/services/'
import { CorrectNameOptions, NrRequestActionCodes } from '@bcrs-shared-components/enums/'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module/'
Expand All @@ -84,8 +84,7 @@ import NameTranslations from '@/components/common/NameTranslations.vue'
NameTranslations
}
})
export default class ResultingBusinessName extends Mixins(NameRequestMixin) {
@Getter(useStore) getAmalgamatingBusinesses!: AmalgamatingBusinessIF[]
export default class ResultingBusinessName extends Mixins(AmalgamationMixin, NameRequestMixin) {
@Getter(useStore) getBusinessId!: string
@Getter(useStore) getBusinessLegalName!: string
@Getter(useStore) getCorrectNameOption!: CorrectNameOptions
Expand All @@ -95,11 +94,6 @@ export default class ResultingBusinessName extends Mixins(NameRequestMixin) {
@Getter(useStore) getNameRequestNumber!: string
@Getter(useStore) getShowErrors!: boolean
@Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void
@Action(useStore) setNameRequest!: (x: NameRequestIF) => void
@Action(useStore) setNameRequestApprovedName!: (x: string) => void
@Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void
// Local properties
formType = null as CorrectNameOptions
Expand Down Expand Up @@ -151,10 +145,7 @@ export default class ResultingBusinessName extends Mixins(NameRequestMixin) {
/** Resets company name values to original when Cancel was clicked. */
resetName (): void {
// clear out existing data
this.setNameRequest(EmptyNameRequest)
this.setNameRequestApprovedName(null)
this.setCorrectNameOption(null)
this.setNameTranslations([])
this.resetValues()
// reset flag
this.formType = null
Expand Down
1 change: 1 addition & 0 deletions src/enums/amalgamationEnums.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum AmlStatuses {
OK,
ERROR_CCC_MISMATCH,
ERROR_FROZEN,
ERROR_FOREIGN,
ERROR_FOREIGN_HORIZONTAL,
ERROR_FOREIGN_UNLIMITED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface AmalgamatingLearIF {
address?: AddressIF
status?: AmlStatuses // computed status (base on business rules)
isNotInGoodStanding?: boolean // whether business is in good standing
isFrozen?: boolean // whether business is frozen
isFutureEffective?: boolean // whether business has a future effective filing
isPendingFiling?: boolean // whether business has a pending filing
isLimitedRestoration?: boolean // whether business is in limited restoration
Expand Down
32 changes: 28 additions & 4 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Component, Vue } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import { useStore } from '@/store/store'
import { AmlRoles, AmlStatuses, AmlTypes, EntityStates, FilingStatus, RestorationTypes } from '@/enums'
import { AmalgamatingBusinessIF } from '@/interfaces'
import { AmalgamatingBusinessIF, EmptyNameRequest, NameRequestIF, NameTranslationIF } from '@/interfaces'
import { CorrectNameOptions } from '@bcrs-shared-components/enums/'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
import { AuthServices, LegalServices } from '@/services'

Expand All @@ -20,11 +21,16 @@ export default class AmalgamationMixin extends Vue {
@Getter(useStore) isTypeBcUlcCompany!: boolean

@Action(useStore) setAmalgamatingBusinesses!: (x: Array<any>) => void
@Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void
@Action(useStore) setNameRequest!: (x: NameRequestIF) => void
@Action(useStore) setNameRequestApprovedName!: (x: string) => void
@Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void

/** Iterable array of rule functions, in order of processing. */
readonly rules = [
this.notAffiliated,
this.notHistorical,
this.notFrozen,
this.notInGoodStanding,
this.limitedRestoration,
this.futureEffectiveFiling,
Expand Down Expand Up @@ -58,6 +64,14 @@ export default class AmalgamationMixin extends Vue {
return null
}

/** Disallow frozen business. */
notFrozen (business: AmalgamatingBusinessIF): AmlStatuses {
if (business.type === AmlTypes.LEAR && business.isFrozen) {
return AmlStatuses.ERROR_FROZEN
}
return null
}

/** Disallow if NIGS (except for staff). */
notInGoodStanding (business: AmalgamatingBusinessIF): AmlStatuses {
if (!this.isRoleStaff && business.type === AmlTypes.LEAR && business.isNotInGoodStanding) {
Expand Down Expand Up @@ -169,6 +183,14 @@ export default class AmalgamationMixin extends Vue {
return null
}

/** Resets company name values to original in Resulting Business Name Component. */
resetValues (): void {
this.setNameRequest(EmptyNameRequest)
this.setNameRequestApprovedName(null)
this.setCorrectNameOption(null)
this.setNameTranslations([])
}

/**
* Get the business information, mailing address, email, and first filing if in LEAR.
* Otherwise, return error.
Expand Down Expand Up @@ -198,10 +220,11 @@ export default class AmalgamationMixin extends Vue {
// check for expired restoration
if (this.getCurrentDate > business.businessInfo.restorationExpiryDate) return false
// fetch state filing
const stateFiling = await LegalServices.fetchFiling(business.businessInfo.stateFiling)
const stateFiling =
await LegalServices.fetchFiling(business.businessInfo.stateFiling).catch(() => null) // on error, return null
return (
stateFiling.restoration.type === RestorationTypes.LIMITED ||
stateFiling.restoration.type === RestorationTypes.LTD_EXTEND
stateFiling?.restoration?.type === RestorationTypes.LIMITED ||
stateFiling?.restoration?.type === RestorationTypes.LTD_EXTEND
)
}

Expand Down Expand Up @@ -256,6 +279,7 @@ export default class AmalgamationMixin extends Vue {
legalType: tingBusiness.businessInfo.legalType,
address: tingBusiness.addresses?.registeredOffice.mailingAddress,
isNotInGoodStanding: (tingBusiness.businessInfo.goodStanding === false),
isFrozen: (tingBusiness.businessInfo.adminFreeze === true),
isFutureEffective: this.isFutureEffective(tingBusiness),
isPendingFiling: this.isPendingFiling(tingBusiness),
isLimitedRestoration: await this.isLimitedRestoration(tingBusiness),
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/BusinessStatus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ describe('Business Status', () => {
status: AmlStatuses.ERROR_CCC_MISMATCH,
tooltip: 'A BC community contribution company must amalgamate to form a new BC community'
},
{
label: 'Error FROZEN',
status: AmlStatuses.ERROR_FROZEN,
tooltip: 'This business is frozen. Frozen businesses cannot be part of an amalgamation.'
},
{
label: 'Error Foreign',
status: AmlStatuses.ERROR_FOREIGN,
Expand Down Expand Up @@ -82,7 +87,7 @@ describe('Business Status', () => {
]

it('has the expected number of tests', () => {
expect(tests.length).toBe(1 + 14) // OK + 14 errors
expect(tests.length).toBe(1 + 15) // OK + 14 errors
})

for (const test of tests) {
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ describe.skip('Business Table - rule evaluation', () => {
const rules = [
{ methodName: 'notAffiliated', error: AmlStatuses.ERROR_NOT_AFFILIATED },
{ methodName: 'notHistorical', error: AmlStatuses.ERROR_HISTORICAL },
{ methodName: 'notFrozen', error: AmlStatuses.ERROR_FROZEN },
{ methodName: 'notInGoodStanding', error: AmlStatuses.ERROR_NOT_IN_GOOD_STANDING },
{ methodName: 'limitedRestoration', error: AmlStatuses.ERROR_LIMITED_RESTORATION },
{ methodName: 'futureEffectiveFiling', error: AmlStatuses.ERROR_FUTURE_EFFECTIVE_FILING },
Expand Down Expand Up @@ -221,8 +222,8 @@ describe.skip('Business Table - rule evaluation', () => {
})

it('has the expected number of rules', () => {
expect(rules.length).toBe(14)
expect(wrapper.vm.rules.length).toBe(14)
expect(rules.length).toBe(15)
expect(wrapper.vm.rules.length).toBe(15)
})

// check each rule sequentially
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/amalgamation-mixin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Amalgamation Mixin - rules', () => {
})

it('has the expected number of rules', () => {
expect(wrapper.vm.rules.length).toBe(14)
expect(wrapper.vm.rules.length).toBe(15)
})

it('correctly evaluates "notAffiliated" rule', () => {
Expand Down Expand Up @@ -54,6 +54,17 @@ describe('Amalgamation Mixin - rules', () => {
expect(wrapper.vm.notHistorical({ type: AmlTypes.LEAR, isHistorical: false })).toBeNull()
})

it('correctly evaluates "notFrozen" rule', () => {
// verify rule
expect(wrapper.vm.notFrozen({ type: AmlTypes.LEAR, isFrozen: true })).toBe(AmlStatuses.ERROR_FROZEN)

// verify not LEAR only
expect(wrapper.vm.notFrozen({ type: AmlTypes.FOREIGN, isFrozen: true })).toBeNull()

// verify not frozen only
expect(wrapper.vm.notFrozen({ type: AmlTypes.LEAR, isFrozen: false })).toBeNull()
})

it('correctly evaluates "notInGoodStanding" rule', () => {
// init
store.setKeycloakRoles([])
Expand Down

0 comments on commit 58c1909

Please # to comment.