Skip to content

Commit

Permalink
18833 agm ext calc (#599)
Browse files Browse the repository at this point in the history
* 18833-AGM-extension-calculation

* Updated package.json

* Added getter that takes argument for AGM year. Working test case for getTotalAgmExtension method
  • Loading branch information
jamespaologarcia committed Dec 15, 2023
1 parent 73cb7b0 commit f607203
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 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.25",
"version": "7.0.26",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
25 changes: 25 additions & 0 deletions src/stores/filingHistoryListStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ export const useFilingHistoryListStore = defineStore('filingHistoryList', {
})
},

/** Returns the total AGM extension duration requires argument for year */
getTotalAgmExtensionDuration (state: FilingHistoryListStateIF): (year: number) => number {
return (year: number) => {
return state.filings.reduce((totalMonths, filing) => {
// Skip if not AGM_EXTENSION
if (filing.name !== FilingTypes.AGM_EXTENSION) {
return totalMonths
}
const filingExtension = filing.data?.agmExtension
// Cast year as number
// Skip if extension data is missing
if (!filingExtension) {
return totalMonths
}
// Skip if years don't match
if (Number(filingExtension.year) !== year) {
return totalMonths
}
// Add total months for the specific AGM year
totalMonths += filingExtension.extensionDuration || 0
return totalMonths
}, 0)
}
},

/** The count of filings in the Filing History List. */
getHistoryCount (): number {
const filings = this.getFilings as ApiFilingIF[]
Expand Down
6 changes: 3 additions & 3 deletions src/views/AgmExtension.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ import { CommonMixin, DateMixin, EnumMixin, FilingMixin, ResourceLookupMixin } f
import { LegalServices } from '@/services/'
import { FilingCodes, FilingTypes, Routes, SaveErrorReasons } from '@/enums'
import { AgmExtEvalIF, ConfirmDialogType, EmptyAgmExtEval } from '@/interfaces'
import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
import { useBusinessStore, useConfigurationStore, useFilingHistoryListStore, useRootStore } from '@/stores'
@Component({
components: {
Expand Down Expand Up @@ -206,7 +206,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin,
@Getter(useRootStore) getUserInfo!: any
@Getter(useBusinessStore) isGoodStanding!: boolean
@Getter(useRootStore) isRoleStaff!: boolean
@Getter(useFilingHistoryListStore) getTotalAgmExtensionDuration!: (year: number) => number;
// enum for template
readonly FilingCodes = FilingCodes
Expand Down Expand Up @@ -430,7 +430,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin,
isFirstAgm: this.data.isFirstAgm,
extReqForAgmYear: this.data.isPrevExtension,
intendedAgmDate: this.data.intendedAgmDate,
totalApprovedExt: this.data.extensionDuration,
totalApprovedExt: this.getTotalAgmExtensionDuration(Number(this.data.agmYear)) + this.data.extensionDuration,
expireDateApprovedExt: this.data.agmDueDate,
// conditionally add properties if not null
...(this.data.prevAgmDate && { prevAgmRefDate: this.data.prevAgmDate }),
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/AgmExtension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Vue from 'vue'
import Vuetify from 'vuetify'
import { createLocalVue, mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import { useBusinessStore, useRootStore } from '@/stores'
import { useBusinessStore, useFilingHistoryListStore, useRootStore } from '@/stores'
import VueRouter from 'vue-router'
import mockRouter from './mockRouter'
import { CorpTypeCd } from '@/enums'
import { CorpTypeCd, FilingTypes } from '@/enums'
import { LegalServices } from '@/services'

// components
Expand All @@ -30,6 +30,7 @@ const vuetify = new Vuetify({})
setActivePinia(createPinia())
const businessStore = useBusinessStore()
const rootStore = useRootStore()
const filingHistoryListStore = useFilingHistoryListStore()

describe('AGM Extension view', () => {
let wrapper: any
Expand Down Expand Up @@ -155,6 +156,17 @@ describe('AGM Extension view', () => {
expect(wrapper.findComponent(NotEligibleExtensionDialog).attributes('dialog')).toBe('true')
})

it('returns total months in agm within the same year extension', async () => {
const filingHistoryList = [
{ name: FilingTypes.AGM_EXTENSION, data: { agmExtension: { extensionDuration: 2, year: 2023 } } },
{ name: FilingTypes.AGM_EXTENSION, data: { agmExtension: { extensionDuration: 4, year: 2023 } } },
{ name: FilingTypes.AGM_EXTENSION, data: { agmExtension: { extensionDuration: 4, year: 2024 } } }
]
filingHistoryListStore.setFilings(filingHistoryList as any)
const totalAgmExtension = filingHistoryListStore.getTotalAgmExtensionDuration(2023)
expect(totalAgmExtension).toBe(6)
})

it('files JSON data properly when eligible', async () => {
// verify initial route name
expect(wrapper.vm.$route.name).toBe('agm-extension')
Expand Down

0 comments on commit f607203

Please sign in to comment.