diff --git a/frontend/src/views/supp-allowances/SupplementaryFormView.vue b/frontend/src/views/supp-allowances/SupplementaryFormView.vue index 08ddc827..b36598fe 100644 --- a/frontend/src/views/supp-allowances/SupplementaryFormView.vue +++ b/frontend/src/views/supp-allowances/SupplementaryFormView.vue @@ -495,11 +495,15 @@ export default { setSuppTermDates() { const today = new Date() const formattedEndDate = new Date(this.fundingAgreement.endDate) - const termTwoEndDate = new Date(formattedEndDate.setFullYear(formattedEndDate.getFullYear() - 1)) - const termOneEndDate = new Date(termTwoEndDate.setFullYear(termTwoEndDate.getFullYear() - 1)) + + const termTwoEndDate = new Date(new Date(this.fundingAgreement.endDate).setFullYear(new Date(this.fundingAgreement.endDate).getFullYear() - 1)) + const termOneEndDate = new Date(new Date(termTwoEndDate).setFullYear(new Date(termTwoEndDate).getFullYear() - 1)) switch (true) { - case today < termOneEndDate: + //not having a funding agreement or FA end date will only happen if a user navigates to SuppApp right after + //OFM core creation. They moved too quickly and the FA did not have time to generate in Dynamics before returning. + //In this case, we can safely assume they are in term 1. Upon refresh, the FA will exist. + case today < termOneEndDate || !this.fundingAgreement?.endDate: this.fundingExpiryDate = termOneEndDate this.renewalTerm = SUPP_TERM_CODES.TERM_ONE this.nextRenewalTerm = SUPP_TERM_CODES.TERM_TWO