Skip to content

Commit

Permalink
- app version = 7.0.30
Browse files Browse the repository at this point in the history
- updated some code comments
- added AmalgamatedInto interface object
- added enum mixin and utility functions
- added some business store getters
- refactored getReasonText() and added case for amalgamation
- cast some parameters to pre-empt code errors
- added unit tests
  • Loading branch information
Severin Beauvais committed Jan 3, 2024
1 parent 7ce2d90 commit a107c37
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 46 deletions.
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-filings-ui",
"version": "7.0.29",
"version": "7.0.30",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dashboard/TodoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
</div>
</template>

<!-- is this a draft IA or Registration? -->
<!-- is this a draft Amalgamation or IA or Registration? -->
<template
v-else-if="isStatusDraft(item) && (isTypeAmalgamation(item) || isTypeIncorporationApplication(item) ||
isTypeRegistration(item))"
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/business-state-interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EntityState, CorpTypeCd, FilingSubTypes, FilingTypes } from '@/enums'
import { AmalgamationTypes } from '@bcrs-shared-components/enums'
import { IsoDatePacific, ApiDateTimeUtc } from '@bcrs-shared-components/interfaces'

export interface FilingTypeIF {
Expand All @@ -16,6 +17,13 @@ export interface AllowedActionsIF {
}
}

export interface AmalgamatedIntoIF {
amalgamationDate: ApiDateTimeUtc
amalgamationType: AmalgamationTypes
identifier: string // eg, BC7654321
legalName: string
}

