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

Ofmcc 6357 2 year supp term #392

Merged
merged 15 commits into from
Oct 25, 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
22 changes: 11 additions & 11 deletions frontend/src/views/supp-allowances/SupplementaryAllowanceView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@
<span class="application-number">{{ application?.referenceNumber }}</span>
<router-view
:key="application?.applicationId"
:applicationId="application?.applicationId"
:fundingAgreement="application?.fundingAgreement"
:application-id="application?.applicationId"
:funding-agreement="application?.fundingAgreement"
:cancel="cancel"
:back="back"
:next="next"
:save="save"
:submit="submit"
@process="process"
@setSubmit="setSubmit"
@setNext="setNext" />
@set-submit="setSubmit"
@set-next="setNext" />
</div>
</div>
<AppNavButtons
:loading="processing"
:showBack="showBack"
:showCancel="showCancel"
:showSave="showSave"
:showNext="showNext"
:showSubmit="showSubmit"
:disableSubmit="disableSubmit"
:disableNext="disableNext"
:show-back="showBack"
:show-cancel="showCancel"
:show-save="showSave"
:show-next="showNext"
:show-submit="showSubmit"
:disable-submit="disableSubmit"
:disable-next="disableNext"
@back="toggleBack"
@cancel="toggleCancel"
@save="toggleSave"
Expand Down
49 changes: 38 additions & 11 deletions frontend/src/views/supp-allowances/SupplementaryFormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
at any time.
</p>

<AppAlertBanner v-if="currentTermDisabled" type="warning">Your current year funding is ending and you are no longer able to make changes. Please apply for Next Year</AppAlertBanner>
<AppAlertBanner v-if="isFundingTermComplete" type="warning">Your current year funding is ending and you are no longer able to make changes.</AppAlertBanner>
<AppAlertBanner v-else-if="currentTermDisabled" type="warning">Your current year funding is ending and you are no longer able to make changes. Please apply for Next Year</AppAlertBanner>

<v-form ref="form">
<v-row no-gutters class="mb-2">
Expand All @@ -24,7 +25,9 @@
<AppButton id="current-year-button" class="mr-1" :active="!nextTermActive" :primary="false" size="large" width="200px" @click="setActiveTerm(false)">Current Year</AppButton>
</v-col>
<v-col cols="6" lg="2">
<AppButton id="next-year-button" :active="nextTermActive" :primary="false" :disabled="!isNextTermEnabled" size="large" width="200px" @click="setActiveTerm(true)">Next Year</AppButton>
<AppButton v-if="!isFundingTermComplete" id="next-year-button" :active="nextTermActive" :primary="false" :disabled="!isNextTermEnabled" size="large" width="200px" @click="setActiveTerm(true)">
Next Year
</AppButton>
</v-col>
</v-row>
<v-row v-if="fundingExpiryDate">
Expand Down Expand Up @@ -198,6 +201,10 @@ import { SUPP_TERM_CODES, CORE_SERVICES_PANELS, DISCRETIONARY_PANEL } from '@/ut
import format from '@/utils/format'
import moment from 'moment'

const DAYS_BEFORE_TERM_EXPIRES = 45
const DAYS_BEFORE_NEXT_TERM_ENABLED = 120
const TWO_YEARS = 730

