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

Fix/update unit note expired status #1634

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions ppr-ui/src/components/tables/common/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,9 @@ export default defineComponent({
}
if (days === -99) {
return 'Infinite'
}
if (days < 0) {
return 'Expired'
} else {
if (days > 364) {
const today = new Date()
Expand Down
10 changes: 8 additions & 2 deletions ppr-ui/src/components/unitNotes/UnitNoteHeaderInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MhUIStatusTypes, UnitNoteDocTypes, UnitNoteStatusTypes } from '@/enums'
import { UnitNotesInfo, cancelledWithRedemptionNote } from '@/resources'
import { UnitNoteIF } from '@/interfaces/unit-note-interfaces/unit-note-interface'
import { pacificDate } from '@/utils'
import { useMhrUnitNote } from '@/composables'

export default defineComponent({
name: 'UnitNoteHeaderInfo',
Expand All @@ -33,6 +34,10 @@ export default defineComponent({
}
},
setup (props) {
const {
isExpiryDatePassed
} = useMhrUnitNote()

const localState = reactive({
noteHeader: computed(() : string => {
let header =
Expand All @@ -41,7 +46,9 @@ export default defineComponent({
? UnitNotesInfo[props.note.documentType].panelHeader
: UnitNotesInfo[props.note.documentType].header

if (props.note.status === UnitNoteStatusTypes.CANCELLED &&
if (isExpiryDatePassed(props.note)) {
header += ` (Expired)`
} else if (props.note.status === UnitNoteStatusTypes.CANCELLED &&
props.note.documentType === UnitNoteDocTypes.NOTICE_OF_TAX_SALE) {
header += ` ${cancelledWithRedemptionNote}`
} else if (props.note.status === UnitNoteStatusTypes.CANCELLED) {
Expand All @@ -53,7 +60,6 @@ export default defineComponent({
} else if (props.note.documentType === UnitNoteDocTypes.EXTENSION_TO_NOTICE_OF_CAUTION) {
header += ` (Extended)`
}

return header
})
})
Expand Down
14 changes: 13 additions & 1 deletion ppr-ui/src/composables/mhrInformation/useMhrUnitNote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UnitNoteDocTypes, UnitNoteStatusTypes } from '@/enums/unitNoteDocTypes'
import { CancelUnitNoteIF, PartyIF, UnitNoteIF, UnitNotePanelIF, UnitNoteRegistrationIF } from '@/interfaces'
import { useStore } from '@/store/store'
import { deleteEmptyProperties, submitMhrUnitNote } from '@/utils'
import { deleteEmptyProperties, localTodayDate, submitMhrUnitNote } from '@/utils'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import { computed } from 'vue-demi'
Expand Down Expand Up @@ -114,6 +114,17 @@ export const useMhrUnitNote = () => {

const isCancelUnitNote = computed((): boolean => getMhrUnitNoteType.value === UnitNoteDocTypes.NOTE_CANCELLATION)

const isExpiryDatePassed = (note: UnitNoteIF): boolean => {
if (note.documentType === UnitNoteDocTypes.CONTINUED_NOTE_OF_CAUTION ||
dimak1 marked this conversation as resolved.
Show resolved Hide resolved
note.documentType === UnitNoteDocTypes.EXTENSION_TO_NOTICE_OF_CAUTION) {
if (note.expiryDateTime != null && note.expiryDateTime !== '') {
const expiryDate = note.expiryDateTime.substring(0, 10)
const today = localTodayDate()
return new Date(expiryDate) < new Date(today)
} else return false
} else return false
}

const isRedemptionUnitNote = computed(
(): boolean => getMhrUnitNoteType.value === UnitNoteDocTypes.NOTICE_OF_REDEMPTION
)
Expand Down Expand Up @@ -254,6 +265,7 @@ export const useMhrUnitNote = () => {
prefillUnitNote,
isCancelUnitNote,
isRedemptionUnitNote,
isExpiryDatePassed,
getCancelledUnitNoteHeader,
buildApiDataAndSubmit,
isPersonGivingNoticeOptional,
Expand Down
7 changes: 4 additions & 3 deletions ppr-ui/tests/unit/UnitNotePanels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ const verifyHeaderContent = (note: UnitNotePanelIF, header: Wrapper<any>) => {
const typeText = header.find('h3').text()

let statusText = ''
if (note.status === UnitNoteStatusTypes.CANCELLED) {
statusText = ' (Cancelled)'
} else if (note.status === UnitNoteStatusTypes.EXPIRED) {
if (note.status === UnitNoteStatusTypes.EXPIRED ||
useMhrUnitNote().isExpiryDatePassed(note)) {
statusText = ' (Expired)'
} else if (note.status === UnitNoteStatusTypes.CANCELLED) {
statusText = ' (Cancelled)'
}

const expectedTypeText = (UnitNotesInfo[note.documentType]?.panelHeader ??
Expand Down