Skip to content

Commit

Permalink
Handle Draft MHR Re-Registrations (#1914)
Browse files Browse the repository at this point in the history
* Handle Draft Mhr Re-Registrations
  • Loading branch information
dimak1 authored Jun 5, 2024
1 parent 6f1756e commit 41cb127
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 27 deletions.
3 changes: 2 additions & 1 deletion ppr-ui/src/components/common/ButtonFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default defineComponent({
isRoleStaffBcol,
isRoleStaffReg,
isRoleStaffSbc,
isMhrReRegistration,
getMhrInformation
} = storeToRefs(useStore())
const { mhrDraftHandler } = useNewMhrRegistration()
Expand Down Expand Up @@ -254,7 +255,7 @@ export default defineComponent({
const newItem: RegTableNewItemI = {
addedReg: draft.financingStatement?.documentId || draft.draftNumber,
// adding mhrNumber will scroll to draft mhr correction
addedRegParent: isMhrCorrection.value ? getMhrInformation.value.mhrNumber : '',
addedRegParent: (isMhrCorrection.value || isMhrReRegistration.value) ? getMhrInformation.value.mhrNumber : '',
addedRegSummary: null,
prevDraft: prevDraftId
}
Expand Down
20 changes: 18 additions & 2 deletions ppr-ui/src/components/common/RegistrationsWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default defineComponent({
const { goToExemptions } = useExemptions()
const { initMhrReRegistration } = useMhrReRegistration()
const { initMhrReRegistration, initDraftMhrReRegistration } = useMhrReRegistration()
const localState = reactive({
loading: false,
Expand Down Expand Up @@ -739,7 +739,7 @@ export default defineComponent({
openMhr(mhrInfo)
break
case TableActions.OPEN_DRAFT_CORRECTION:
if (mhrInfo.outOfDate) {
if (mhrInfo.outOfDate) {
// Handle stale drafts before opening the MHR when flagged as outOfDate
localState.staleDraftId = mhrInfo?.draftNumber
localState.mhrWithDraftId = mhrInfo?.mhrNumber
Expand All @@ -748,6 +748,16 @@ export default defineComponent({
}
openDraftMhrCorrection(mhrInfo)
break
case TableActions.OPEN_DRAFT_RE_REGISTRATION:
if (mhrInfo.outOfDate) {
// Handle stale drafts before opening the MHR when flagged as outOfDate
localState.staleDraftId = mhrInfo?.draftNumber
localState.mhrWithDraftId = mhrInfo?.mhrNumber
localState.staleDraftDialogDisplay = true
return
}
openDraftMhrReRegistration(mhrInfo)
break
case UnitNoteDocTypes.RESIDENTIAL_EXEMPTION_ORDER:
case UnitNoteDocTypes.NON_RESIDENTIAL_EXEMPTION:
openMhrExemption(mhrInfo, action)
Expand Down Expand Up @@ -807,6 +817,12 @@ export default defineComponent({
goToRoute(RouteNames.SUBMITTING_PARTY)
}
const openDraftMhrReRegistration = async (draftMhrCorrection) => {
await initDraftMhrReRegistration(draftMhrCorrection)
// Navigate to MHR Re-Registration home route
goToRoute(RouteNames.SUBMITTING_PARTY)
}
const openMhrExemption = async (mhrSummary: MhRegistrationSummaryIF, type: UnitNoteDocTypes): Promise<void> => {
await setMhrInformation(mhrSummary)
await goToExemptions(type)
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/components/tables/common/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ export default defineComponent({
switch (item.registrationType) {
case APIMhrTypes.REGISTRY_STAFF_ADMIN:
action = TableActions.OPEN_DRAFT_CORRECTION
action = item.registrationDescription === APIMhrDescriptionTypes.RE_REGISTER_NEW_UNIT
? TableActions.OPEN_DRAFT_RE_REGISTRATION : TableActions.OPEN_DRAFT_CORRECTION
break
case APIMhrTypes.MANUFACTURED_HOME_REGISTRATION:
action = item.draftNumber ? TableActions.EDIT_NEW_MHR : TableActions.OPEN_MHR
Expand Down
53 changes: 38 additions & 15 deletions ppr-ui/src/composables/mhrRegistration/useMhrReRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,34 @@ import { HomeCertificationOptions } from '@/enums'
import { MhRegistrationSummaryIF } from '@/interfaces'
import { MhrReRegistrationType } from '@/resources'
import { useStore } from '@/store/store'
import { fetchMhRegistration } from '@/utils'
import { fetchMhRegistration, getMhrDraft } from '@/utils'
import { useNewMhrRegistration } from './useNewMhrRegistration'
import { cloneDeep } from 'lodash'
import { useMhrInformation } from '../mhrInformation'

export const useMhrReRegistration = () => {
const {
setMhrBaseline,
setRegistrationType
} = useStore()
const { setMhrBaseline, setRegistrationType, setMhrDraftNumber } = useStore()

const { setMhrNumber, setMhrStatusType } = useStore()
const { parseMhrPermitData } = useMhrInformation()

const initMhrReRegistration = async (mhrSummary: MhRegistrationSummaryIF): Promise<void> => {
const initMhrReRegistration = async (mhrSummary: MhRegistrationSummaryIF): Promise<void> =>
initReRegistrationOrDraft(mhrSummary)

const initDraftMhrReRegistration = async (mhrSummary: MhRegistrationSummaryIF): Promise<void> =>
initReRegistrationOrDraft(mhrSummary, true)

/**
* Private function to init the MHR Re-Registration or Draft Re-Registration.
*
* @param {MhRegistrationSummaryIF} mhrSummary - The MHR summary information.
* @param {boolean} isDraft - A flag indicating whether the registration is a draft or not. Defaults to false.
*
*/
const initReRegistrationOrDraft = async (
mhrSummary: MhRegistrationSummaryIF,
isDraft: boolean = false
): Promise<void> => {
setMhrNumber(mhrSummary.mhrNumber)
setRegistrationType(MhrReRegistrationType)
setMhrStatusType(mhrSummary.statusType)
Expand All @@ -29,14 +42,20 @@ export const useMhrReRegistration = () => {
(data?.description?.engineerName && HomeCertificationOptions.ENGINEER_INSPECTION) ||
null

// remove props that should not be pre-populated into Re-Registration
data.documentId = ''
data.ownerGroups = []
if (!isDraft) {
// remove props that should not be pre-populated into Re-Registration
data.documentId = ''
data.ownerGroups = []
// parse Transport Permit data to correctly show Location of Home step
parseMhrPermitData(data)
} else {
const draftNumber = mhrSummary.draftNumber
const { registration } = await getMhrDraft(draftNumber)
setMhrDraftNumber(draftNumber)
setMhrStatusType(data?.status)
await useNewMhrRegistration().initDraftOrCurrentMhr(registration)
}

// parse Transport Permit data to correctly show Location of Home step
parseMhrPermitData(data)

// Preserve MHR snapshot
await setMhrBaseline(
cloneDeep({
...data,
Expand All @@ -47,10 +66,14 @@ export const useMhrReRegistration = () => {
}
})
)
await useNewMhrRegistration().initDraftOrCurrentMhr(data, false)

if (!isDraft) {
await useNewMhrRegistration().initDraftOrCurrentMhr(data, false)
}
}

return {
initMhrReRegistration
initMhrReRegistration,
initDraftMhrReRegistration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const useNewMhrRegistration = (isMhrCorrections: boolean = false) => {
// Getters
isRoleStaffReg,
isMhrManufacturerRegistration,
isMhrReRegistration,
getFolioOrReferenceNumber,
getMhrRegistrationHomeDescription,
getMhrRegistrationSubmittingParty,
Expand Down Expand Up @@ -358,7 +359,7 @@ export const useNewMhrRegistration = (isMhrCorrections: boolean = false) => {
}

// add additional props to payload for Mhr Corrections
if (isMhrCorrection.value) {
if (isMhrCorrection.value || isMhrReRegistration.value) {
data.documentType = getRegistrationType.value?.registrationTypeAPI
data.mhrNumber = getMhrInformation.value.mhrNumber
}
Expand All @@ -375,7 +376,7 @@ export const useNewMhrRegistration = (isMhrCorrections: boolean = false) => {

const mhrDraftHandler = async (): Promise<MhrDraftIF> => {

const draftType = isMhrCorrection.value
const draftType = (isMhrCorrection.value || isMhrReRegistration.value)
? APIMhrTypes.REGISTRY_STAFF_ADMIN
: APIMhrTypes.MANUFACTURED_HOME_REGISTRATION

Expand Down
7 changes: 4 additions & 3 deletions ppr-ui/src/enums/registrationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export enum UIRegistrationTypes {
SPECULATION_VACANCY_TAX = 'Crown Charge - Speculation and Vacancy Tax Act',
TOBACCO_TAX = 'Crown Charge - Tobacco Tax Act',
OTHER = 'Crown Charge - Other',
// miscellaneous registration other
// miscellaneous registration other
LIEN_UNPAID_WAGES = 'Lien for Unpaid Wages',
HERITAGE_CONSERVATION_NOTICE = 'Heritage Conservation Notice',
MANUFACTURED_HOME_NOTICE = 'Manufactured Home Notice',
Expand Down Expand Up @@ -127,7 +127,7 @@ export enum StatementTypes {
CHANGE_STATEMENT = 'CHANGE',
DISHCARGE_STATEMENT = 'DISCHARGE',
FINANCING_STATEMENT = 'FINANCING',
RENEWAL_STATEMENT = 'RENEWAL',
RENEWAL_STATEMENT = 'RENEWAL'
}

export enum APIAmendmentTypes {
Expand Down Expand Up @@ -189,6 +189,7 @@ export enum UIRegistrationClassTypes {

export enum APIMhrDescriptionTypes {
REGISTER_NEW_UNIT = 'MANUFACTURED HOME REGISTRATION',
RE_REGISTER_NEW_UNIT = 'MANUFACTURED HOME RE-REGISTRATION',
CONVERTED = 'RECORD CONVERSION',

SALE_OR_GIFT = 'TRANSFER DUE TO SALE OR GIFT',
Expand Down Expand Up @@ -257,7 +258,7 @@ export enum APIMhrTypes {
RESIDENTIAL_EXEMPTION = 'EXEMPTION_RES',
MANUFACTURED_HOME_REGISTRATION = 'MHREG',
TRANSPORT_PERMIT = 'PERMIT',
REGISTRY_STAFF_ADMIN = 'REG_STAFF_ADMIN',
REGISTRY_STAFF_ADMIN = 'REG_STAFF_ADMIN'
}

/**
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/enums/tableActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export enum TableActions {
REMOVE_TRANSFER_DRAFT = 'removeTransferDraft',
OPEN_MHR = 'openMhr',
EDIT_NEW_MHR = 'editMhr',
OPEN_DRAFT_CORRECTION = 'openDraftCorrection'
OPEN_DRAFT_CORRECTION = 'openDraftCorrection',
OPEN_DRAFT_RE_REGISTRATION = 'openDraftReRegistration'
}
10 changes: 8 additions & 2 deletions ppr-ui/src/views/newMhrRegistration/MhrRegistration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
class="pt-3 pb-6"
>
<v-col>
<h1>{{ getRegistrationType.registrationTypeUI }}</h1>
<h1>{{ getRegistrationType.registrationTypeUI }} {{ isDraft && ' - Draft' }} </h1>
<p class="pt-7">
The homeowner and home location information in the Initial Registration form must align
with the supporting documentation.
Expand Down Expand Up @@ -175,7 +175,8 @@ export default defineComponent({
setRegTableNewItem,
setMhrTransferType,
setDraft,
setMhrInformationDraftId
setMhrInformationDraftId,
setMhrCorrectStatusType
} = useStore()
const {
// Getters
Expand Down Expand Up @@ -321,6 +322,11 @@ export default defineComponent({
delete data.submittingParty.hasUsedPartyLookup
}
// Because Corrections flow is reused for Re-Registrations, the Mhr status needs to be set in corrections
if (isMhrReRegistration.value) {
setMhrCorrectStatusType(getMhrInformation.value.statusType)
}
const mhrSubmission = isMhrCorrection.value || isMhrReRegistration.value
? await submitAdminRegistration(
getMhrInformation.value.mhrNumber,
Expand Down

0 comments on commit 41cb127

Please sign in to comment.