export default {
name: 'SupplementaryFormView',
components: { AppAlertBanner, AppButton, AppDialog, AppLabel, IndigenousProgrammingAllowance, SupportNeedsProgrammingAllowance, TransportationAllowance },
Expand Down Expand Up @@ -250,6 +257,7 @@ export default {
currentTermDisabled: false,
nextTermActive: false,
fundingExpiryDate: undefined,
isFundingTermComplete: false,
}
},
computed: {
Expand Down Expand Up @@ -310,12 +318,10 @@ export default {
this.INDIGENOUS = 'indigenous'
this.CORE_SERVICES_PANELS = CORE_SERVICES_PANELS
this.DISCRETIONARY_PANEL = DISCRETIONARY_PANEL

this.panel = this.allPanelIDs
this.SUPPLEMENTARY_TYPES = SUPPLEMENTARY_TYPES
this.NOT_IN_GOOD_STANDING_WARNING_MESSAGE = NOT_IN_GOOD_STANDING_WARNING_MESSAGE
this.DAYS_BEFORE_TERM_EXPIRES = 45
this.DAYS_BEFORE_NEXT_TERM_ENABLED = 120

this.setSuppTermDates()
await this.loadData()
},
Expand Down Expand Up @@ -550,8 +556,20 @@ export default {
setSuppTermDates() {
const today = new Date()
const formattedEndDate = new Date(this.fundingAgreement.endDate)
const termTwoEndDate = moment(formattedEndDate).subtract(1, 'years').toDate()
const termOneEndDate = moment(formattedEndDate).subtract(2, 'years').toDate()
const formattedStartDate = new Date(this.fundingAgreement.startDate)
const daysOfTerm = moment.duration(moment(formattedEndDate).diff(moment(formattedStartDate))).asDays()
let termTwoEndDate
let termOneEndDate

//ofmcc-6357- allow supp terms to work with both a FA term of 2 and 3 years in length
//this will account for leap years as a standard non leap year term would be 729 days.
if (daysOfTerm > TWO_YEARS) {
termTwoEndDate = moment(formattedEndDate).subtract(1, 'years').toDate()
termOneEndDate = moment(formattedEndDate).subtract(2, 'years').toDate()
} else {
termTwoEndDate = formattedEndDate
termOneEndDate = moment(formattedEndDate).subtract(1, 'years').toDate()
}

switch (true) {
//not having a funding agreement or FA end date will only happen if a user navigates to SuppApp right after
Expand All @@ -570,10 +588,13 @@ export default {
this.renewalTerm = SUPP_TERM_CODES.TERM_TWO
this.nextRenewalTerm = SUPP_TERM_CODES.TERM_THREE
this.setIsCurrentTermDisabled(termTwoEndDate, today)
this.setIsNextTermEnabled(termTwoEndDate, today)
if (daysOfTerm > TWO_YEARS) {
this.setIsNextTermEnabled(termTwoEndDate, today)
}

break

case today < formattedEndDate:
case today < formattedEndDate && daysOfTerm > TWO_YEARS:
this.fundingExpiryDate = formattedEndDate
this.renewalTerm = SUPP_TERM_CODES.TERM_THREE
this.setIsCurrentTermDisabled(formattedEndDate, today)
Expand All @@ -584,15 +605,21 @@ export default {
this.renewalTerm = SUPP_TERM_CODES.TERM_THREE
this.currentTermDisabled = true
}

this.setIsNearTermEndDate(formattedEndDate, today)
},
setIsCurrentTermDisabled(termEndDate, today) {
const priorDate = moment(termEndDate).subtract(this.DAYS_BEFORE_TERM_EXPIRES, 'days').toDate()
const priorDate = moment(termEndDate).subtract(DAYS_BEFORE_TERM_EXPIRES, 'days').toDate()
this.currentTermDisabled = today > priorDate
},
setIsNextTermEnabled(termEndDate, today) {
const priorDate = moment(termEndDate).subtract(this.DAYS_BEFORE_NEXT_TERM_ENABLED, 'days').toDate()
const priorDate = moment(termEndDate).subtract(DAYS_BEFORE_NEXT_TERM_ENABLED, 'days').toDate()
this.isNextTermEnabled = today > priorDate
},
setIsNearTermEndDate(formattedEndDate, today) {
const priorDate = moment(formattedEndDate).subtract(DAYS_BEFORE_TERM_EXPIRES, 'days').toDate()
this.isFundingTermComplete = today > priorDate || today > formattedEndDate
},
setActiveTerm(value) {
this.nextTermActive = value
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ import rules from '@/utils/rules'
export default {
components: { AppDialog, AppButton, IndigenousProgrammingSummary, SupportNeedsSummary, TransportationSummary },
mixins: [alertMixin, permissionsMixin],
inheritAttrs: false,
props: {
back: {
type: Boolean,
Expand Down
Loading