Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19822 Fixed NR validation on submit #656

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.8.15",
"version": "5.9.1",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
17 changes: 11 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -980,12 +980,17 @@ export default class App extends Mixins(CommonMixin, DateMixin, FilingTemplateMi
private async processNameRequest (filing: any): Promise<void> {
try {
const nrNumber = filing[filing.header?.name].nameRequest.nrNumber

// fetch NR data
const nrResponse = await LegalServices.fetchValidContactNr(nrNumber).catch(error => {
console.log('NR error =', error) // eslint-disable-line no-console
this.nameRequestInvalidErrorDialog = true
})
const applicantPhone = filing[filing.header?.name].nameRequest.applicantPhone // may be undefined
const applicantEmail = filing[filing.header?.name].nameRequest.applicantEmail // may be undefined
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample filing JSON:

image


// Fetch NR data using saved applicant phone or email (eg, restoration or amalgamation).
// NB - if NR is affiliated to the current account (eg, IA or registration) then phone and email
// don't matter.
const nrResponse = await LegalServices.fetchValidContactNr(nrNumber, applicantPhone, applicantEmail)
.catch(error => {
console.log('NR error =', error) // eslint-disable-line no-console
this.nameRequestInvalidErrorDialog = true
})

//
// The NR checks below are sort-of a duplicate of code in BusinessName.vue and
Expand Down
26 changes: 16 additions & 10 deletions src/components/common/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export default class Actions extends Mixins(AmalgamationMixin, CommonMixin,
@Getter(useStore) getEntityIdentifier!: string
@Getter(useStore) getFilingType!: string
@Getter(useStore) getMaxStep!: number
// @Getter(useStore) getNameRequestApplicant!: NrApplicantIF
// @Getter(useStore) getNameRequestNumber!: string
@Getter(useStore) getSteps!: Array<any>
@Getter(useStore) isBusySaving!: boolean
@Getter(useStore) isEntityType!: boolean
Expand Down Expand Up @@ -250,13 +252,16 @@ export default class Actions extends Mixins(AmalgamationMixin, CommonMixin,
return
}

// If this is a named company IA, validate NR before filing submission. This method is different
// from the processNameRequest method in App.vue. This method shows a generic message if
// the Name Request is not valid and clicking ok in the pop up redirects to the Manage Businesses
// dashboard.
// If a NR was used, validate it before filing submission. This method is different from the
// processNameRequest method in App.vue -- this method shows a generic message if the NR is
// not valid and clicking OK in the pop up redirects to the Manage Businesses dashboard.
if (this.getNameRequestNumber) {
try {
await this._validateNameRequest(this.getNameRequestNumber)
await this._validateNameRequest(
this.getNameRequestNumber,
this.getNameRequestApplicant.phoneNumber,
this.getNameRequestApplicant.emailAddress
)
} catch (error) {
console.log('Error validating NR in onClickFilePay(): ', error) // eslint-disable-line no-console
this.setIsFilingPaying(false)
Expand Down Expand Up @@ -328,11 +333,12 @@ export default class Actions extends Mixins(AmalgamationMixin, CommonMixin,

// FUTURE: merge this with NameRequestMixin::validateNameRequest()
/** Fetches NR and validates it. */
private async _validateNameRequest (nrNumber: string): Promise<void> {
const nameRequest = await LegalServices.fetchValidContactNr(nrNumber).catch(error => {
this.$root.$emit('name-request-retrieve-error')
throw new Error(error)
})
private async _validateNameRequest (nrNumber: string, phone = '', email = ''): Promise<void> {
const nameRequest = await LegalServices.fetchValidContactNr(nrNumber, phone, email)
.catch(error => {
this.$root.$emit('name-request-retrieve-error')
throw new Error(error)
})

// ensure NR was found
if (!nameRequest) {
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/filing-interfaces/filing-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface NameRequestFilingIF {
legalName?: string // only set when there is a name change (including NR)
nrNumber?: string // only set when there is an NR
correctNameOption?: CorrectNameOptions // only used by UI for save and resume
applicantPhone?: string // only used by UI for save and resume
applicantEmail?: string // only used by UI for save and resume
}

/** Interface for amalgamation filing data saved to the Legal API. */
Expand Down
13 changes: 10 additions & 3 deletions src/mixins/filing-template-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
ContinuationInFilingIF, CourtOrderIF, CourtOrderStepIF, CreateMemorandumIF, CreateResolutionIF,
CreateRulesIF, DefineCompanyIF, DissolutionFilingIF, DissolutionStatementIF, DocumentDeliveryIF,
EffectiveDateTimeIF, EmptyContactPoint, EmptyNaics, IncorporationAgreementIF, IncorporationFilingIF,
NaicsIF, NameRequestFilingIF, NameTranslationIF, OfficeAddressIF, OrgPersonIF, PartyIF,
RegistrationFilingIF, RegistrationStateIF, RestorationFilingIF, RestorationStateIF, ShareStructureIF,
SpecialResolutionIF, StaffPaymentIF, StaffPaymentStepIF, UploadAffidavitIF
NaicsIF, NrApplicantIF, NameRequestFilingIF, NameTranslationIF, OfficeAddressIF, OrgPersonIF,
PartyIF, RegistrationFilingIF, RegistrationStateIF, RestorationFilingIF, RestorationStateIF,
ShareStructureIF, SpecialResolutionIF, StaffPaymentIF, StaffPaymentStepIF, UploadAffidavitIF
} from '@/interfaces'
import {
AmalgamationTypes, ApprovalTypes, BusinessTypes, CoopTypes, CorrectNameOptions, DissolutionTypes,
Expand Down Expand Up @@ -55,6 +55,7 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
@Getter(useStore) getFolioNumber!: string
@Getter(useStore) getIncorporationAgreementStep!: IncorporationAgreementIF
@Getter(useStore) getMemorandum!: any
@Getter(useStore) getNameRequestApplicant!: NrApplicantIF
@Getter(useStore) getNameRequestApprovedName!: string
@Getter(useStore) getNameRequestNumber!: string
@Getter(useStore) getNameTranslations!: NameTranslationIF[]
Expand Down Expand Up @@ -186,6 +187,8 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
filing.amalgamationApplication.nameRequest.correctNameOption = CorrectNameOptions.CORRECT_NEW_NR
filing.amalgamationApplication.nameRequest.legalName = this.getNameRequestApprovedName
filing.amalgamationApplication.nameRequest.nrNumber = this.getNameRequestNumber
filing.amalgamationApplication.nameRequest.applicantPhone = this.getNameRequestApplicant.phoneNumber
filing.amalgamationApplication.nameRequest.applicantEmail = this.getNameRequestApplicant.emailAddress
break
case CorrectNameOptions.CORRECT_AML_NUMBERED:
filing.amalgamationApplication.nameRequest.correctNameOption = CorrectNameOptions.CORRECT_AML_NUMBERED
Expand Down Expand Up @@ -391,6 +394,8 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
filing.continuationIn.nameRequest.correctNameOption = CorrectNameOptions.CORRECT_NEW_NR
filing.continuationIn.nameRequest.legalName = this.getNameRequestApprovedName
filing.continuationIn.nameRequest.nrNumber = this.getNameRequestNumber
filing.continuationIn.nameRequest.applicantPhone = this.getNameRequestApplicant.phoneNumber
filing.continuationIn.nameRequest.applicantEmail = this.getNameRequestApplicant.emailAddress
break
case CorrectNameOptions.CORRECT_AML_NUMBERED:
filing.continuationIn.nameRequest.correctNameOption = CorrectNameOptions.CORRECT_AML_NUMBERED
Expand Down Expand Up @@ -857,6 +862,8 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
filing.restoration.nameRequest.correctNameOption = CorrectNameOptions.CORRECT_NEW_NR
filing.restoration.nameRequest.legalName = this.getNameRequestApprovedName
filing.restoration.nameRequest.nrNumber = this.getNameRequestNumber
filing.restoration.nameRequest.applicantPhone = this.getNameRequestApplicant.phoneNumber
filing.restoration.nameRequest.applicantEmail = this.getNameRequestApplicant.emailAddress
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample filing JSON: (same screenshot as above)

image

break
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/legal-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ export default class LegalServices {
if (error?.response?.status === StatusCodes.NOT_FOUND) {
return null // NR not found (not an error)
} else if (error?.response?.status === StatusCodes.BAD_REQUEST) {
throw new Error('Sent invalid email or phone number.') // Sent invalid email or phone
throw new Error('Invalid email or phone number.')
} else if (error?.response?.status === StatusCodes.FORBIDDEN) {
throw new Error('Not sent email or phone number.') // Not sent the email or phone
throw new Error('Missing email or phone number.')
}
throw error
})
Expand Down
22 changes: 14 additions & 8 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ import {
NaicsIF,
NameRequestIF,
NameTranslationIF,
NrApplicantIF,
OfficeAddressIF,
OrgInformationIF,
OrgPersonIF,
PartyIF,
PeopleAndRoleIF,
PeopleAndRolesResourceIF,
RegisteredRecordsAddressesIF,
RegistrationStateIF,
ResourceIF,
Expand All @@ -66,8 +68,7 @@ import {
StateIF,
StepIF,
UploadAffidavitIF,
ValidationDetailIF,
PeopleAndRolesResourceIF
ValidationDetailIF
} from '@/interfaces'

// It's possible to move getters / actions into seperate files:
Expand Down Expand Up @@ -350,24 +351,29 @@ export const useStore = defineStore('store', {
return this.stateModel.business.officeAddress
},

/** The Correct Name Option. */
getCorrectNameOption (): CorrectNameOptions {
return this.stateModel.correctNameOption
},

/** The Name Request object. */
getNameRequest (): NameRequestIF {
return this.stateModel.nameRequest
},

/** The Name Request applicant (may be empty object). */
getNameRequestApplicant (): NrApplicantIF {
return this.getNameRequest.applicants // object not array
},

/** The approved name (from NR or Correct Name component). */
getNameRequestApprovedName (): string {
return this.stateModel.nameRequestApprovedName
},

/** The Correct Name Option. */
getCorrectNameOption (): CorrectNameOptions {
return this.stateModel.correctNameOption
},

/** The Name Request number. */
getNameRequestNumber (): string {
return this.getNameRequest?.nrNum
return this.getNameRequest.nrNum
},

/** The Company Step object. */
Expand Down
14 changes: 9 additions & 5 deletions tests/unit/Actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AxiosInstance as axios } from '@/utils'
import Actions from '@/components/common/Actions.vue'
import mockRouter from './MockRouter'
import LegalServices from '@/services/legal-services'
import { FilingTypes } from '@/enums'
import { FilingTypes, NameRequestStates } from '@/enums'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
import { CourtOrderStepIF, DefineCompanyIF, EffectiveDateTimeIF, IncorporationAgreementIF, NameRequestIF,
OrgPersonIF, PeopleAndRoleIF, ShareStructureIF, TombstoneIF } from '@/interfaces'
Expand Down Expand Up @@ -67,7 +67,7 @@ const nrData = {
nrNum: 'NR 1234567',
request_action_cd: 'NEW',
requestTypeCd: 'BC',
state: 'APPROVED'
state: NameRequestStates.APPROVED
}

describe('Actions component', () => {
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Emits error event if NR validation fails in file and pay', () => {

const expiredNR = { ...nrData }
expiredNR.expirationDate = 'Thu, 31 Dec 2019 23:59:59 GMT'
expiredNR.state = 'EXPIRED'
expiredNR.state = NameRequestStates.EXPIRED

// GET NR data
sinon.stub(axios, 'get')
Expand All @@ -130,8 +130,10 @@ describe('Emits error event if NR validation fails in file and pay', () => {
// init store
store.stateModel.currentDate = '2020/01/29'
store.stateModel.nameRequest = {
applicants: {},
legalType: CorpTypeCd.BENEFIT_COMPANY,
nrNum: 'NR 1234567'
nrNum: 'NR 1234567',
state: NameRequestStates.APPROVED
} as NameRequestIF
store.stateModel.nameRequestApprovedName = 'My Name Request Inc.'
store.stateModel.tombstone = {
Expand Down Expand Up @@ -386,8 +388,10 @@ describe('Actions component - Filing Functionality', () => {
// init store
store.stateModel.currentDate = '2020/01/29'
store.stateModel.nameRequest = {
applicants: {},
legalType: CorpTypeCd.BENEFIT_COMPANY,
nrNum: 'NR 1234567'
nrNum: 'NR 1234567',
state: NameRequestStates.APPROVED
} as NameRequestIF
store.stateModel.nameRequestApprovedName = 'My Name Request Inc.'
store.stateModel.nameTranslations = []
Expand Down
Loading