export interface BusinessWarningIF {
code: string // FUTURE: use an enum
filing?: string // not used
Expand All @@ -28,6 +36,7 @@ export interface BusinessWarningIF {
export interface ApiBusinessIF {
adminFreeze: boolean
allowedActions: AllowedActionsIF
amalgamatedInto?: AmalgamatedIntoIF
arMaxDate?: IsoDatePacific // not used
arMinDate?: IsoDatePacific // not used
associationType: string // COOP only
Expand Down
5 changes: 5 additions & 0 deletions src/mixins/enum-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export default class EnumMixin extends Vue {
return (item.name === FilingTypes.CORRECTION)
}

/** DEPRECATED Returns True if filing is a Dissolution. */
isTypeDissolution (item: any): boolean {
return (item.name === FilingTypes.DISSOLUTION)
}

/** DEPRECATED Returns True if filing is an Incorporation Application. */
isTypeIncorporationApplication (item: any): boolean {
return (item.name === FilingTypes.INCORPORATION_APPLICATION)
Expand Down
5 changes: 5 additions & 0 deletions src/services/enum-utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export default class EnumUtilities {
return (item.name === FilingTypes.CORRECTION)
}

/** Returns True if filing is a Dissolution. */
static isTypeDissolution (item: any): boolean {
return (item.name === FilingTypes.DISSOLUTION)
}

/** Returns True if filing is an Amalgamation. */
static isTypeAmalgamation (item: any): boolean {
return (item.name === FilingTypes.AMALGAMATION_APPLICATION)
Expand Down
12 changes: 9 additions & 3 deletions src/stores/businessStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AllowedActionsIF, ApiBusinessIF, ApiDateTimeUtc, BusinessStateIF, BusinessWarningIF } from '@/interfaces'
import { AllowedActionsIF, AmalgamatedIntoIF, ApiBusinessIF, ApiDateTimeUtc, BusinessStateIF, BusinessWarningIF }
from '@/interfaces'
import { defineStore } from 'pinia'
import { CorpTypeCd, EntityState } from '@/enums'
import { DateUtilities, LegalServices } from '@/services/'
Expand Down Expand Up @@ -34,11 +35,16 @@ export const useBusinessStore = defineStore('business', {
}),

getters: {
/** The allowed actions object. */
/** The Allowed Actions object. */
getAllowedActions (state: BusinessStateIF): AllowedActionsIF {
return state.businessInfo.allowedActions
},

/** The Amalgamated Info object. */
getAmalgamatedInto (state: BusinessStateIF): AmalgamatedIntoIF {
return state.businessInfo.amalgamatedInto
},

/** The business number (aka Tax ID). */
getBusinessNumber (state: BusinessStateIF): string {
return state.businessInfo.taxId
Expand All @@ -49,7 +55,7 @@ export const useBusinessStore = defineStore('business', {
return state.businessInfo.warnings
},

/** The business state.businessInfo. */
/** The business state. */
getBusinessState (state: BusinessStateIF): EntityState {
return state.businessInfo.state
},
Expand Down
4 changes: 2 additions & 2 deletions src/stores/filingHistoryListStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useFilingHistoryListStore = defineStore('filingHistoryList', {
})
},

/** Returns the total AGM extension duration requires argument for year */
/** The function to compute total AGM extension duration. Requires argument for AGM Year. */
getTotalAgmExtensionDuration (state: FilingHistoryListStateIF): (year: number) => number {
return (year: number) => {
return state.filings.reduce((totalMonths, filing) => {
Expand All @@ -47,11 +47,11 @@ export const useFilingHistoryListStore = defineStore('filingHistoryList', {
return totalMonths
}
const filingExtension = filing.data?.agmExtension
// Cast year as number
// Skip if extension data is missing
if (!filingExtension) {
return totalMonths
}
// Cast year as number
// Skip if years don't match
if (Number(filingExtension.year) !== year) {
return totalMonths
Expand Down
78 changes: 56 additions & 22 deletions src/stores/rootStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineStore } from 'pinia'
import { CorpTypeCd, EntityStatus, FilingSubTypes, FilingTypes } from '@/enums'
import { ApiTaskIF, DissolutionConfirmationResourceIF, FilingDataIF, OfficeAddressIF, PartyIF, RootStateIF,
TodoListResourceIF, IsoDatePacific, StateFilingIF } from '@/interfaces'
import { ApiTaskIF, DissolutionConfirmationResourceIF, FilingDataIF, OfficeAddressIF, PartyIF,
RootStateIF, TodoListResourceIF, IsoDatePacific, StateFilingIF } from '@/interfaces'
import { DateUtilities, EnumUtilities, LegalServices } from '@/services'
import { useBusinessStore } from './businessStore'
import { useFilingHistoryListStore } from './filingHistoryListStore'
Expand Down Expand Up @@ -225,40 +225,74 @@ export const useRootStore = defineStore('root', {
return state.stateFiling
},

/**
* A formatted concatenation of the name and the effective date of the filing.
* Only used when entity is historical.
*/
/** The historical reason text to display in the info header. */
getReasonText (): string {
const enDash = '–' // ALT + 0150
const businessStore = useBusinessStore()
const stateFiling = this.getStateFiling as StateFilingIF // may be null

if (!businessStore.isHistorical) return null // safety check

// check if historical reason is amalgamation
const amalgamatedInto = businessStore.getAmalgamatedInto
if (amalgamatedInto) return reasonTextAmalgamation()

// get state filing (may be null)
const stateFiling = this.getStateFiling as StateFilingIF
const filingType = stateFiling?.header?.name
if (!filingType) return null // safety check

// create reason text to display in the info header
let name: string
let date: string
// check if historical reason is dissolution
if (filingType === FilingTypes.DISSOLUTION) return reasonTextDissolution()

// check if historical reason is continuation out
if (filingType === FilingTypes.CONTINUATION_OUT) return reasonTextContinuationOut()

// fallback reason text
return reasonTextOther()

if (filingType === FilingTypes.DISSOLUTION) {
name = EnumUtilities.dissolutionTypeToName(
//
// helper functions
//

/** The reason text for a business made historical by an amalgamation. */
function reasonTextAmalgamation (): string {
const name = 'Amalgamation'
const amalgamationDate = DateUtilities.apiToDate(amalgamatedInto.amalgamationDate)
if (!amalgamationDate) throw new Error('Invalid amalgamation date')
const date = DateUtilities.dateToPacificDate(amalgamationDate, true)
const identifier = amalgamatedInto.identifier || 'Unknown Company'
return `${name} ${enDash} ${date} ${enDash} ${identifier}`
}

/** The reason text for a business made historical by a dissolution. */
function reasonTextDissolution (): string {
const name = EnumUtilities.dissolutionTypeToName(
businessStore.isFirm,
(stateFiling?.dissolution?.dissolutionType as FilingSubTypes)
(stateFiling.dissolution?.dissolutionType as FilingSubTypes)
)
const dissolutionDate = DateUtilities.yyyyMmDdToDate(stateFiling.dissolution?.dissolutionDate)
if (!dissolutionDate) throw new Error('Invalid dissolution date')
date = DateUtilities.dateToPacificDate(dissolutionDate, true)
} else {
name = (filingType === FilingTypes.CONTINUATION_OUT)
? 'Continued Out'
: EnumUtilities.filingTypeToName(filingType)
const effectiveDate = DateUtilities.apiToDate(stateFiling.header.effectiveDate)
const date = DateUtilities.dateToPacificDate(dissolutionDate, true)
return `${name} ${enDash} ${date}`
}

/** The reason text for a business made historical by a continuation out. */
function reasonTextContinuationOut (): string {
const name = 'Continued Out'
const effectiveDate = DateUtilities.apiToDate(stateFiling.header?.effectiveDate)
if (!effectiveDate) throw new Error('Invalid effective date')
date = DateUtilities.dateToPacificDateTime(effectiveDate)
const date = DateUtilities.dateToPacificDate(effectiveDate, true)
return `${name} ${enDash} ${date}`
}

const enDash = '–' // ALT + 0150
return `${name} ${enDash} ${date}`
/** The reason text for a business made historical by some other state filing. */
function reasonTextOther (): string {
const name = EnumUtilities.filingTypeToName(filingType)
const effectiveDate = DateUtilities.apiToDate(stateFiling.header?.effectiveDate)
if (!effectiveDate) throw new Error('Invalid effective date')
const date = DateUtilities.dateToPacificDate(effectiveDate, true)
return `${name} ${enDash} ${date}`
}
},

/** The limited restoration active-until date, if it exists, otherwise null. */
Expand Down
2 changes: 1 addition & 1 deletion src/views/AgmExtension.vue
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin,
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/AgmLocationChg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export default class AgmLocationChg extends Mixins(CommonMixin, DateMixin,
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/AnnualReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ export default class AnnualReport extends Mixins(CommonMixin, DateMixin, FilingM
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/ConsentContinuationOut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/ContinuationOut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin,
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/Correction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ export default class Correction extends Mixins(CommonMixin, DateMixin, EnumMixin
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/StandaloneDirectorsFiling.vue
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ export default class StandaloneDirectorsFiling extends Mixins(CommonMixin, DateM
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
2 changes: 1 addition & 1 deletion src/views/StandaloneOfficeAddressFiling.vue
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D
ret = await LegalServices.createFiling(this.getIdentifier, filing, isDraft)
}
return ret
} catch (error) {
} catch (error: any) {
// save errors or warnings, if any
this.saveErrors = error?.response?.data?.errors || []
this.saveWarnings = error?.response?.data?.warnings || []
Expand Down
Loading

0 comments on commit a107c37

Please sign in to comment.