Skip to content

Commit

Permalink
- created getter for template logic
Browse files Browse the repository at this point in the history
- renamed some emitters/events for consistency
- removed conversion from logic (not used)
- type cleanup
- misc cleanup
- don't save legal name if it's empty
- fixed some unit tests
  • Loading branch information
Severin Beauvais committed Apr 18, 2024
1 parent e8fdb7e commit 5be659b
Show file tree
Hide file tree
Showing 21 changed files with 131 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ export default class CorrectCompanyName extends Mixins(CommonMixin) {
if (this.formType === CorrectNameOptions.CORRECT_NAME) {
// set the new company name
this.setNameRequestLegalName(this.companyName)
this.emitIsSaved(true)
this.emitSaved(true)
}
}
/** Inform parent the process is complete. */
@Emit('isSaved')
@Emit('saved')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private emitIsSaved (isSaved: boolean): void {}
private emitSaved (isSaved: boolean): void {}
/** Inform parent when form is valid and ready for submission. */
@Watch('valid')
@Emit('isValid')
@Emit('valid')
private emitValid (): boolean {
return this.valid
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/common/YourCompany/CorrectName/CorrectName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
:key="item.id"
:formType="formType"
:validate="validateNameChange"
@isSaved="emitIsSaved($event)"
@isValid="isFormValid = $event"
@saved="emitIsSaved($event)"
@valid="isFormValid = $event"
/>
</v-expansion-panel-content>
</v-expansion-panel>
Expand Down Expand Up @@ -101,7 +101,7 @@ import CorrectNameToNumber from './CorrectNameToNumber.vue'
})
export default class CorrectName extends Vue {
/** The options to display */
@Prop() readonly correctionNameChoices!: Array<string>
@Prop() readonly correctNameChoices!: Array<string>
// local properties
displayedOptions: Array<CorrectNameOptionIF> = []
Expand Down Expand Up @@ -139,7 +139,7 @@ export default class CorrectName extends Vue {
mounted (): void {
// Filter the options to be displayed by what id's were passed from the parent component
this.displayedOptions = this.correctionNameOptions.filter(
option => this.correctionNameChoices.includes(option.id)
option => this.correctNameChoices.includes(option.id)
)
// open by default and assign id if only 1 option
if (this.isOneOption) {
Expand All @@ -149,7 +149,7 @@ export default class CorrectName extends Vue {
}
get isOneOption (): boolean {
return (this.correctionNameChoices.length === 1)
return (this.correctNameChoices.length === 1)
}
/** Trigger form submission */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
if (this.isNameRequestInvalid(nr)) {
// Invalid NR type, inform parent the process is done and prompt confirm dialog
this.emitIsSaved()
this.emitSaved()
const dialogContent = this.nameRequestErrorText(nr)
await this.showConfirmDialog(
Expand All @@ -218,39 +218,41 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
this.storeNameRequest(nr)
// Set our entity type, if it's a conversion request
if (nr.request_action_cd === NrRequestActionCodes.CONVERSION) {
this.setEntityType(nr.legalType as unknown as CorpTypeCd)
this.setEntityType(nr.legalType as any)
this.setEntityTypeChangedByName(true)
}
this.emitIsSaved(true)
this.emitSaved(true)
}
} catch {
// "fetchValidateNameRequest" handles its own errors
// Inform parent process is complete
this.emitIsSaved()
this.emitSaved()
}
}
}
/* Checks name request type or if it's an invalid conversion name request. */
isNameRequestInvalid (nr: NameRequestIF): boolean {
const isNameEntityTypeDifferent = (this.getEntityType !== nr.legalType as unknown as CorpTypeCd)
const isNameEntityTypeDifferent = (this.getEntityType !== nr.legalType as any)
const entityTypeOptions = this.getResource?.changeData?.entityTypeOptions
const isValidConversionNameRequest = nr.request_action_cd === NrRequestActionCodes.CONVERSION &&
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: NameRequestIF): string {
const isConversionOrAlterationNameRequest = nr.request_action_cd === NrRequestActionCodes.CONVERSION
const isConversionOrAlterationNameRequest = (nr.request_action_cd === NrRequestActionCodes.CONVERSION)
let dialogContent = ''
if (isConversionOrAlterationNameRequest) {
dialogContent = `<p class="info-text">
This alteration 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>`
} else {
const corpFullDescription = GetCorpFullDescription(nr.legalType as unknown as CorpTypeCd)
const corpFullDescription = GetCorpFullDescription(nr.legalType as any)
dialogContent = `<p class="info-text">
This ${corpFullDescription}
Name Request does not match the current business type
Expand All @@ -270,13 +272,12 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
...this.getNameRequest,
...nameRequest
} as any)
// *** TODO: should fallback be null?
this.setNameRequestLegalName(this.getNrApprovedName(nameRequest) || '')
this.setNameRequestLegalName(this.getNrApprovedName(nameRequest) || null)
}
/** Inform parent the process is complete. */
@Emit('isSaved')
emitIsSaved (isSaved = false): boolean {
@Emit('saved')
private emitSaved (isSaved = false): boolean {
if (!isSaved) this.$refs.correctNrForm.resetValidation()
return isSaved
}
Expand All @@ -286,8 +287,8 @@ export default class CorrectNameRequest extends Mixins(CommonMixin, NameRequestM
@Watch('nameRequestNumber')
@Watch('applicantPhone')
@Watch('applicantEmail')
@Emit('isValid')
emitValid (): boolean {
@Emit('valid')
private emitValid (): boolean {
return this.isFormValid
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,22 @@ export default class CorrectNameToNumber extends Vue {
// delete the current NR number (if any)
this.setNameRequest({
...this.getNameRequest,
nrNum: '' // *** TODO: should this be undefined?
nrNum: undefined
} as any)
// delete the current legal name (if any)
console.log('>>> setting name request legal name')
this.setNameRequestLegalName(null) // *** TODO: should this be undefined?
this.emitIsSaved(true)
this.setNameRequestLegalName(null)
this.emitSaved(true)
}
}
/** Inform parent the process is complete. */
@Emit('isSaved')
@Emit('saved')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private emitIsSaved (isSaved: boolean): void {}
private emitSaved (saved: boolean): void {}
/** Inform parent when form is valid and ready for submission. */
@Watch('correctToNumbered')
@Emit('isValid')
@Emit('valid')
private emitValid (): boolean {
return this.correctToNumbered
}
Expand Down
74 changes: 50 additions & 24 deletions src/components/common/YourCompany/EntityName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
class="pa-0"
>
<v-chip
v-if="hasCompanyNameChanged || (hasBusinessNameChanged && (isAlterationFiling || isFirmChangeFiling ||
isFirmConversionFiling || isSpecialResolutionFiling))"
v-if="shouldShowEditedLabel"
id="corrected-lbl"
x-small
label
Expand Down Expand Up @@ -207,7 +206,7 @@
cols="9"
>
<CorrectName
:correctionNameChoices="correctionNameChoices"
:correctNameChoices="correctNameChoices"
@isSaved="nameChangeHandler($event)"
@cancel="isEditingNames = false"
/>
Expand Down Expand Up @@ -300,34 +299,61 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
@Action(useStore) setEntityType!: (x: CorpTypeCd) => void
@Action(useStore) setEntityTypeChangedByName!: (x: boolean) => void
// local properties
dropdown = false // v-model for dropdown menu
hasCompanyNameChanged = false // only used by corrections
isEditingNames = false
/** The corp full description. */
get corpFullDescription (): string {
return GetCorpFullDescription(this.getNameRequest.legalType as unknown as CorpTypeCd)
return GetCorpFullDescription(this.getNameRequest.legalType as any)
}
/** Whether the edited label should be displayed. */
get shouldShowEditedLabel (): boolean {
return (
this.hasCompanyNameChanged ||
(
this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling)
)
)
}
// 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,
// and the name has not been changed by type.
/**
* Whether 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,
* and the name has not been changed by type.
*/
get shouldShowUndoButton (): boolean {
return (this.hasCompanyNameChanged ||
(this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling))) &&
!this.isNameChangedByType
return (
(
this.hasCompanyNameChanged ||
(
this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling)
)
) &&
!this.isNameChangedByType
)
}
// Returns true if the type details should be displayed. This is the case when there is no new NR,
// the business name has changed, and the filing is an alteration, firm change, or firm conversion filing,
// and the name has not been changed by type.
/**
* Whether the type details should be displayed. This is the case when:
* - there is no new NR, and
* - the business name has changed, and
* - the filing is an alteration or firm change filing, and
* - the name has not been changed by type
*/
get shouldShowTypeDetail (): boolean {
return !this.hasNewNr && this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isFirmConversionFiling) &&
!this.isNameChangedByType
return (
!this.hasNewNr &&
this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling) &&
!this.isNameChangedByType
)
}
// local properties
dropdown = false // v-model for dropdown menu
hasCompanyNameChanged = false // only used by corrections
isEditingNames = false
/** The company name (from NR, or incorporation number). */
get companyName (): string {
if (this.getNameRequestLegalName) return this.getNameRequestLegalName
Expand All @@ -352,7 +378,7 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
}
/** The current options for name changes. */
get correctionNameChoices (): Array<CorrectNameOptions> {
get correctNameChoices (): Array<CorrectNameOptions> {
// safety check
if (!this.getResource.changeData) return []
Expand All @@ -368,7 +394,7 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
/** Whether to show the name options button and component. */
get showNameOptions (): boolean {
return (this.correctionNameChoices.length > 0)
return (this.correctNameChoices.length > 0)
}
get nrFullName (): string {
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/filing-interfaces/filing-data-interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { FilingCodes } from '@/enums/'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module/'

//
// See also @bcrs-shared-components/interfaces/filing-data-interface.ts
//

/** Filing data object passed to the SBC Fee Summary. */
export interface FilingDataIF {
filingDescription?: string
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/resource-interfaces/resource-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ResourceIF {
addressLabel: string
title?: string // BEN corrections only
description?: string // BEN corrections only
filingData: FilingDataIF | Array<FilingDataIF>
filingData: FilingDataIF
additionalFilingData?: FilingDataIF,
changeData?: {
correctNameOptions: Array<CorrectNameOptions>
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/fee-mixin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import { EmptyFees, FeesIF } from '@/interfaces'
import { EmptyFees, FeesIF, FilingDataIF } from '@/interfaces'
import { PayServices } from '@/services/'
import { StaffPaymentOptions } from '@bcrs-shared-components/enums'
import { FilingDataIF, StaffPaymentIF } from '@bcrs-shared-components/interfaces'
import { StaffPaymentIF } from '@bcrs-shared-components/interfaces'
import { cloneDeep } from 'lodash'
import { useStore } from '@/store/store'

Expand Down
19 changes: 13 additions & 6 deletions src/mixins/filing-template-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ export default class FilingTemplateMixin extends DateMixin {
contactPoint: this.getContactPoint,
nameRequest: {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
},
offices: this.getOfficeAddresses,
Expand Down Expand Up @@ -297,8 +298,9 @@ export default class FilingTemplateMixin extends DateMixin {
if (this.getNameRequestNumber || this.hasBusinessNameChanged || this.hasBusinessTypeChanged) {
filing.alteration.nameRequest = {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
}
}
Expand Down Expand Up @@ -403,8 +405,9 @@ export default class FilingTemplateMixin extends DateMixin {
if (this.getNameRequestNumber || this.hasBusinessNameChanged) {
filing.restoration.nameRequest = {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
}
} else {
Expand Down Expand Up @@ -523,8 +526,9 @@ export default class FilingTemplateMixin extends DateMixin {
filing.changeOfName = {
nameRequest: {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
},
legalName: this.getNameRequestLegalName
Expand Down Expand Up @@ -587,8 +591,9 @@ export default class FilingTemplateMixin extends DateMixin {
if (this.hasBusinessNameChanged) {
filing.changeOfRegistration.nameRequest = {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
}
}
Expand Down Expand Up @@ -693,11 +698,13 @@ export default class FilingTemplateMixin extends DateMixin {
}

// Apply business name change to filing
// FUTURE: can probably delete this as Record Conversion doesn't allow name change
if (this.hasBusinessNameChanged) {
filing.conversion.nameRequest = {
// add in the fields needed by Legal API
// don't save legal name if it's empty
...this.getNameRequest,
legalName: this.getNameRequestLegalName,
legalName: this.getNameRequestLegalName || undefined,
nrNumber: this.getNameRequestNumber
}
}
Expand Down
Loading

0 comments on commit 5be659b

Please sign in to comment.