Skip to content

Commit

Permalink
16577 - Alteration - Name Request changes (#518)
Browse files Browse the repository at this point in the history
* Fix getUpdatedName, implement nameRequestRequiredError for non-numbered companies.

* Minor tweak for getUpdatedName

* Changes as per the design spec, set the company type via company name.

* Comment update

* Tweak for business type

* Go into edit mode when entityTypeChangedByName, also disable dropdown.

* Tweak for editing

* Package + package lock

* Logic error

* Move resetType back

* Unit test fixes.

* Fix typescript errors in unit tests

* Remove flushpromises.

* Update package + package.lock
  • Loading branch information
seeker25 authored Jul 25, 2023
1 parent c3b5106 commit 7f2c6f4
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 30 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-edit-ui",
"version": "4.5.3",
"version": "4.5.4",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
71 changes: 61 additions & 10 deletions src/components/common/YourCompany/ChangeBusinessType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@
<v-select
id="business-type-selector"
v-model="selectedEntityType"
:disabled="isEntityTypeChangedByName"
:items="entityTypeOptions"
hint="Select a New Business Type"
:hint="isEntityTypeChangedByName ? '' : 'Select a New Business Type'"
persistent-hint
filled
>
Expand All @@ -112,13 +113,25 @@

<div
v-if="minimumThreeDirectorError"
id="minimum-three-director-error"
class="my-6"
>
<p class="error-text">
The business type cannot be changed. A Community Contribution Company requires a minimum of three directors.
</p>
</div>

<div
v-if="nameRequestRequiredError"
id="name-request-required-error"
class="my-6"
>
<p class="error-text">
An alteration of business type Name Request is required to make this change. After the name is approved,
you can then select 'change' beside the company name to update it.
</p>
</div>

<div class="my-6">
<p class="info-text">
Businesses can only be altered to specific types. If the business type you want is
Expand All @@ -145,7 +158,7 @@
id="done-btn"
large
color="primary"
:disabled="!confirmArticles || minimumThreeDirectorError"
:disabled="disableDoneButton"
@click="submitTypeChange()"
>
<span>Done</span>
Expand All @@ -169,7 +182,10 @@
cols="2"
class="mt-n2"
>
<div class="actions mr-4">
<div
v-if="!isEntityTypeChangedByName"
class="actions mr-4"
>
<v-btn
v-if="hasBusinessTypeChanged"
id="btn-undo-business-type"
Expand Down Expand Up @@ -276,6 +292,7 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
@Getter(useStore) isBenefitCompany!: boolean
@Getter(useStore) isBcUlcCompany!: boolean
@Getter(useStore) isConflictingLegalType!: boolean
@Getter(useStore) isEntityTypeChangedByName!: boolean
@Getter(useStore) isNameChangedByType!: boolean
@Getter(useStore) isNumberedCompany!: boolean
Expand Down Expand Up @@ -307,6 +324,12 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
this.confirmArticles = false
}
/** Display the edit, so the user has to reconfirm articles. */
@Watch('isEntityTypeChangedByName')
entityTypeChangedByName (val): void {
this.isEditingType = val
}
/** Verify New Business name. */
get isNewName (): boolean {
return this.getNameRequestLegalName &&
Expand Down Expand Up @@ -334,12 +357,27 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
return this.supportedEntityTypes?.includes(this.getEntitySnapshot?.businessInfo?.legalType)
}
get nameRequestRequiredError (): boolean {
if (this.isNumberedCompany) {
return false
}
// Named companies to CC or ULC require a name request.
if (this.isCommunityContribution || this.isUnlimitedLiability) {
return true
}
// Named ULC to BC Limited require a name request.
if (this.getEntitySnapshot?.businessInfo?.legalType === CorpTypeCd.BC_ULC_COMPANY && this.isBcLimited) {
return true
}
return false
}
get minimumThreeDirectorError (): boolean {
return this.isCommunityContribution && this.getNumberOfDirectors < 3
}
/** Reset company type values to original. */
protected resetType () {
resetType () {
this.setEntityType(this.getEntitySnapshot?.businessInfo?.legalType)
// reset name request
this.setNameRequest({
Expand All @@ -353,7 +391,7 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
}
/** Submit new company type. */
protected submitTypeChange () {
submitTypeChange () {
this.setEntityType(this.selectedEntityType)
this.isEditingType = false
Expand All @@ -379,12 +417,21 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
}
getUpdatedName (originalName: string): string {
if (this.isUnlimitedLiability || this.isCommunityContribution) {
return originalName.endsWith(' LTD.') ? originalName : originalName + ' LTD.'
} else if (this.isBcLimited && this.isBcUlcCompany) {
return originalName.replace(/\sLTD\.$/, '')
if (this.isBcUlcCompany) {
originalName = originalName.replace(' LTD.', '')
originalName += ' UNLIMITED LIABILITY COMPANY'
return originalName
} else if (this.isCommunityContribution) {
originalName = originalName.replace(' LTD.', '')
originalName += ' COMMUNITY CONTRIBUTION COMPANY'
return originalName
} else if (this.isBcLimited || this.isBenefitCompany) {
originalName = originalName.replace(' UNLIMITED LIABILITY COMPANY', '').replace(' ULC', '')
originalName = originalName.replace(' COMMUNITY CONTRIBUTION COMPANY', '').replace(' CCC', '')
originalName = originalName.replace(' LTD.', '')
originalName += ' LTD.'
return originalName
}
return originalName
}
Expand Down Expand Up @@ -416,6 +463,10 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
return ResourceUtilities.articleTitle(this.selectedEntityType)
}
get disableDoneButton (): boolean {
return !this.confirmArticles || this.minimumThreeDirectorError || this.nameRequestRequiredError
}
@Watch('isEditingType')
@Emit('isEditingBusinessType')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import { ActionBindingIF, ConfirmDialogType, NameRequestApplicantIF, NameRequest
NrResponseIF } from '@/interfaces/'
import { CorrectNameOptions } from '@/enums/'
import { CorpTypeCd, GetCorpFullDescription } from '@bcrs-shared-components/corp-type-module/'
import { NrRequestActionCodes } from '@bcrs-shared-components/enums'
import { useStore } from '@/store/store'
@Component({
Expand All @@ -125,11 +126,13 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
/** Whether to perform validation. */
@Prop({ default: false }) readonly validate!: boolean
@Action(useStore) setNameRequest!: ActionBindingIF
@Getter(useStore) getNameRequest!: NameRequestIF
@Getter(useStore) getEntityType!: CorpTypeCd
@Action(useStore) setNameRequest!: ActionBindingIF
@Action(useStore) setEntityType!: ActionBindingIF
@Action(useStore) setEntityTypeChangedByName!: ActionBindingIF
// Local properties
formValid = false
nameRequestNumber = ''
Expand Down Expand Up @@ -161,12 +164,12 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
(!!this.applicantPhone || !!this.applicantEmail)
}
private isValidEmail (value: string): boolean {
isValidEmail (value: string): boolean {
if (value?.length < 1) return true
return ((!!this.applicantPhone && !!value) || !!this.validateEmailFormat(value))
}
private isValidNrNumber (value: string): boolean {
isValidNrNumber (value: string): boolean {
const VALID_FORMAT = new RegExp(/^(NR)?\s*(\d{7})$/)
if (VALID_FORMAT.test(value)) {
this.nameRequestNumber = 'NR ' + value.match(VALID_FORMAT)[2]
Expand All @@ -175,20 +178,20 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
return false
}
private validateEmailFormat (value: string): boolean {
validateEmailFormat (value: string): boolean {
// eslint-disable-next-line max-len
const VALID_FORMAT = new RegExp(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)
return VALID_FORMAT.test(value)
}
@Watch('validate')
private onValidate (): void {
onValidate (): void {
this.$refs.correctNrForm.validate()
}
/** Watch for form submission and emit results. */
@Watch('formType')
private async onSubmit (): Promise<any> {
async onSubmit (): Promise<any> {
// this component should only see correct-new-nr form type
if (this.formType === CorrectNameOptions.CORRECT_NEW_NR) {
try {
Expand All @@ -199,14 +202,11 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
this.applicantEmail
)
if (this.getEntityType !== nr.legalType) {
if (this.isNameRequestInvalid(nr)) {
// Invalid NR type, inform parent the process is done and prompt confirm dialog
this.emitIsSaved()
const dialogContent = `<p class="info-text">This ${GetCorpFullDescription(nr.entity_type_cd)} ` +
`Name Request does not match the current business type ` +
`<b>${GetCorpFullDescription(this.getEntityType)}</b>.\n\n` +
`The Name Request type must match the business type before you can continue.</p>`
const dialogContent = this.nameRequestErrorText(nr)
await this.showConfirmDialog(
this.$refs.confirm,
'Name Request Type Does Not Match Business Type',
Expand All @@ -215,6 +215,11 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
)
} else {
this.parseNameRequest(nr)
// Set our entity type, if it's a conversion request
if (nr.request_action_cd === NrRequestActionCodes.CONVERSION) {
this.setEntityType(nr.legalType)
this.setEntityTypeChangedByName(true)
}
this.emitIsSaved(true)
}
} catch {
Expand All @@ -225,11 +230,39 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
}
}
/* Checks name request type or if it's an invalid conversion name request. */
isNameRequestInvalid (nr: NrResponseIF): boolean {
const isNameEntityTypeDifferent = this.getEntityType !== nr.legalType
const entityTypeOptions = this.getResource?.changeData?.entityTypeOptions
const isValidConversionNameRequest = nr.request_action_cd === NrRequestActionCodes.CONVERSION &&
entityTypeOptions?.some(options => options.value === nr.legalType)
return (isNameEntityTypeDifferent && !isValidConversionNameRequest)
}
/* Generate content of error depending on name request type. */
nameRequestErrorText (nr: NrResponseIF): string {
const isConversionOrAlterationNameRequest = nr.request_action_cd === NrRequestActionCodes.CONVERSION
let dialogContent = ''
if (isConversionOrAlterationNameRequest) {
dialogContent = `<p class="info-text">This alteration name request from ` +
`${GetCorpFullDescription(nr.entity_type_cd)} to ${GetCorpFullDescription(nr.legalType)} ` +
`does not match the current business type ` +
`<b>${GetCorpFullDescription(this.getEntityType)}</b>.\n\n` +
`The Name Request type must match the business type before you can continue.</p>`
} else {
dialogContent = `<p class="info-text">This ${GetCorpFullDescription(nr.entity_type_cd)} ` +
`Name Request does not match the current business type ` +
`<b>${GetCorpFullDescription(this.getEntityType)}</b>.\n\n` +
`The Name Request type must match the business type before you can continue.</p>`
}
return dialogContent
}
/**
* Parse and Set the Name Request date to Store.
* @param nr The name request data
*/
private parseNameRequest (nr: NrResponseIF): void {
parseNameRequest (nr: NrResponseIF): void {
const nrCorrection: NrCorrectionIF = {
legalType: nr.legalType,
nrNumber: this.nameRequestNumber,
Expand All @@ -251,7 +284,7 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
/** Inform parent the process is complete. */
@Emit('isSaved')
private emitIsSaved (isSaved = false): boolean {
emitIsSaved (isSaved = false): boolean {
if (!isSaved) this.$refs.correctNrForm.resetValidation()
return isSaved
}
Expand All @@ -262,7 +295,7 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
@Watch('applicantPhone')
@Watch('applicantEmail')
@Emit('isValid')
private emitValid (): boolean {
emitValid (): boolean {
return this.isFormValid
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/common/YourCompany/EntityName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,15 @@ export default class EntityName extends Mixins(NameRequestMixin) {
@Getter(useStore) isNumberedCompany!: boolean
@Getter(useStore) isSpecialResolutionFiling!: boolean
@Getter(useStore) isNameChangedByType!: boolean
@Getter(useStore) isEntityTypeChangedByName!: boolean
// store actions
@Action(useStore) setBusinessInformation!: ActionBindingIF
@Action(useStore) setEditingCompanyName!: ActionBindingIF
@Action(useStore) setNameRequest!: ActionBindingIF
@Action(useStore) setValidComponent!: ActionBindingIF
@Action(useStore) setEntityType!: ActionBindingIF
@Action(useStore) setEntityTypeChangedByName!: ActionBindingIF
// Returns true if the undo button should be displayed. This is the case when the company name has changed,
// or the business name has changed during an alteration, firm change, or special resolution filing,
Expand Down Expand Up @@ -404,6 +407,11 @@ export default class EntityName extends Mixins(NameRequestMixin) {
nrNumber: this.getEntitySnapshot.businessInfo.nrNumber
})
if (this.isEntityTypeChangedByName) {
this.setEntityType(this.getEntitySnapshot.businessInfo.legalType)
this.setEntityTypeChangedByName(false)
}
// reset flag
this.hasCompanyNameChanged = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface TombStoneIF {
transactionalFolioNumber: string
userEmail?: string
nameChangedByType: boolean
entityTypeChangedByName: boolean
}
3 changes: 2 additions & 1 deletion src/store/state/state-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const stateModel: StateModelIF = {
haveUnsavedChanges: false,
folioNumber: '',
transactionalFolioNumber: '',
nameChangedByType: false
nameChangedByType: false,
entityTypeChangedByName: false
},
completingParty: null,
newAlteration: {
Expand Down
8 changes: 8 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ export const useStore = defineStore('store', {
return this.stateModel.tombstone.nameChangedByType
},

/** Whether business type has changed by name change. */
isEntityTypeChangedByName (): boolean {
return this.stateModel.tombstone.entityTypeChangedByName
},

/** Whether business type has changed. */
hasBusinessTypeChanged (): boolean {
const currentEntityType = this.getEntityType
Expand Down Expand Up @@ -1298,6 +1303,9 @@ export const useStore = defineStore('store', {
setEntityType (entityType: CorpTypeCd) {
this.stateModel.tombstone.entityType = entityType
},
setEntityTypeChangedByName (entityTypeChangedByName: boolean) {
this.stateModel.tombstone.entityTypeChangedByName = entityTypeChangedByName
},
setBusinessId (businessId) {
this.stateModel.tombstone.businessId = businessId
},
Expand Down
Loading

0 comments on commit 7f2c6f4

Please sign in to comment.