From da5fccfc7d3b034a69fbaf29ae30885c6410150f Mon Sep 17 00:00:00 2001 From: Jonathan Longe Date: Wed, 11 Jan 2023 11:51:32 -0800 Subject: [PATCH] 14789 Create UI throwing schema error when court order is not entered (#495) --- src/components/common/Actions.vue | 4 + src/mixins/filing-template-mixin.ts | 17 +- src/store/getters/state-getters.ts | 3 +- .../IncorporationReviewConfirm.vue | 4 +- tests/unit/Actions.spec.ts | 1 + tests/unit/IncorporationReviewConfirm.spec.ts | 5 +- tests/unit/filing-template-mixin.spec.ts | 38 ++++ tests/unit/test-data/incorpApp.json | 169 ++++++++++++++++++ 8 files changed, 225 insertions(+), 16 deletions(-) create mode 100644 tests/unit/test-data/incorpApp.json diff --git a/src/components/common/Actions.vue b/src/components/common/Actions.vue index 6a2ca872c..dcdff56bf 100644 --- a/src/components/common/Actions.vue +++ b/src/components/common/Actions.vue @@ -175,6 +175,7 @@ export default class Actions extends Vue { // clear flag this.setHaveChanges(false) } catch (error) { + console.log('Error on onClickSave(): ', error) this.$root.$emit('save-error-event', error) this.setIsSaving(false) return @@ -203,6 +204,7 @@ export default class Actions extends Vue { // clear flag this.setHaveChanges(false) } catch (error) { + console.log('Error on onClickSaveResume(): ', error) this.$root.$emit('save-error-event', error) this.setIsSavingResuming(false) return @@ -246,6 +248,7 @@ export default class Actions extends Vue { try { await this.validateNameRequest(this.getNameRequestNumber) } catch (error) { + console.log('Error on onClickFilePay(): ', error) this.setIsFilingPaying(false) return } @@ -261,6 +264,7 @@ export default class Actions extends Vue { // clear flag this.setHaveChanges(false) } catch (error) { + console.log('Error on onClickFilePay(): ', error) this.$root.$emit('save-error-event', error) this.setIsFilingPaying(false) return diff --git a/src/mixins/filing-template-mixin.ts b/src/mixins/filing-template-mixin.ts index 920ff4dc5..fbda9a695 100644 --- a/src/mixins/filing-template-mixin.ts +++ b/src/mixins/filing-template-mixin.ts @@ -84,7 +84,6 @@ export default class FilingTemplateMixin extends DateMixin { @Getter getStaffPaymentStep!: StaffPaymentStepIF @Getter getCourtOrderStep!: CourtOrderStepIF @Getter isRoleStaff!: boolean - @Getter isTypeBcUlcCompany!: boolean @Getter getDissolutionStatementStep!: DissolutionStatementIF @Getter getDissolutionCustodian!: OrgPersonIF @Getter getFolioNumber!: string @@ -201,8 +200,8 @@ export default class FilingTemplateMixin extends DateMixin { agreementType: this.getIncorporationAgreementStep.agreementType } - if (this.isTypeBcUlcCompany) { - const courtOrder = this.getCourtOrderStep.courtOrder + const courtOrder = this.getCourtOrderStep.courtOrder + if (courtOrder && (courtOrder.hasPlanOfArrangement || courtOrder.fileNumber)) { filing.incorporationApplication.courtOrder = { fileNumber: courtOrder.fileNumber, effectOfOrder: courtOrder.hasPlanOfArrangement ? EffectOfOrders.PLAN_OF_ARRANGEMENT : '', @@ -318,11 +317,9 @@ export default class FilingTemplateMixin extends DateMixin { this.setIncorporationAgreementStepData({ agreementType: draftFiling.incorporationApplication.incorporationAgreement?.agreementType }) - - if (this.isTypeBcUlcCompany) { - this.setCourtOrderFileNumber(draftFiling.incorporationApplication.courtOrder?.fileNumber) - this.setHasPlanOfArrangement(draftFiling.incorporationApplication.courtOrder?.hasPlanOfArrangement) - } + // set courtOrder attribute + this.setCourtOrderFileNumber(draftFiling.incorporationApplication.courtOrder?.fileNumber || '') + this.setHasPlanOfArrangement(draftFiling.incorporationApplication.courtOrder?.hasPlanOfArrangement || false) break } @@ -818,8 +815,8 @@ export default class FilingTemplateMixin extends DateMixin { this.setAffidavit(uploadAffidavit) // restore Court Order data - this.setCourtOrderFileNumber(draftFiling.dissolution.courtOrder?.fileNumber) - this.setHasPlanOfArrangement(draftFiling.dissolution.courtOrder?.hasPlanOfArrangement) + this.setCourtOrderFileNumber(draftFiling.dissolution.courtOrder?.fileNumber || '') + this.setHasPlanOfArrangement(draftFiling.dissolution.courtOrder?.hasPlanOfArrangement || false) // NB: do not restore/overwrite Folio Number - just use the FN from auth info (see App.vue) diff --git a/src/store/getters/state-getters.ts b/src/store/getters/state-getters.ts index 82e585179..3b1ca3d3d 100644 --- a/src/store/getters/state-getters.ts +++ b/src/store/getters/state-getters.ts @@ -502,7 +502,8 @@ export const isIncorporationApplicationValid = (state: StateIF): boolean => { const isBaseStepsValid = ( getCreateShareStructureStep(state).valid && getEffectiveDateTime(state).valid && - getIncorporationAgreementStep(state).valid + getIncorporationAgreementStep(state).valid && + getCourtOrderStep(state).valid ) // Coop steps diff --git a/src/views/Incorporation/IncorporationReviewConfirm.vue b/src/views/Incorporation/IncorporationReviewConfirm.vue index 376ca0b8f..cf8b79258 100644 --- a/src/views/Incorporation/IncorporationReviewConfirm.vue +++ b/src/views/Incorporation/IncorporationReviewConfirm.vue @@ -125,7 +125,7 @@ -
+

Court Order and Plan of Arrangement

@@ -142,7 +142,7 @@ :autoValidation="getValidateSteps" :draftCourtOrderNumber="getCourtOrderStep.courtOrder.fileNumber" :hasDraftPlanOfArrangement="getCourtOrderStep.courtOrder.hasPlanOfArrangement" - :courtOrderNumberRequired="true" + :courtOrderNumberRequired="false" :invalidSection="isCourtOrderInvalid" @emitCourtNumber="setCourtOrderFileNumber($event)" @emitPoa="setHasPlanOfArrangement($event)" diff --git a/tests/unit/Actions.spec.ts b/tests/unit/Actions.spec.ts index e9ad2cc71..0ae64e19b 100644 --- a/tests/unit/Actions.spec.ts +++ b/tests/unit/Actions.spec.ts @@ -143,6 +143,7 @@ describe('Emits error event if NR validation fails in file and pay', () => { store.state.stateModel.createShareStructureStep = { valid: true } store.state.stateModel.incorporationAgreementStep = { valid: true } store.state.stateModel.effectiveDateTime = { valid: true } + store.state.stateModel.courtOrderStep = { valid: true } const localVue = createLocalVue() localVue.use(VueRouter) diff --git a/tests/unit/IncorporationReviewConfirm.spec.ts b/tests/unit/IncorporationReviewConfirm.spec.ts index cc1179d61..ca5b4e165 100644 --- a/tests/unit/IncorporationReviewConfirm.spec.ts +++ b/tests/unit/IncorporationReviewConfirm.spec.ts @@ -56,7 +56,7 @@ for (const test of reviewConfirmTestCases) { expect(wrapper.find('#certify-section').exists()).toBe(true) }) - it('displays Court Order and Plan of Arrangement section only for ULC', () => { + it('displays Court Order and Plan of Arrangement section only for BEN, ULC, CC, BC', () => { wrapper = shallowWrapperFactory( IncorporationReviewConfirm, null, @@ -67,8 +67,7 @@ for (const test of reviewConfirmTestCases) { IncorporationResources ) - const expected = (test.entityType === 'ULC') - expect(wrapper.find('#court-order-poa-section').exists()).toBe(test.entityType === 'ULC') + expect(wrapper.find('#court-order-poa-section').exists()).toBe(['BEN', 'ULC', 'CC', 'BC'].includes(test.entityType)) }) // FUTURE: Expand unit testing for validation on step 5. Include routing to appropriate steps from error links. diff --git a/tests/unit/filing-template-mixin.spec.ts b/tests/unit/filing-template-mixin.spec.ts index 8ec1afb4f..bee2e38cf 100644 --- a/tests/unit/filing-template-mixin.spec.ts +++ b/tests/unit/filing-template-mixin.spec.ts @@ -493,3 +493,41 @@ describe('Staff Payment', () => { }) }) }) + +for (const entityType of ['BEN', 'BC', 'CC', 'ULC']) { + describe('Base corporate incorporation filing: ' + entityType, () => { + // load coop filing data + let ia = require('./test-data/incorpApp.json') + ia.filing.business.legalType = entityType + ia.filing.incorporationApplication.nameRequest.legalType = entityType + let wrapper: any + + beforeEach(() => { + wrapper = wrapperFactory(MixinTester, null, {}) + }) + + afterEach(() => { + wrapper.destroy() + }) + + it('courtOrder attribute is not required', () => { + wrapper.vm.parseIncorporationDraft(ia.filing) + const filing = wrapper.vm.buildIncorporationFiling() + expect(filing.incorporationApplication).not.toHaveProperty('courtNumber') + }) + + it('can include courtOrder attribute', () => { + ia.filing.incorporationApplication.courtOrder = { + 'fileNumber': '12034567', + 'hasPlanOfArrangement': true + } + wrapper.vm.parseIncorporationDraft(ia.filing) + const filing = wrapper.vm.buildIncorporationFiling() + expect(filing.incorporationApplication.courtOrder).toEqual({ + fileNumber: '12034567', + effectOfOrder: 'planOfArrangement', + hasPlanOfArrangement: true + }) + }) + }) +} diff --git a/tests/unit/test-data/incorpApp.json b/tests/unit/test-data/incorpApp.json new file mode 100644 index 000000000..b9171fa6f --- /dev/null +++ b/tests/unit/test-data/incorpApp.json @@ -0,0 +1,169 @@ +{ + "filing": { + "business": { + "identifier": "id123abc", + "legalType": "BC" + }, + "documents": [], + "header": { + "affectedFilings": [], + "availableOnPaperOnly": false, + "certifiedBy": "BCREGTEST Rosette ELEVEN", + "colinIds": [], + "comments": [], + "date": "2021-10-26T20:30:00.230581+00:00", + "effectiveDate": "2021-10-26T20:30:00.230609+00:00", + "filingId": 112950, + "inColinOnly": false, + "isCorrected": false, + "isCorrectionPending": false, + "isFutureEffective": false, + "name": "incorporationApplication", + "paymentStatusCode": "COMPLETED", + "paymentToken": "13408", + "status": "PAID", + "submitter": "bcsc/iaptaestlb6ita56a3sqwhvvdulxqsl5" + }, + "incorporationApplication": { + "contactPoint": { + "email": "eleven@email.com", + "phone": "(555) 555-5555" + }, + "nameRequest": { + "legalName": "TEST INC IA", + "legalType": "CP", + "nrNumber": "NR 5269136" + }, + "nameTranslations": [], + "offices": { + "registeredOffice": { + "deliveryAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + }, + "mailingAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + } + } + }, + "parties": [ + { + "deliveryAddress": { + "addressCity": "Smithers", + "addressCountry": "CA", + "addressRegion": "BC", + "postalCode": "V0J 2N2", + "streetAddress": "5-6421 Airport Rd", + "streetAddressAdditional": "" + }, + "mailingAddress": { + "addressCity": "Smithers", + "addressCountry": "CA", + "addressRegion": "BC", + "postalCode": "V0J 2N2", + "streetAddress": "5-6421 Airport Rd", + "streetAddressAdditional": "" + }, + "officer": { + "email": "a@test.com", + "firstName": "BCREGTEST Rosette", + "id": "79825708-ca1d-41f6-86b0-fa7f30f93c5d", + "lastName": "ELEVEN", + "middleName": "", + "organizationName": "", + "partyType": "person" + }, + "roles": [ + { + "appointmentDate": "2021-10-26", + "roleType": "Completing Party" + }, + { + "appointmentDate": "2021-10-26", + "roleType": "Director" + } + ] + }, + { + "deliveryAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + }, + "mailingAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + }, + "officer": { + "firstName": "John", + "id": "7b755f98-c183-4e04-96fd-027715f06c49", + "lastName": "Test", + "middleName": "", + "organizationName": "", + "partyType": "person" + }, + "roles": [ + { + "appointmentDate": "2021-10-26", + "roleType": "Director" + } + ] + }, + { + "deliveryAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + }, + "mailingAddress": { + "addressCity": "Victoria", + "addressCountry": "CA", + "addressRegion": "BC", + "deliveryInstructions": "", + "postalCode": "V8W 3H2", + "streetAddress": "735 Broughton St", + "streetAddressAdditional": "" + }, + "officer": { + "firstName": "Anna", + "id": "1d759481-7395-4826-87bc-666b5518d4d6", + "lastName": "Test", + "middleName": "", + "organizationName": "", + "partyType": "person" + }, + "roles": [ + { + "appointmentDate": "2021-10-26", + "roleType": "Director" + } + ] + } + ] + } + } +}