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 13 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
37 changes: 31 additions & 6 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 @@ -250,6 +253,7 @@ export default {
currentTermDisabled: false,
nextTermActive: false,
fundingExpiryDate: undefined,
isFundingTermComplete: false,
}
},
computed: {
Expand Down Expand Up @@ -550,8 +554,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()
const TWO_YEARS = 730
weskubo-cgi marked this conversation as resolved.
Show resolved Hide resolved

let termTwoEndDate
let termOneEndDate
//ofmcc-6357- allow supp terms to work with both a FA term of 2 and 3 years in length
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 +586,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,6 +603,8 @@ 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()
Expand All @@ -593,6 +614,10 @@ export default {
const priorDate = moment(termEndDate).subtract(this.DAYS_BEFORE_NEXT_TERM_ENABLED, 'days').toDate()
this.isNextTermEnabled = today > priorDate
},
setIsNearTermEndDate(formattedEndDate, today) {
const priorDate = moment(formattedEndDate).subtract(this.DAYS_BEFORE_TERM_EXPIRES, 'days').toDate()
this.isFundingTermComplete = today > priorDate || today > formattedEndDate
},
setActiveTerm(value) {
this.nextTermActive = value
},
Expand Down
Loading