diff --git a/package-lock.json b/package-lock.json index b7f72a6f..4a6c4c85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-edit-ui", - "version": "4.11.12", + "version": "4.11.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-edit-ui", - "version": "4.11.12", + "version": "4.11.13", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/action-chip": "1.1.5", diff --git a/package.json b/package.json index 12911bce..70e9f9c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-edit-ui", - "version": "4.11.12", + "version": "4.11.13", "private": true, "appName": "Edit UI", "sbcName": "SBC Common Components", diff --git a/src/components/common/YourCompany/EntityName.vue b/src/components/common/YourCompany/EntityName.vue index c41970fa..552868f1 100644 --- a/src/components/common/YourCompany/EntityName.vue +++ b/src/components/common/YourCompany/EntityName.vue @@ -290,6 +290,7 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) { @Getter(useStore) isFirmChangeFiling!: boolean @Getter(useStore) isFirmConversionFiling!: boolean @Getter(useStore) isLimitedRestorationExtension!: boolean + @Getter(useStore) isLimitedRestorationToFull!: boolean @Getter(useStore) isNumberedCompany!: boolean @Getter(useStore) isSpecialResolutionFiling!: boolean @Getter(useStore) isNameChangedByType!: boolean @@ -321,7 +322,9 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) { this.hasCompanyNameChanged || ( this.hasBusinessNameChanged && - (this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling) + (this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling || + this.isLimitedRestorationToFull + ) ) ) } @@ -337,7 +340,9 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) { this.hasCompanyNameChanged || ( this.hasBusinessNameChanged && - (this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling) + (this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling || + this.isLimitedRestorationToFull + ) ) ) && !this.isNameChangedByType @@ -439,8 +444,22 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) { /** Updates UI when correct name options are done. */ nameChangeHandler (isSaved = false): void { - this.hasCompanyNameChanged = this.isNewName - if (isSaved) this.isEditingNames = false + // check if this is a numbered company case: + // 1. no Name Request legal name exists (indicating not using NR) + // 2. business number exists (needed for numbered company name) + const isNumberedName = !this.getNameRequestLegalName && !!this.getBusinessNumber + this.hasCompanyNameChanged = this.isNewName || isNumberedName + + if (isSaved) { + this.isEditingNames = false + + // set legal name for numbered company to satisfy Legal API requirement + // without this, Legal API will return error when filing restoration with numbered option + if (isNumberedName) { + const numberedName = `${this.getBusinessNumber} B.C. ${this.getUpdatedName}` + this.setNameRequestLegalName(numberedName) + } + } } /** Reset company name values to original. */ diff --git a/tests/unit/EntityName.spec.ts b/tests/unit/EntityName.spec.ts index abaeac12..d9b799bb 100644 --- a/tests/unit/EntityName.spec.ts +++ b/tests/unit/EntityName.spec.ts @@ -21,6 +21,8 @@ import { CorrectionResourceGp } from '@/resources/Correction/GP' import { CorrectionResourceSp } from '@/resources/Correction/SP' import { CorrectionResourceUlc } from '@/resources/Correction/ULC' +import { RestorationResourceBc } from '@/resources/LimitedRestorationToFull/BC' + import { SpecialResolutionResourceCp } from '@/resources/SpecialResolution/CP' import { createPinia, setActivePinia } from 'pinia' @@ -398,3 +400,57 @@ describe('Name Changes by Type change', () => { ) }) }) + +describe('Name Changes for Limited Restoration to Full', () => { + let wrapper: any + + const entitySnapshot = { + businessInfo: { + legalName: 'Mock Original Name', + legalType: CorpTypeCd.BC_COMPANY, + identifier: 'BC0884805' + } + } + + beforeEach(() => { + // Set original business Data + store.stateModel.summaryMode = false + store.stateModel.nameRequestLegalName = entitySnapshot.businessInfo.legalName + store.stateModel.entitySnapshot = entitySnapshot as any + store.stateModel.tombstone.filingType = FilingTypes.RESTORATION + store.stateModel.tombstone.entityType = entitySnapshot.businessInfo.legalType + store.stateModel.tombstone.businessId = entitySnapshot.businessInfo.identifier + store.resourceModel = RestorationResourceBc + + wrapper = mount(EntityName, { + vuetify, + computed: { + isLimitedRestorationToFull: () => true, + isNameChangedByType: () => false + } + }) + }) + + afterEach(() => { + wrapper.destroy() + }) + + it('displays Undo button after changing to a numbered company and resuming draft', async () => { + // Initial state + const companyName = wrapper.find('.company-name') + expect(companyName.exists()).toBe(true) + expect(companyName.text()).toBe('Mock Original Name') + + // Simulate changing to numbered company + store.stateModel.nameRequestLegalName = null + + await wrapper.vm.nameChangeHandler(true) + await Vue.nextTick() + + // Verify show the Undo button + const button = wrapper.find('#btn-undo-company-name') + expect(button.exists()).toBe(true) + expect(button.text()).toBe('Undo') + expect(wrapper.vm.shouldShowUndoButton).toBe(true) + }) +})