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

19390 Added draft task TING validation #629

Merged
merged 1 commit into from
Jan 19, 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.6.41",
"version": "5.6.42",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
}

// Get the business information
const business = await this.fetchAmalgamatingBusinessInfo(businessLookup)
const business = await this.fetchAmalgamatingBusinessInfo(businessLookup.identifier)

// Check for unaffiliated business.
if (!business.authInfo) {
Expand Down Expand Up @@ -350,6 +350,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
}

// Check for Legal API fetch issues.
// NB - don't check for null firstTask since that's valid
if (!business.businessInfo || !business.addresses || !business.firstFiling) {
this.snackbarText = 'Unable to add that business.'
this.snackbar = true
Expand All @@ -372,6 +373,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
isNotInGoodStanding: (business.businessInfo.goodStanding === false),
isFrozen: (business.businessInfo.adminFreeze === true),
isFutureEffective: this.isFutureEffective(business),
isDraftTask: this.isDraftTask(business),
isPendingFiling: this.isPendingFiling(business),
isLimitedRestoration: await this.isLimitedRestoration(business),
isHistorical: (business.businessInfo.state === EntityStates.HISTORICAL)
Expand Down
3 changes: 3 additions & 0 deletions src/components/Amalgamation/BusinessStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default class BusinessStatus extends Vue {
return 'A BC community contribution company must amalgamate to form a new BC community ' +
'contribution company.'

case AmlStatuses.ERROR_DRAFT_TASK:
return 'This business has a draft task. It cannot be part of an amalgamation.'

case AmlStatuses.ERROR_FROZEN:
return 'This business is frozen. Frozen businesses cannot be part of an amalgamation.'

Expand Down
1 change: 1 addition & 0 deletions src/enums/amalgamationEnums.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum AmlStatuses {
OK,
ERROR_CCC_MISMATCH,
ERROR_DRAFT_TASK,
ERROR_FROZEN,
ERROR_FOREIGN,
ERROR_FOREIGN_HORIZONTAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface AmalgamatingLearIF {
isNotInGoodStanding?: boolean // whether business is in good standing
isFrozen?: boolean // whether business is frozen
isFutureEffective?: boolean // whether business has a future effective filing
isDraftTask?: boolean // whether business has a draft task
isPendingFiling?: boolean // whether business has a pending filing
isLimitedRestoration?: boolean // whether business is in limited restoration
isHistorical?: boolean // whether business is historical
Expand Down
44 changes: 33 additions & 11 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class AmalgamationMixin extends Vue {
this.notInGoodStanding,
this.limitedRestoration,
this.futureEffectiveFiling,
this.draftTask,
this.pendingFiling,
this.foreign,
this.foreignUnlimited,
Expand Down Expand Up @@ -96,6 +97,14 @@ export default class AmalgamationMixin extends Vue {
return null
}

/** Disallow if a draft task exists. */
draftTask (business: AmalgamatingBusinessIF): AmlStatuses {
if (business.type === AmlTypes.LEAR && business.isDraftTask) {
return AmlStatuses.ERROR_DRAFT_TASK
}
return null
}

/** Disallow if a pending filing exists. */
pendingFiling (business: AmalgamatingBusinessIF): AmlStatuses {
if (business.type === AmlTypes.LEAR && business.isPendingFiling) {
Expand Down Expand Up @@ -192,21 +201,22 @@ export default class AmalgamationMixin extends Vue {
}

/**
* Get the business information, mailing address, email, and first filing if in LEAR.
* Otherwise, return error.
* Fetches the business' auth information, business info, addresses, first task, and first filing.
* @param identifier The business identifier.
*/
async fetchAmalgamatingBusinessInfo (item: any): Promise<any> {
// Get the auth info, business info, addresses and filings concurrently.
async fetchAmalgamatingBusinessInfo (identifier: string): Promise<any> {
// Make all API calls concurrently without rejection.
// NB - if any call failed, that item will be null.
const [ authInfo, businessInfo, addresses, firstFiling ] =
const [ authInfo, businessInfo, addresses, firstTask, firstFiling ] =
await Promise.allSettled([
AuthServices.fetchAuthInfo(item.identifier),
LegalServices.fetchBusinessInfo(item.identifier),
LegalServices.fetchAddresses(item.identifier),
LegalServices.fetchFirstOrOnlyFiling(item.identifier)
AuthServices.fetchAuthInfo(identifier),
LegalServices.fetchBusinessInfo(identifier),
LegalServices.fetchAddresses(identifier),
LegalServices.fetchFirstTask(identifier),
LegalServices.fetchFirstOrOnlyFiling(identifier)
]).then(results => results.map((result: any) => result.value || null))

return { authInfo, businessInfo, addresses, firstFiling }
return { authInfo, businessInfo, addresses, firstTask, firstFiling }
}
Copy link
Collaborator Author

@severinbeauvais severinbeauvais Jan 19, 2024

Choose a reason for hiding this comment

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

I thought it was better to pass in identifier instead of an untyped business object in which we "hope" there is an identifier. Identifier is the only thing we need from the business object in this function.


/**
Expand Down Expand Up @@ -241,6 +251,17 @@ export default class AmalgamationMixin extends Vue {
)
}

/**
* This business is draft task if the first task in the Todo List is still draft (or pending).
* @param business The business to check if is Draft Task or not.
*/
isDraftTask (business: any): boolean {
return (
business.firstTask?.header.status === FilingStatus.DRAFT ||
business.firstTask?.header.status === FilingStatus.PENDING
)
Copy link
Collaborator Author

@severinbeauvais severinbeauvais Jan 19, 2024

Choose a reason for hiding this comment

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

NB - Pending is if the filing was filed-and-paid but the payment failed. The user can retry or cancel the payment. If they cancel the payment then the filing goes back to Draft status.

}

/**
* This business is pending filing if the first filing in the ledger is still not complete or corrected
* (ie, it's paid or pending).
Expand All @@ -259,7 +280,7 @@ export default class AmalgamationMixin extends Vue {
*/
async refetchAmalgamatingBusinessesInfo (): Promise<void> {
const fetchTingInfo = async (item: any): Promise<AmalgamatingBusinessIF> => {
const tingBusiness = await this.fetchAmalgamatingBusinessInfo(item)
const tingBusiness = await this.fetchAmalgamatingBusinessInfo(item.identifier)
// no auth info and business info means foreign, otherwise LEAR (affiliated or non-affiliated)
if (!tingBusiness.authInfo && !tingBusiness.businessInfo) {
return {
Expand All @@ -281,6 +302,7 @@ export default class AmalgamationMixin extends Vue {
isNotInGoodStanding: (tingBusiness.businessInfo.goodStanding === false),
isFrozen: (tingBusiness.businessInfo.adminFreeze === true),
isFutureEffective: this.isFutureEffective(tingBusiness),
isDraftTask: this.isDraftTask(tingBusiness),
isPendingFiling: this.isPendingFiling(tingBusiness),
isLimitedRestoration: await this.isLimitedRestoration(tingBusiness),
isHistorical: (tingBusiness.businessInfo.state === EntityStates.HISTORICAL)
Expand Down
6 changes: 3 additions & 3 deletions src/mixins/filing-template-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
@Action(useStore) setBusinessContact!: (x: ContactPointIF) => void
@Action(useStore) setCertifyState!: (x: CertifyIF) => void
@Action(useStore) setCooperativeType!: (x: CoopTypes) => void
@Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void
// @Action(useStore) setCorrectNameOption!: (x: CorrectNameOptions) => void
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VS Code was giving me a warning that this action is already imported (via another mixin). Instead of deleting the declaration here, I just commented it out. This should help a curious developer understand why this declaration is not needed.

@Action(useStore) setCourtOrderFileNumber!: (x: string) => void
@Action(useStore) setCustodianOfRecords!: (x: OrgPersonIF) => void
@Action(useStore) setDissolutionDate!: (x: string) => void
Expand All @@ -94,8 +94,8 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
@Action(useStore) setFoundingDate!: (x: string) => void
@Action(useStore) setLegalName!: (x: string) => void
@Action(useStore) setMemorandum!: (x: CreateMemorandumIF) => void
@Action(useStore) setNameRequestApprovedName!: (x: string) => void
@Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void
// @Action(useStore) setNameRequestApprovedName!: (x: string) => void
// @Action(useStore) setNameTranslations!: (x: NameTranslationIF[]) => void
@Action(useStore) setOfficeAddresses!: (x: RegisteredRecordsAddressesIF) => void
@Action(useStore) setOrgPersonList!: (x: OrgPersonIF[]) => void
@Action(useStore) setRegistrationBusinessAddress!: (x: BusinessAddressIF) => void
Expand Down
13 changes: 5 additions & 8 deletions src/services/legal-services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AxiosInstance as axios } from '@/utils'
import { StatusCodes } from 'http-status-codes'
import { AmalgamationFilingIF, BusinessIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF,
RegistrationFilingIF, RestorationFilingIF } from '@/interfaces'
import { BusinessIF, DissolutionFilingIF, IncorporationFilingIF, NameRequestIF } from '@/interfaces'
import { FilingTypes } from '@/enums'

/**
Expand Down Expand Up @@ -29,12 +28,11 @@ export default class LegalServices {

/**
* Fetches the first or only filing.
* This is expected to be a draft IA or Registration.
* This is probably a draft Amalgamation, IA or Registration.
* @param tempId the temp registration number
* @returns a promise to return the draft filing, else exception
*/
// eslint-disable-next-line max-len
static async fetchFirstOrOnlyFiling (tempId: string): Promise<AmalgamationFilingIF | IncorporationFilingIF | RegistrationFilingIF> {
static async fetchFirstOrOnlyFiling (tempId: string): Promise<any> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When this function is used by amalgamation code, the type of filing could actually be any of our filings in the ledger.

Ditto for tasks below.

const url = `businesses/${tempId}/filings`

return axios.get(url)
Expand Down Expand Up @@ -65,12 +63,11 @@ export default class LegalServices {

/**
* Fetches the first task.
* This is expected to be a draft Dissolution or Restoration.
* This is probably a draft Dissolution or Restoration.
* @param businessId the business identifier
* @returns a promise to return the draft filing, else exception
*/
// eslint-disable-next-line max-len
static async fetchFirstTask (businessId: string): Promise<DissolutionFilingIF | RestorationFilingIF> {
static async fetchFirstTask (businessId: string): Promise<any> {
const url = `businesses/${businessId}/tasks`
return axios.get(url)
.then(response => {
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/BusinessStatus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ describe('Business Status', () => {
tooltip: 'A BC community contribution company must amalgamate to form a new BC community'
},
{
label: 'Error FROZEN',
label: 'Error Draft Task',
status: AmlStatuses.ERROR_DRAFT_TASK,
tooltip: 'This business has a draft task. It cannot be part of an amalgamation.'
},
{
label: 'Error Frozen',
status: AmlStatuses.ERROR_FROZEN,
tooltip: 'This business is frozen. Frozen businesses cannot be part of an amalgamation.'
},
Expand Down Expand Up @@ -87,7 +92,7 @@ describe('Business Status', () => {
]

it('has the expected number of tests', () => {
expect(tests.length).toBe(1 + 15) // OK + 14 errors
expect(tests.length).toBe(1 + 16) // OK + 16 errors
})

for (const test of tests) {
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe.skip('Business Table - rule evaluation', () => {
{ methodName: 'notInGoodStanding', error: AmlStatuses.ERROR_NOT_IN_GOOD_STANDING },
{ methodName: 'limitedRestoration', error: AmlStatuses.ERROR_LIMITED_RESTORATION },
{ methodName: 'futureEffectiveFiling', error: AmlStatuses.ERROR_FUTURE_EFFECTIVE_FILING },
{ methodName: 'draftTask', error: AmlStatuses.ERROR_DRAFT_TASK },
{ methodName: 'pendingFiling', error: AmlStatuses.ERROR_PENDING_FILING },
{ methodName: 'foreign', error: AmlStatuses.ERROR_FOREIGN },
{ methodName: 'foreignUnlimited', error: AmlStatuses.ERROR_FOREIGN_UNLIMITED },
Expand Down Expand Up @@ -222,8 +223,8 @@ describe.skip('Business Table - rule evaluation', () => {
})

it('has the expected number of rules', () => {
expect(rules.length).toBe(15)
expect(wrapper.vm.rules.length).toBe(15)
expect(rules.length).toBe(16)
expect(wrapper.vm.rules.length).toBe(16)
})

// check each rule sequentially
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/amalgamation-mixin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Amalgamation Mixin - rules', () => {
})

it('has the expected number of rules', () => {
expect(wrapper.vm.rules.length).toBe(15)
expect(wrapper.vm.rules.length).toBe(16)
})

it('correctly evaluates "notAffiliated" rule', () => {
Expand Down Expand Up @@ -114,6 +114,17 @@ describe('Amalgamation Mixin - rules', () => {
expect(wrapper.vm.futureEffectiveFiling({ type: AmlTypes.LEAR, isFutureEffective: false })).toBeNull()
})

it('correctly evaluates "draftTask" rule', () => {
// verify rule
expect(wrapper.vm.draftTask({ type: AmlTypes.LEAR, isDraftTask: true })).toBe(AmlStatuses.ERROR_DRAFT_TASK)

// verify not LEAR only
expect(wrapper.vm.draftTask({ type: AmlTypes.FOREIGN, isDraftTask: true })).toBeNull()

// verify not draft task only
expect(wrapper.vm.draftTask({ type: AmlTypes.LEAR, isDraftTask: false })).toBeNull()
})

it('correctly evaluates "pendingFiling" rule', () => {
// verify rule
expect(wrapper.vm.pendingFiling({ type: AmlTypes.LEAR, isPendingFiling: true })).toBe(AmlStatuses.ERROR_PENDING_FILING)
Expand Down
Loading