From 3c9f2718300a01b025f8a1c0ceef4fbc38090452 Mon Sep 17 00:00:00 2001 From: Hrvoje Fekete Date: Mon, 16 Sep 2024 11:06:47 -0400 Subject: [PATCH] 22685 - To Do Action - handling extra name request info (#43) * 22685 - expander content added. * 22685 - expander content updated, subitle handled. * 22685 - tests part 1 * Fixing sync issue (race condition while loading bootstrap business). * 22685 - tests part 2 * eslint fixes... * Address change icon color update. * Removing unnecessary comment. * PR updates. --- .../components/todos/name-request-draft.cy.ts | 184 +++++++++++ cypress/fixtures/bootstrapFiling.json | 36 --- .../filings/draft/amalgamation-application.ts | 304 ++++++++++++++++++ .../corporation-continuation-application.ts | 38 +++ .../filings/draft/incorporation-applicaton.ts | 40 +++ .../filings/draft/sole-prop-with-nr.ts | 43 +++ cypress/fixtures/name-requests/soleProp.ts | 94 ++++++ cypress/support/commands.ts | 36 ++- .../bcros/businessDetails/index.vue | 10 +- .../filing/common/filedAnd/PendingCoa.vue | 2 +- src/components/bcros/todo/Item.vue | 6 +- .../todo/expansion-content/DraftWithNR.vue | 96 ++++++ src/enums/name-request-consent-flag-e.ts | 7 + src/pages/dashboard.vue | 4 +- src/stores/businessBootstrap.ts | 18 +- src/utils/date.ts | 8 +- src/utils/nr-utils.ts | 81 +++++ src/utils/todo/task-filing/content-loader.ts | 7 +- src/utils/todo/task-filing/index.ts | 16 +- 19 files changed, 948 insertions(+), 82 deletions(-) create mode 100644 cypress/e2e/components/todos/name-request-draft.cy.ts delete mode 100644 cypress/fixtures/bootstrapFiling.json create mode 100644 cypress/fixtures/filings/draft/amalgamation-application.ts create mode 100644 cypress/fixtures/filings/draft/corporation-continuation-application.ts create mode 100644 cypress/fixtures/filings/draft/incorporation-applicaton.ts create mode 100644 cypress/fixtures/filings/draft/sole-prop-with-nr.ts create mode 100644 cypress/fixtures/name-requests/soleProp.ts create mode 100644 src/components/bcros/todo/expansion-content/DraftWithNR.vue create mode 100644 src/enums/name-request-consent-flag-e.ts create mode 100644 src/utils/nr-utils.ts diff --git a/cypress/e2e/components/todos/name-request-draft.cy.ts b/cypress/e2e/components/todos/name-request-draft.cy.ts new file mode 100644 index 0000000..baed00a --- /dev/null +++ b/cypress/e2e/components/todos/name-request-draft.cy.ts @@ -0,0 +1,184 @@ +import { DraftFilingSolePropWithNr } from '../../../fixtures/filings/draft/sole-prop-with-nr' +import { SolePropNr } from '../../../fixtures/name-requests/soleProp' +import { DraftFilingIncorporationApplicationNumbered } from '../../../fixtures/filings/draft/incorporation-applicaton' +import { DraftFilingAmalgamationApplication } from '../../../fixtures/filings/draft/amalgamation-application' +import { + DraftFilingCorporationContinuationApplication +} from '../../../fixtures/filings/draft/corporation-continuation-application' + +context('TODOs -> Draft Filings', () => { + it('Sole Prop with NR - expires today', () => { + const draftFiling = DraftFilingSolePropWithNr + const nameRequest = Object.assign({}, SolePropNr) + + const today = new Date() + nameRequest.expirationDate = today.toISOString() + + cy.intercept( + 'GET', + '**/api/v2/nameRequests/**/validate**', + nameRequest + ).as('nameRequest') + + cy.visitTempBusinessDash(draftFiling, false) + cy.wait('@nameRequest') + + cy.get('[data-cy="header_todo"]').should('exist') + cy.get('[data-cy="todoItemList"]').should('exist') + + // subtitle + cy.get('[data-cy^="todoItem-label-"]') + .should('exist') + .contains('NR APPROVED - Expires today') + + // View More button exists + cy.get('[data-cy^="todoItem-showMore-"]').should('exist') + cy.get('[data-cy^="todoItem-showMore-"]').click() + + // extended content + cy.get('[data-cy="todoItem-content"]').should('exist').contains('Name Request') + + // The action button exists + cy.get('[data-cy^="todoItemActions-"]') + .find('button') + .should('exist') + .should('have.text', 'Register using this NR') + + // no dropdown menu + cy.get('[data-cy="popover-button"]').should('exist').click() + + cy.get('[data-cy="menu-button-0"]') + .should('exist') + .should('have.text', 'Delete Registration') + }) + + it('Sole Prop with NR expire in 10 days', () => { + const draftFiling = DraftFilingSolePropWithNr + const nameRequest = Object.assign({}, SolePropNr) + + const in10days = new Date() + in10days.setDate(in10days.getDate() + 10) + nameRequest.expirationDate = in10days.toISOString() + + cy.intercept( + 'GET', + '**/api/v2/nameRequests/**/validate**', + nameRequest + ).as('nameRequest') + + cy.visitTempBusinessDash(draftFiling, false) + cy.wait('@nameRequest') + + cy.get('[data-cy="header_todo"]').should('exist') + cy.get('[data-cy="todoItemList"]').should('exist') + + // subtitle + cy.get('[data-cy^="todoItem-label-"]') + .should('exist') + .contains('NR APPROVED - Expires in 10 days') + + // View More button exists + cy.get('[data-cy^="todoItem-showMore-"]').should('exist') + cy.get('[data-cy^="todoItem-showMore-"]').click() + + // extended content + cy.get('[data-cy="todoItem-content"]').should('exist').contains('Name Request') + + // The action button exists + cy.get('[data-cy^="todoItemActions-"]') + .find('button') + .should('exist') + .should('have.text', 'Register using this NR') + + // dropdown menu + cy.get('[data-cy="popover-button"]').should('exist').click() + + cy.get('[data-cy="menu-button-0"]') + .should('exist') + .should('have.text', 'Delete Registration') + }) + + it('Numbered limited company (no NR)', () => { + cy.visitTempBusinessDash(DraftFilingIncorporationApplicationNumbered, false) + + cy.get('[data-cy="header_todo"]').should('exist') + cy.get('[data-cy="todoItemList"]').should('exist') + + // subtitle + cy.get('[data-cy^="todoItem-label-"]') + .should('exist') + .contains('DRAFT') + + // View More button exists + cy.get('[data-cy^="todoItem-showMore-"]').should('not.exist') + + // The action button exists + cy.get('[data-cy^="todoItemActions-"]') + .find('button') + .should('exist') + .should('have.text', 'Incorporate a Numbered Company') + + cy.get('[data-cy="popover-button"]').should('exist').click() + + // dropdown menu + cy.get('[data-cy="menu-button-0"]') + .should('exist') + .should('have.text', 'Delete Incorporation Application') + }) + + it('Amalgamation application', () => { + cy.visitTempBusinessDash(DraftFilingAmalgamationApplication, false) + + cy.get('[data-cy="header_todo"]').should('exist') + cy.get('[data-cy="todoItemList"]').should('exist') + + // subtitle + cy.get('[data-cy^="todoItem-label-"]') + .should('exist') + .contains('DRAFT') + + // View More button exists + cy.get('[data-cy^="todoItem-showMore-"]').should('not.exist') + + // The action button exists + cy.get('[data-cy^="todoItemActions-"]') + .find('button') + .should('exist') + .should('have.text', 'Resume') + + cy.get('[data-cy="popover-button"]').should('exist').click() + + // dropdown menu + cy.get('[data-cy="menu-button-0"]') + .should('exist') + .should('have.text', 'Delete Amalgamation Application') + }) + + it('BC Limited Company Continuation Application', () => { + cy.visitTempBusinessDash(DraftFilingCorporationContinuationApplication, false) + + cy.get('[data-cy="header_todo"]').should('exist') + cy.get('[data-cy="todoItemList"]').should('exist') + + // subtitle + cy.get('[data-cy^="todoItem-label-"]') + .should('exist') + .contains('DRAFT') + + // View More button exists + cy.get('[data-cy^="todoItem-showMore-"]').should('not.exist') + + // The action button exists + cy.get('[data-cy^="todoItemActions-"]') + .find('button') + .should('exist') + .should('have.text', 'Continue In as a Numbered Company') + + cy.get('[data-cy="popover-button"]').should('exist').click() + + // dropdown menu + cy.get('[data-cy="menu-button-0"]') + .should('exist') + .should('have.text', 'Delete Continuation Application') + }) +}) diff --git a/cypress/fixtures/bootstrapFiling.json b/cypress/fixtures/bootstrapFiling.json deleted file mode 100644 index 8092d85..0000000 --- a/cypress/fixtures/bootstrapFiling.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "commentsCount": 0, - "commentsLink": "https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334/comments", - "displayLedger": true, - "documentsLink": "https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334/documents", - "filing": { - "business": { - "identifier": "TMvQC2uMeY", - "legalType": "BC" - }, - "header": { - "accountId": 3113, - "affectedFilings": [], - "availableOnPaperOnly": false, - "colinIds": [], - "comments": ["ssssss"], - "date": "2023-08-11T17:18:58.548021+00:00", - "deletionLocked": false, - "effectiveDate": "2023-08-11T17:18:58.548047+00:00", - "filingId": 146334, - "inColinOnly": false, - "isCorrected": false, - "isCorrectionPending": false, - "name": "incorporationApplication", - "status": "DRAFT", - "submitter": "bcsc/zgcbnhm6u7fprxi7ajt6kff7gsky43ta" - }, - "incorporationApplication": { - "nameRequest": { - "legalType": "BC" - } - } - }, - "filingLink": "https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334", - "isFutureEffective": false -} diff --git a/cypress/fixtures/filings/draft/amalgamation-application.ts b/cypress/fixtures/filings/draft/amalgamation-application.ts new file mode 100644 index 0000000..40388e1 --- /dev/null +++ b/cypress/fixtures/filings/draft/amalgamation-application.ts @@ -0,0 +1,304 @@ +export const DraftFilingAmalgamationApplication = { + commentsCount: 0, + commentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TQMmue0hhd/filings/150699/comments', + displayLedger: true, + documentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TQMmue0hhd/filings/150699/documents', + filing: { + amalgamationApplication: { + amalgamatingBusinesses: [ + { + addresses: { + recordsOffice: { + deliveryAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2912871, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2912870, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + } + }, + registeredOffice: { + deliveryAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2912873, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2912872, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + } + } + }, + authInfo: { + contacts: [ + { + email: 'test@TT.CA', + extension: '', + phone: '' + } + ] + }, + identifier: 'C9900775', + isDraftTask: false, + isFrozen: false, + isFutureEffective: false, + isHistorical: false, + isLimitedRestoration: false, + isNotInGoodStanding: false, + isPendingFiling: false, + legalType: 'C', + name: '9900775 B.C. LTD.', + role: 'primary', + status: 0, + type: 'lear' + }, + { + addresses: { + recordsOffice: { + deliveryAddress: { + addressCity: 'Vancouver', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2716699, + postalCode: 'V6J 5L2', + streetAddress: '201-1768 8th Ave W', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Vancouver', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2716698, + postalCode: 'V6J 5L2', + streetAddress: '201-1768 8th Ave W', + streetAddressAdditional: '' + } + }, + registeredOffice: { + deliveryAddress: { + addressCity: 'Vancouver', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2716701, + postalCode: 'V6J 5L2', + streetAddress: '201-1768 8th Ave W', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Vancouver', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2716700, + postalCode: 'V6J 5L2', + streetAddress: '201-1768 8th Ave W', + streetAddressAdditional: '' + } + } + }, + authInfo: { + contacts: [ + { + email: 'hrvoje.fekete.business@gmail.com', + extension: '', + phone: '(123) 456-7890' + } + ], + folioNumber: '12345' + }, + identifier: 'BC0871427', + isDraftTask: false, + isFrozen: false, + isFutureEffective: false, + isHistorical: false, + isLimitedRestoration: false, + isNotInGoodStanding: false, + isPendingFiling: false, + legalType: 'BEN', + name: '0871427 B.C. LTD.', + role: 'amalgamating', + status: 0, + type: 'lear' + } + ], + contactPoint: { + email: 'test@TT.CA', + phone: '' + }, + courtApproval: null, + nameRequest: { + correctNameOption: 'correct-aml-adopt', + legalName: '9900775 B.C. LTD.', + legalType: 'BC' + }, + nameTranslations: [], + offices: { + recordsOffice: { + deliveryAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2912871, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2912870, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + } + }, + registeredOffice: { + deliveryAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'delivery', + deliveryInstructions: '', + id: 2912873, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Pitt Meadows', + addressCountry: 'CA', + addressRegion: 'BC', + addressType: 'mailing', + deliveryInstructions: '', + id: 2912872, + postalCode: 'V3Y 1T1', + streetAddress: '14-19032 Advent Rd', + streetAddressAdditional: '' + } + } + }, + parties: [ + { + deliveryAddress: { + addressCity: 'Victoria', + addressCountry: 'CA', + addressRegion: 'BC', + deliveryInstructions: null, + id: 2912868, + postalCode: 'V8W 1W4', + streetAddress: '1-940 Blanshard', + streetAddressAdditional: '' + }, + mailingAddress: { + addressCity: 'Victoria', + addressCountry: 'CA', + addressRegion: 'BC', + deliveryInstructions: null, + id: 2912869, + postalCode: 'V8W 1W4', + streetAddress: '1-940 Blanshard', + streetAddressAdditional: '' + }, + officer: { + email: 'arwen.qin@gov.bc.ca', + firstName: 'ARWEN', + id: 584824, + lastName: 'QIN', + partyType: 'person' + }, + roles: [ + { + appointmentDate: '2024-07-10', + cessationDate: null, + roleType: 'Director' + } + ] + } + ], + shareStructure: { + shareClasses: [ + { + currency: null, + hasMaximumShares: false, + hasParValue: false, + hasRightsOrRestrictions: false, + id: 464319, + maxNumberOfShares: null, + name: 'Class A Shares', + parValue: null, + priority: 1, + series: [], + type: 'Class' + } + ] + }, + type: 'horizontal' + }, + business: { + identifier: 'TQMmue0hhd', + legalType: 'BC' + }, + header: { + affectedFilings: [], + availableOnPaperOnly: false, + colinIds: [], + comments: [], + date: '2024-08-27T23:12:12.674613+00:00', + deletionLocked: false, + effectiveDate: '2024-08-27T23:12:12.674638+00:00', + filingId: 150699, + folioNumber: '', + inColinOnly: false, + isCorrected: false, + isCorrectionPending: false, + isFutureEffective: false, + name: 'amalgamationApplication', + status: 'DRAFT', + submitter: 'aqin@idir' + } + }, + filingLink: 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TQMmue0hhd/filings/150699', + isFutureEffective: false +} diff --git a/cypress/fixtures/filings/draft/corporation-continuation-application.ts b/cypress/fixtures/filings/draft/corporation-continuation-application.ts new file mode 100644 index 0000000..b85cdd1 --- /dev/null +++ b/cypress/fixtures/filings/draft/corporation-continuation-application.ts @@ -0,0 +1,38 @@ +export const DraftFilingCorporationContinuationApplication = { + commentsCount: 0, + commentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TFBwKmnNt5/filings/150816/comments', + displayLedger: true, + documentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TFBwKmnNt5/filings/150816/documents', + filing: { + business: { + identifier: 'TFBwKmnNt5', + legalType: 'C' + }, + continuationIn: { + nameRequest: { + legalType: 'C' + } + }, + header: { + accountId: 3040, + affectedFilings: [], + availableOnPaperOnly: false, + colinIds: [], + comments: [], + date: '2024-09-06T19:38:16.594574+00:00', + deletionLocked: false, + effectiveDate: '2024-09-06T19:38:16.594598+00:00', + filingId: 150816, + inColinOnly: false, + isCorrected: false, + isCorrectionPending: false, + name: 'continuationIn', + status: 'DRAFT', + submitter: 'aqin@idir' + } + }, + filingLink: 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TFBwKmnNt5/filings/150816', + isFutureEffective: false +} diff --git a/cypress/fixtures/filings/draft/incorporation-applicaton.ts b/cypress/fixtures/filings/draft/incorporation-applicaton.ts new file mode 100644 index 0000000..4650ef1 --- /dev/null +++ b/cypress/fixtures/filings/draft/incorporation-applicaton.ts @@ -0,0 +1,40 @@ +export const BoostrapFiling = { + commentsCount: 0, + commentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334/comments', + displayLedger: true, + documentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334/documents', + filing: { + business: { + identifier: 'TMvQC2uMeY', + legalType: 'BC' + }, + header: { + accountId: 3113, + affectedFilings: [], + availableOnPaperOnly: false, + colinIds: [], + comments: ['ssssss'], + date: '2023-08-11T17:18:58.548021+00:00', + deletionLocked: false, + effectiveDate: '2023-08-11T17:18:58.548047+00:00', + filingId: 146334, + inColinOnly: false, + isCorrected: false, + isCorrectionPending: false, + name: 'incorporationApplication', + status: 'DRAFT', + submitter: 'bcsc/zgcbnhm6u7fprxi7ajt6kff7gsky43ta' + }, + incorporationApplication: { + nameRequest: { + legalType: 'BC' + } + } + }, + filingLink: 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TMvQC2uMeY/filings/146334', + isFutureEffective: false +} + +export const DraftFilingIncorporationApplicationNumbered = BoostrapFiling diff --git a/cypress/fixtures/filings/draft/sole-prop-with-nr.ts b/cypress/fixtures/filings/draft/sole-prop-with-nr.ts new file mode 100644 index 0000000..04d5db6 --- /dev/null +++ b/cypress/fixtures/filings/draft/sole-prop-with-nr.ts @@ -0,0 +1,43 @@ +export const DraftFilingSolePropWithNr = { + commentsCount: 0, + commentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TM1hgJDxOp/filings/150402/comments', + displayLedger: true, + documentsLink: + 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TM1hgJDxOp/filings/150402/documents', + filing: { + business: { + identifier: 'TM1hgJDxOp', + legalType: 'SP' + }, + header: { + accountId: 3040, + affectedFilings: [], + availableOnPaperOnly: false, + colinIds: [], + comments: [], + date: '2024-07-29T23:01:52.172882+00:00', + deletionLocked: false, + effectiveDate: '2024-07-29T23:01:52.172916+00:00', + filingId: 150402, + inColinOnly: false, + isCorrected: false, + isCorrectionPending: false, + name: 'registration', + status: 'DRAFT', + submitter: 's2beauva@idir' + }, + registration: { + business: { + natureOfBusiness: 'testing' + }, + businessType: 'SP', + nameRequest: { + legalType: 'SP', + nrNumber: 'NR 3367062' + } + } + }, + filingLink: 'https://legal-api-dev.apps.silver.devops.gov.bc.ca/api/v2/businesses/TM1hgJDxOp/filings/150402', + isFutureEffective: false +} diff --git a/cypress/fixtures/name-requests/soleProp.ts b/cypress/fixtures/name-requests/soleProp.ts new file mode 100644 index 0000000..a47ceb4 --- /dev/null +++ b/cypress/fixtures/name-requests/soleProp.ts @@ -0,0 +1,94 @@ +export const SolePropNr = { + actions: [ + { + URL: null, + entitiesFilingName: null, + filingName: 'Registration', + learTemplate: null + } + ], + additionalInfo: '*** New Request ***', + applicants: { + addrLine1: '1318 Treebank Rd W', + addrLine2: null, + addrLine3: null, + city: 'Esquimalt', + clientFirstName: null, + clientLastName: null, + contact: '', + countryTypeCd: 'CA', + declineNotificationInd: null, + emailAddress: 'sss@ggg.ccc', + faxNumber: null, + firstName: 'Severin', + lastName: 'Beauvais', + middleName: null, + partyId: 1665795, + phoneNumber: '1234', + postalCd: 'V9A 7G1', + stateProvinceCd: 'BC' + }, + checkedOutBy: null, + checkedOutDt: null, + comments: [ + { + comment: 'The applicant has indicated the submitted name or names are in English.', + examiner: 'name_request_service_account', + id: 139804, + timestamp: '2024-07-29T22:59:58.833402+00:00' + } + ], + consentFlag: null, + consent_dt: null, + corpNum: '', + entity_type_cd: 'FR', + expirationDate: '2024-09-24T06:59:00+00:00', + furnished: 'Y', + hasBeenReset: false, + homeJurisNum: '', + id: 2268802, + lastUpdate: '2024-09-10T08:01:17.023041+00:00', + legalType: 'SP', + names: [ + { + choice: 1, + comment: null, + conflict1: '', + conflict1_num: '', + conflict2: '', + conflict2_num: '', + conflict3: '', + conflict3_num: '', + consumptionDate: null, + corpNum: null, + decision_text: '', + designation: '', + id: 4270806, + name: 'SEVERIN FIRM APPLICATION TEST', + name_type_cd: 'CO', + state: 'APPROVED' + } + ], + natureBusinessInfo: 'testing', + notifiedBeforeExpiry: true, + notifiedExpiry: false, + nrNum: 'NR 3367062', + nwpta: [], + previousNr: null, + previousRequestId: null, + previousStateCd: null, + priorityCd: 'N', + priorityDate: null, + requestTypeCd: 'FR', + request_action_cd: 'NEW', + source: 'NAMEREQUEST', + state: 'APPROVED', + stateCd: 'APPROVED', + submitCount: 1, + submittedDate: '2024-07-29T22:59:58.830321+00:00', + submitter_userid: 'name_request_service_account', + target: 'lear', + tradeMark: '', + userId: 's2beauva@idir', + xproJurisdiction: '' +} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index fe41898..d8de603 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,5 +1,6 @@ import { BusinessI } from '../../src/interfaces/business-i' import { BusinessStateE } from '../../src/enums/business-state-e' +import { BoostrapFiling } from '../fixtures/filings/draft/incorporation-applicaton' Cypress.Commands.add('interceptBusinessInfo', (identifier, legalType, isHistorical) => { cy.fixture(`business${legalType}`).then((business) => { @@ -230,7 +231,12 @@ Cypress.Commands.add('visitBusinessDashFor', } ) -Cypress.Commands.add('visitTempBusinessDash', (filingFixture = 'bootstrapFiling.json', asStaff = false) => { +Cypress.Commands.add('visitTempBusinessDash', (draftFiling = undefined, asStaff = false) => { + let bootstrapFiling = BoostrapFiling + if (draftFiling) { + bootstrapFiling = draftFiling + } + // settings if (asStaff) { sessionStorage.setItem('FAKE_CYPRESS_LOGIN', 'trueStaff') @@ -250,23 +256,21 @@ Cypress.Commands.add('visitTempBusinessDash', (filingFixture = 'bootstrapFiling. cy.intercept('GET', '**/api/v1/orgs/**/products*', { fixture: 'products.json' }).as('getProducts') // business related info - cy.fixture(filingFixture).then((bootstrapFiling) => { - const tempBusiness = bootstrapFiling.filing.business + const tempBusiness = bootstrapFiling.filing.business - cy.intercept( - 'GET', - `**/api/v2/businesses/${tempBusiness.identifier}/filings`, - bootstrapFiling - ) + cy.intercept( + 'GET', + `**/api/v2/businesses/${tempBusiness.identifier}/filings`, + bootstrapFiling + ) - // go ! - cy.visit(`/${tempBusiness.identifier}`) - cy.wait([ - '@getSettings', - '@getProducts' - ]) - cy.injectAxe() - }) + // go ! + cy.visit(`/${tempBusiness.identifier}`) + cy.wait([ + '@getSettings', + '@getProducts' + ]) + cy.injectAxe() }) Cypress.Commands.add('visitBusinessDashAuthError', (identifier = 'BC0871427', legalType = 'BEN') => { diff --git a/src/components/bcros/businessDetails/index.vue b/src/components/bcros/businessDetails/index.vue index 9d6757f..3969875 100644 --- a/src/components/bcros/businessDetails/index.vue +++ b/src/components/bcros/businessDetails/index.vue @@ -27,7 +27,7 @@ watch(currentBusiness, updateBusinessDetails) watch(currentBusinessContact, updateBusinessDetails) /** Load in the business data required for this layout. */ -async function loadComponentData(identifier: string) { +async function loadComponentData (identifier: string) { if (bootstrap.checkIsTempReg(identifier)) { // this is a business bootstrap (actual business does not exist yet) await bootstrap.loadBusinessBootstrap(identifier) @@ -38,13 +38,7 @@ async function loadComponentData(identifier: string) { } // watcher required because layouts start rendering before the route is initialized -watch(() => route.params.identifier as string, loadComponentData) -onBeforeMount(() => { - // onBeforeMount required for refresh case (route will be set already so ^ watcher will not fire) - if (route.params.identifier) { - loadComponentData(route.params.identifier as string) - } -}) +watch(() => route.params.identifier as string, loadComponentData, { immediate: true }) diff --git a/src/components/bcros/filing/common/filedAnd/PendingCoa.vue b/src/components/bcros/filing/common/filedAnd/PendingCoa.vue index bf12513..5fefd3a 100644 --- a/src/components/bcros/filing/common/filedAnd/PendingCoa.vue +++ b/src/components/bcros/filing/common/filedAnd/PendingCoa.vue @@ -9,7 +9,7 @@ arrow: true }" > - + diff --git a/src/components/bcros/todo/Item.vue b/src/components/bcros/todo/Item.vue index 2ef1d7f..4ac5c35 100644 --- a/src/components/bcros/todo/Item.vue +++ b/src/components/bcros/todo/Item.vue @@ -362,7 +362,11 @@ const cancelPaymentAndSetToDraft = async (_refreshDashboard = true): Promise - + diff --git a/src/components/bcros/todo/expansion-content/DraftWithNR.vue b/src/components/bcros/todo/expansion-content/DraftWithNR.vue new file mode 100644 index 0000000..d287e44 --- /dev/null +++ b/src/components/bcros/todo/expansion-content/DraftWithNR.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/src/enums/name-request-consent-flag-e.ts b/src/enums/name-request-consent-flag-e.ts new file mode 100644 index 0000000..7b2d140 --- /dev/null +++ b/src/enums/name-request-consent-flag-e.ts @@ -0,0 +1,7 @@ +// Constants +export const NrConsentFlagE = { + RECEIVED_STATE: 'Received', + NOT_RECEIVED_STATE: 'Not Received', + NOT_REQUIRED_STATE: 'Not Required', + WAIVED_STATE: 'Waived' +} diff --git a/src/pages/dashboard.vue b/src/pages/dashboard.vue index 68b136e..01cfb82 100644 --- a/src/pages/dashboard.vue +++ b/src/pages/dashboard.vue @@ -102,11 +102,11 @@ const alerts = computed((): Array> => { alertList.push({ alertType: AlertTypesE.FROZEN }) } if ((currentBusiness.value?.goodStanding === false) || - (allWarnings.some(item => item.warningType === WarningTypesE.NOT_IN_GOOD_STANDING))) { + (allWarnings.some(item => item.warningType === WarningTypesE.NOT_IN_GOOD_STANDING))) { alertList.push({ alertType: AlertTypesE.STANDING }) } if ((allWarnings.some(item => item.warningType === WarningTypesE.INVOLUNTARY_DISSOLUTION)) || - (currentBusiness.value?.inDissolution)) { + (currentBusiness.value?.inDissolution)) { let days = null const warning = allWarnings.find(item => item.warningType?.includes(WarningTypesE.INVOLUNTARY_DISSOLUTION) diff --git a/src/stores/businessBootstrap.ts b/src/stores/businessBootstrap.ts index 214121d..4e0bb85 100644 --- a/src/stores/businessBootstrap.ts +++ b/src/stores/businessBootstrap.ts @@ -8,6 +8,7 @@ import { filingTypeToName } from '~/utils/todo/task-filing/helper' /** Manages bcros bootstrap business (temp reg) data */ export const useBcrosBusinessBootstrap = defineStore('bcros/businessBootstrap', () => { const bootstrapFiling: Ref<{ filing: BootstrapFilingI }> = ref(undefined) + const isStoreLoading = ref(false) const bootstrapIdentifier = computed(() => bootstrapFiling.value?.filing.business.identifier) const bootstrapLegalType = computed(() => bootstrapFiling.value?.filing.business.legalType) const bootstrapFilingType = computed(() => bootstrapFiling.value?.filing.header.name) @@ -108,12 +109,27 @@ export const useBcrosBusinessBootstrap = defineStore('bcros/businessBootstrap', console.error(`Attempted to load ${identifier} as a bootstrap filing.`) return } + + const storeIsLoading = new Promise((resolve) => { + watch(isStoreLoading, (newValue) => { + if (newValue === false) { // check the condition + resolve(true) + } + }, { immediate: true }) + }) + + // this acts as semaphore, to check if we already have running loadBusinessBootstrap for current/another business + // because there is a possibility to have race conditions to some of the variables if it's started in another thread + await storeIsLoading + const bootsrapCached = bootstrapIdentifier.value === identifier if (!bootsrapCached || force) { + isStoreLoading.value = true bootstrapFiling.value = await getBootstrapFiling(identifier) if (bootstrapNrNumber.value) { - loadLinkedNameRequest(bootstrapNrNumber.value) + await loadLinkedNameRequest(bootstrapNrNumber.value) } + isStoreLoading.value = false } } diff --git a/src/utils/date.ts b/src/utils/date.ts index 919e690..6dff3ce 100644 --- a/src/utils/date.ts +++ b/src/utils/date.ts @@ -49,12 +49,8 @@ export const todayIsoDateString = () => dateToString(new Date(), 'YYYY-MM-DD') export function daysBetweenTwoDates (initialDate: Date, d: Date) { // safety check - if (initialDate !== new Date(initialDate)) { - return NaN - } - if (d !== new Date(d)) { - return NaN - } + if (!isDate(initialDate) || isNaN(initialDate.getTime())) { return NaN } + if (!isDate(d) || isNaN(d.getTime())) { return NaN } // set "date" to 12:00 am Pacific d.setHours(0, 0, 0, 0) diff --git a/src/utils/nr-utils.ts b/src/utils/nr-utils.ts new file mode 100644 index 0000000..f28a28b --- /dev/null +++ b/src/utils/nr-utils.ts @@ -0,0 +1,81 @@ +import { getName } from 'country-list' + +import type { NrApplicantIF } from '@bcrs-shared-components/interfaces' +import { NrRequestActionCodes } from '@bcrs-shared-components/enums' +import type { NameRequestI } from '#imports' +import { NrConsentFlagE } from '~/enums/name-request-consent-flag-e' + +export const getApplicantName = (applicant: NrApplicantIF): string => { + const firstName = applicant?.firstName ? applicant.firstName + ' ' : '' + const middleName = applicant?.middleName ? applicant.middleName + ' ' : '' + return `${firstName}${middleName}${applicant?.lastName || ''}` +} + +export const getApplicantAddress = (applicant: NrApplicantIF): string => { + const city = applicant?.city + const stateProvince = applicant?.stateProvinceCd + const postal = applicant?.postalCd + const country = applicant?.countryTypeCd ? getName(applicant?.countryTypeCd) : '' + + // Build address lines + let address = applicant?.addrLine1 + if (applicant?.addrLine2) { + address = `${address}, ${applicant?.addrLine2}` + } + if (applicant?.addrLine3) { + address = `${address}, ${applicant?.addrLine3}` + } + + return `${address}, ${city}, ${stateProvince}, ${postal}, ${country}` +} + +export const getNrRequestType = (nameRequest?: NameRequestI): string => { + switch (nameRequest?.request_action_cd) { + case NrRequestActionCodes.NEW_BUSINESS: + return 'New Business' + case NrRequestActionCodes.RESTORE: + return 'Restoration Request' + case NrRequestActionCodes.AMALGAMATE: + return 'Amalgamation' + case NrRequestActionCodes.MOVE: + return 'Continuation In' + } + return '' // should never happen if name request is passed in +} + +/** The condition/consent string. */ +export const getNrConditionConsent = (nameRequest: NameRequestI): string => { + if (!nameRequest || nameRequest.state === NameRequestStateE.APPROVED) { + return NrConsentFlagE.NOT_REQUIRED_STATE + } + if (nameRequest.consentFlag === null) { + return NrConsentFlagE.NOT_REQUIRED_STATE + } + if (nameRequest.consentFlag === 'R') { + return NrConsentFlagE.RECEIVED_STATE + } + if (nameRequest.consentFlag === 'N') { + return NrConsentFlagE.WAIVED_STATE + } + return NrConsentFlagE.NOT_RECEIVED_STATE +} + +function expiresText (nameRequest: any): string { + const date = apiToDate(nameRequest.expirationDate) + const expireDays = daysBetweenTwoDates(new Date(), date) + + // NB: 0 means NR expires today + if (isNaN(expireDays) || expireDays < 0) { + return 'Expired' + } else if (expireDays < 1) { + return 'Expires today' + } else if (expireDays < 2) { + return 'Expires tomorrow' + } else { + return `Expires in ${expireDays} days` + } +} + +export const nrSubtitle = (nameRequest: NameRequestI): string => { + return `NR APPROVED - ${expiresText(nameRequest)}` +} diff --git a/src/utils/todo/task-filing/content-loader.ts b/src/utils/todo/task-filing/content-loader.ts index 35d00f6..1688d81 100644 --- a/src/utils/todo/task-filing/content-loader.ts +++ b/src/utils/todo/task-filing/content-loader.ts @@ -1,5 +1,6 @@ import { FilingNames, FilingTypes, CorpTypeCd } from '@bcrs-shared-components/enums' import { filingTypeToName } from './helper' +import { nrSubtitle } from '~/utils/nr-utils' /** Get the title string for the todo item based ob the given filing TaskToDoI object */ export const getTitle = (filing: TaskToDoI, corpFullDescription: string): string => { @@ -140,11 +141,7 @@ export const addSubtitleOrContent = (todoItem: TodoItemI): void => { } else if (todoItem.payErrorObj) { todoItem.subtitle = t('text.todoItem.status.paymentIncomplete') } else if (filingWithNR.includes(todoItem.name)) { - // TO-DO: the subtitle is special if nameRequest exists --- updated this when NameRequest store is implemented - // if (this.getNameRequest) { - // subtitle = `NR APPROVED - ${this.expiresText(this.getNameRequest)}` - // } else { subtitle = 'DRAFT' } - todoItem.subtitle = t('text.todoItem.status.draft') + todoItem.subtitle = todoItem.nameRequest ? nrSubtitle(todoItem.nameRequest) : t('text.todoItem.status.draft') } else { todoItem.subtitle = t('text.todoItem.status.draft') } diff --git a/src/utils/todo/task-filing/index.ts b/src/utils/todo/task-filing/index.ts index ef271fd..0e50303 100644 --- a/src/utils/todo/task-filing/index.ts +++ b/src/utils/todo/task-filing/index.ts @@ -7,8 +7,9 @@ import { filingTypeToName } from './helper' /** Build TodoItemI from filing TaskToDoI */ // https://docs.google.com/spreadsheets/d/1rJY3zsrdHS2qii5xb7hq1gt-D55NsakJtdu9ld9d80U/edit?gid=0#gid=0 -export const buildFilingTodo = async (task: TaskI) : Promise => { - const { bootstrapFiling, bootstrapLegalType, linkedNr } = useBcrosBusinessBootstrap() +export const buildFilingTodo = async (task: TaskI): Promise => { + const { bootstrapFiling, bootstrapLegalType } = useBcrosBusinessBootstrap() + const { linkedNr } = storeToRefs(useBcrosBusinessBootstrap()) const { currentBusiness } = useBcrosBusiness() if (!!currentBusiness && !!bootstrapFiling) { console.error('Attempted buildFilingTodo without initializing the business or bootstrap first.') @@ -36,6 +37,7 @@ export const buildFilingTodo = async (task: TaskI) : Promise => { draftTitle: getDraftTitle(filing), status: header.status, enabled: task.enabled, + nameRequest: linkedNr.value, order: task.order, paymentMethod: header.paymentMethod || null, paymentToken: header.paymentToken || null, @@ -47,8 +49,12 @@ export const buildFilingTodo = async (task: TaskI) : Promise => { addSubtitleOrContent(newTodo) // Add the filingSubType field to newTodo if needed - if (isFilingType([FilingTypes.DISSOLUTION])) { newTodo.filingSubType = filingData.dissolutionType } - if (isFilingType([FilingTypes.RESTORATION])) { newTodo.filingSubType = filingData.type } + if (isFilingType([FilingTypes.DISSOLUTION])) { + newTodo.filingSubType = filingData.dissolutionType + } + if (isFilingType([FilingTypes.RESTORATION])) { + newTodo.filingSubType = filingData.type + } // Add the legalType field to newTodo if needed if ( @@ -113,8 +119,6 @@ export const buildFilingTodo = async (task: TaskI) : Promise => { newTodo.nextArDate = filingData.nextArDate } - newTodo.nameRequest = linkedNr - // For Continuation In filing, add submission information (e.g., submitter, submittedDate, latestReviewComment) if (isFilingType([FilingTypes.CONTINUATION_IN])) { newTodo.submitter = header.submitter