Skip to content

Commit

Permalink
18273 Extension Request Scenario 2 (bcgov#580)
Browse files Browse the repository at this point in the history
* Extension Request Scenario 2

* Fix lint issue

* Fix min expiry date

* Restore comment on isFirstAgm

* Move currentDate to data object

* Fix agm year not clearing on firstAgm change

* Update watcher comment

* Update version to 7.0.10 and fix unit tests
  • Loading branch information
leodube-aot authored and JazzarKarim committed Feb 22, 2024
1 parent 506f687 commit 3d02ff5
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 48 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.9",
"version": "7.0.10",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
165 changes: 120 additions & 45 deletions src/components/AgmExtension/ExtensionRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
import { Component, Emit, Prop, Vue, Watch } from 'vue-property-decorator'
import { VcardTemplate } from '@/components/common'
import { AgmExtEvalIF } from '@/interfaces'
import { useRootStore } from '@/stores'
import { DatePicker } from '@bcrs-shared-components/date-picker'
import AgmYear from '@/components/AgmLocationChange/AgmYear.vue'
import { DateUtilities } from '@/services'
Expand Down Expand Up @@ -526,7 +525,7 @@ export default class ExtensionRequest extends Vue {
return DateUtilities.addMonthsToDate(30, DateUtilities.dateToYyyyMmDd(this.data.incorporationDate))
} else {
// For subsequent AGMs, max shouldn't be later than reference date + 15 months + 12 months
return 'placeholder for future work'
return DateUtilities.addMonthsToDate(27, this.data.prevAgmDate)
}
}
Expand All @@ -536,28 +535,29 @@ export default class ExtensionRequest extends Vue {
return DateUtilities.addMonthsToDate(19, DateUtilities.dateToYyyyMmDd(this.data.incorporationDate))
} else {
// For subsequent AGMs, min shouldn't be later than reference date + 15 months + 1 month
return 'placeholder for future work'
return DateUtilities.addMonthsToDate(16, this.data.prevAgmDate)
}
}
/**
* Whether to disable the editing of AGM Year field.
* Editable (false) when Is this first AGM is set to No.
* Non-Editable (true) when we first load (null) or Is first AGM is Yes.
* Set the agmYear as incorporation date if not null and true.
*/
/** Whether to disable the editing of AGM Year field. */
get isFirstAgm (): boolean {
if (this.data.isFirstAgm !== null) {
if (this.data.isFirstAgm) {
this.data.agmYear = this.data.incorporationDate.getFullYear().toString()
return true
} else {
this.data.agmYear = ''
return false
}
} else {
// Field disabled on first load when value is null
if (this.data.isFirstAgm == null) {
return true
}
// Field disabled when it is first agm
return this.data.isFirstAgm
}
/** Called when isFirstAgm radio group changes. */
@Watch('data.isFirstAgm')
onIsFirstAgmChanged (val: boolean): void {
if (val) {
this.data.agmYear = this.data.incorporationDate.getFullYear().toString()
} else {
this.data.agmYear = ''
}
}
/** Called when extension date picker changes. */
Expand All @@ -566,61 +566,136 @@ export default class ExtensionRequest extends Vue {
this.data.prevExpiryDate = val
}
@Watch('intendedAgmDateText')
/** Called when intended AGM date picker changes. */
@Watch('intendedAgmDateText')
onAgmIntendedDatePickerChanged (val: string): void {
this.data.intendedAgmDate = val
}
@Watch('previousAgmDateText')
/** Called when previous AGM date picker changes. */
@Watch('previousAgmDateText')
onPreviousAgmDatePickerChanged (val: string): void {
this.data.prevAgmDate = val
}
@Watch('data.currentDate')
@Watch('data.isPrevExtension')
@Watch('previousAgmDateText')
@Watch('extensionExpiryDateText')
onIsPrevExtensionChanged (): void {
/* eslint-disable brace-style */
const currentDate = DateUtilities.yyyyMmDdToDate(this.data.currentDate)
this.data.isEligible = null
if (!this.data.isPrevExtension && this.isFirstAgm) { // This is the first extension request for this AGM
// cutOffDate is the date where eligibility will be false if passed in a particular rule.
// IF First AGM and has an extension been request for this AGM year already is false
this.data.extensionDuration = null
// IF first AGM extension
// AND NOT extension requested this year
if (
this.isFirstAgm &&
!this.data.isPrevExtension &&
this.data.incorporationDate
) {
// cutOffDate: the date where eligibility will be false if passed in a particular rule.
const cutOffYyyyMmDd = DateUtilities.addMonthsToDate(
18, DateUtilities.dateToYyyyMmDd(this.data.incorporationDate))
const cutOffDate = DateUtilities.yyyyMmDdToDate(cutOffYyyyMmDd)
const currentDate = DateUtilities.yyyyMmDdToDate(this.getCurrentDate)
// IF CurrentDate > (IncorporationDate + 18 Months + 5 days) --> INELIGIBLE
// ELSE --> ELIGIBLE --> Extension Duration = 6 months
// IF CurrentDate > (IncorporationDate + 18 Months + 5 days)
// THEN NOT ELIGIBLE
if ((DateUtilities.daysBetweenTwoDates(cutOffDate, currentDate) - 5) > 0) {
this.data.isEligible = false
} else {
}
// ELSE ELIGIBLE, ExtensionDuration = 6 months
else {
this.data.isEligible = true
this.data.extensionDuration = 6
}
} else if (this.data.isPrevExtension && this.isFirstAgm && this.extensionExpiryDateText) {
// Yes - Specify the date the extension expires
// IF First AGM and has an extension been request for this AGM year already is true
}
// ELSE IF first AGM extension
// AND extension requested this year
else if (
this.isFirstAgm &&
this.data.isPrevExtension &&
this.extensionExpiryDateText &&
this.data.incorporationDate
) {
const cutOffYyyyMmDd = DateUtilities.addMonthsToDate(
30, DateUtilities.dateToYyyyMmDd(this.data.incorporationDate))
const cutOffDate = DateUtilities.yyyyMmDdToDate(cutOffYyyyMmDd)
const expiryDate = DateUtilities.yyyyMmDdToDate(this.extensionExpiryDateText)
// IF ExpirationDate >= (IncorporationDate + 18 months + 12 months) --> INELIGIBLE
// ELSE --> Check ELSE BLOCK
// IF ExpirationDate >= (IncorporationDate + 18 months + 12 months)
// THEN NOT ELIGIBLE
if ((DateUtilities.daysBetweenTwoDates(cutOffDate, expiryDate)) >= 0) {
this.data.isEligible = false
} else {
// IF CurrentDate > (ExpirationDate + 5 days) --> INELIGIBLE
// ELSE --> ELIGIBLE --> ExtensionDuration = MIN(6, 12 - totalExtensionApproved)
// totalExtensionApproved = (ExpirationDate - 18 months - IncorporationDate) in months
const currentDate = DateUtilities.yyyyMmDdToDate(this.getCurrentDate)
if ((DateUtilities.daysBetweenTwoDates(expiryDate, currentDate)) > 5) {
this.data.isEligible = false
} else {
this.data.isEligible = true
const totalExtensionApproved = DateUtilities.subtractDates(
DateUtilities.dateToYyyyMmDd(this.data.incorporationDate), this.extensionExpiryDateText) - 18
this.data.extensionDuration = Math.min(6, (12 - totalExtensionApproved))
}
}
// ELSE IF CurrentDate > (ExpirationDate + 5 days)
// THEN NOT ELIGIBLE
else if ((DateUtilities.daysBetweenTwoDates(expiryDate, currentDate)) > 5) {
this.data.isEligible = false
}
// ELSE ELIGIBLE, ExtensionDuration = MIN(6, 12 - totalExtensionApproved)
else {
this.data.isEligible = true
// totalExtensionApproved: (ExpirationDate - 18 months - IncorporationDate) in months
const totalExtensionApproved = DateUtilities.subtractDates(
DateUtilities.dateToYyyyMmDd(this.data.incorporationDate), this.extensionExpiryDateText) - 18
this.data.extensionDuration = Math.min(6, (12 - totalExtensionApproved))
}
}
// ELSE IF NOT first agm extension
// AND NOT extension requested this year
else if (
!this.isFirstAgm &&
!this.data.isPrevExtension &&
this.previousAgmDateText
) {
const cutOffYyyyMmDd = DateUtilities.addMonthsToDate(
15, this.previousAgmDateText)
const cutOffDate = DateUtilities.yyyyMmDdToDate(cutOffYyyyMmDd)
// IF CurrentDate > (PrevAgmDate + 15 Months + 5 days)
// THEN NOT ELIGIBLE
if ((DateUtilities.daysBetweenTwoDates(cutOffDate, currentDate) - 5) > 0) {
this.data.isEligible = false
}
// ELSE ELIGIBLE, ExtensionDuration = 6 months
else {
this.data.isEligible = true
this.data.extensionDuration = 6
}
}
// ELSE IF NOT first agm extension
// AND extension requested this year
else if (
!this.isFirstAgm &&
this.data.isPrevExtension &&
this.previousAgmDateText &&
this.extensionExpiryDateText
) {
const cutOffDate = DateUtilities.yyyyMmDdToDate(this.previousAgmDateText)
const expiryDate = DateUtilities.yyyyMmDdToDate(this.extensionExpiryDateText)
// IF CurrentDate > (ExpirationDate + 5 days)
// THEN NOT ELIGIBLE
if ((DateUtilities.daysBetweenTwoDates(expiryDate, currentDate)) > 5) {
this.data.isEligible = false
}
// ELSE IF (ExpirationDate - PrevAgmDate) > 12 months
// THEN NOT ELIGIBLE
else if ((DateUtilities.daysBetweenTwoDates(cutOffDate, expiryDate)) > 365) {
this.data.isEligible = false
}
// ELSE ELIGIBLE, ExtensionDuration = 12 months - ExpiryDate - PrevAgmDate
else {
this.data.isEligible = true
this.data.extensionDuration = 12 - DateUtilities.subtractDates(
this.previousAgmDateText,
this.extensionExpiryDateText
)
}
}
}
Expand Down

0 comments on commit 3d02ff5

Please sign in to comment.