Skip to content

Commit

Permalink
Transfer Bugs & Validation Updates (#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-eyds authored Apr 29, 2024
1 parent 1ac427f commit b08a96a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 29 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/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 ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.1.8",
"version": "3.1.9",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export default defineComponent({
groupId: (allFractionalData.length + 1),
type: 'N/A',
interest: 'Undivided',
interestNumerator: null,
interestNumerator: defaultLcm ? allFractionalData[0]?.interestNumerator : null,
interestDenominator: defaultLcm
} as FractionalOwnershipWithGroupIdIF)
}
Expand Down
11 changes: 5 additions & 6 deletions ppr-ui/src/components/mhrTransfers/HomeOwnersGroupError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
>
{{ transfersErrors.mustContainOneExecutorInGroup }}
</span>
<span
v-else-if="!TransToExec.hasAllCurrentOwnersRemoved(groupId) && TransToExec.hasAddedExecutorsInGroup(groupId)"
>
{{ transfersErrors.ownersMustBeDeceased }}
</span>
<span v-else-if="TransSaleOrGift.hasMixedOwnersInGroup(groupId)">
{{ hasOneHomeOwnerGroup ?
MixedRolesErrors.hasMixedOwnerTypes :
MixedRolesErrors.hasMixedOwnerTypesInGroup }}
</span>
<span
v-else-if="!TransToExec.hasAllCurrentOwnersRemoved(groupId) &&
TransToExec.hasAddedExecutorsInGroup(groupId)"
>
{{ transfersErrors.ownersMustBeDeceased }}
</span>
<span v-else-if="TransToExec.isAllGroupOwnersWithDeathCerts(groupId)">
{{ transfersErrors.allOwnersHaveDeathCerts[getMhrTransferType.transferType] }}
</span>
Expand Down
10 changes: 9 additions & 1 deletion ppr-ui/src/composables/exemption/useExemptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export const useExemptions = () => {
setMhrExemptionValidation({ key: validationFlag, value })
}

/**
* Formats a non-residential reason value to uppercase and replaces spaces with underscores.
* @param {string} value - The value to format.
* @returns {string} The formatted value.
* @example 'Storage Shed' -> 'STORAGE_SHED'
*/
const formatNonResReason = (value: string): string => value.toUpperCase().replace(/\s+/g, '_')

/** Construct the payload for Exemptions submission **/
const buildExemptionPayload = (): ExemptionIF => {
const party = getMhrExemption.value.submittingParty
Expand All @@ -99,7 +107,7 @@ export const useExemptions = () => {
note: {
...removeEmptyProperties(note),
destroyed: note.nonResidentialOption === NonResOptions.DESTROYED,
nonResidentialReason: note.nonResidentialReason?.toUpperCase()
nonResidentialReason: formatNonResReason(note.nonResidentialReason)
}
})
} as ExemptionIF
Expand Down
20 changes: 18 additions & 2 deletions ppr-ui/src/composables/mhrInformation/useTransferOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
// Group has at least one Executor
const hasAddedExecutor = group.owners.some((owner: MhrRegistrationHomeOwnerIF) =>
owner.action !== ActionTypes.REMOVED && owner.partyType === HomeOwnerPartyTypes.EXECUTOR)
return isValidAddedOwner && hasAddedExecutor

return isValidAddedOwner && hasAddedExecutor && TransToExec.hasAllCurrentOwnersRemoved(group.groupId)
},
hasOwnersWithValidSupportDocs: (groupId: number): boolean => {
return getMhrTransferHomeOwnerGroups.value
Expand Down Expand Up @@ -736,7 +737,8 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
group.owners.some(owner => owner.action === ActionTypes.REMOVED))

if (!groupWithDeletedOwners) return false
return TransToAdmin.hasAtLeastOneAdminInGroup(groupWithDeletedOwners.groupId)
return TransToAdmin.hasAtLeastOneAdminInGroup(groupWithDeletedOwners.groupId) &&
TransToAdmin.hasAllCurrentOwnersRemoved(groupWithDeletedOwners.groupId)
}),
hasAddedAdministratorsInGroup: (groupId): boolean =>
hasAddedPartyTypeToGroup(groupId, HomeOwnerPartyTypes.ADMINISTRATOR),
Expand All @@ -745,6 +747,20 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
.find(group => group.groupId === groupId).owners
.some(owner => owner.action !== ActionTypes.REMOVED &&
owner.partyType === HomeOwnerPartyTypes.ADMINISTRATOR)
},
hasAllCurrentOwnersRemoved: (groupId): boolean => {
const regOwners = getMhrTransferHomeOwnerGroups.value
.find(group => group.groupId === groupId).owners
// Filter as Execs, Admins and Trustees doest not have to be removed in order to have a valid group
.filter(owner => [HomeOwnerPartyTypes.OWNER_IND, HomeOwnerPartyTypes.OWNER_BUS]
.includes(owner.partyType))

if (regOwners?.length === 0) return true

return regOwners
.every(owner => isCurrentOwner(owner)
? owner.action === ActionTypes.REMOVED
: owner.action === ActionTypes.ADDED)
}
}

Expand Down
7 changes: 0 additions & 7 deletions ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,6 @@ export function useHomeOwners (isMhrTransfer: boolean = false, isMhrCorrection:
const i = findIndex(groupToUpdate.owners, { ownerId: updatedOwner.ownerId })
set(groupToUpdate, `owners[${i}]`, updatedOwner)

if (!groupToUpdate.interestNumerator && !groupToUpdate.interestDenominator &&
groupToUpdate.owners.every(owner => owner.action === ActionTypes.REMOVED &&
getMhrTransferType.value?.transferType !== ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL &&
getMhrTransferType.value?.transferType !== ApiTransferTypes.TO_ADMIN_NO_WILL)) {
set(groupToUpdate, 'action', ActionTypes.REMOVED)
}

setTransferOrRegistrationHomeOwnerGroups(homeOwnerGroups)
} else {
// need to move the owner to new group
Expand Down
17 changes: 8 additions & 9 deletions ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ describe('Home Owners', () => {
expect(allDeletedBadges.length).toBe(1)

expect(homeOwners.find(getTestId('invalid-group-msg')).exists()).toBeFalsy()
expect(homeOwners.find(getTestId('no-data-msg')).exists()).toBeTruthy()
expect(homeOwners.find(getTestId('no-data-msg')).text()).toContain('No owners added yet.')
expect(homeOwners.find(getTestId('no-data-msg')).exists()).toBeFalsy()

const deletedOwner: MhrRegistrationHomeOwnerIF =
homeOwners.vm.getMhrTransferHomeOwnerGroups[0].owners[0]
Expand Down Expand Up @@ -596,20 +595,20 @@ describe('Home Owners', () => {

expect(groupError.text()).toContain(MixedRolesErrors.hasMixedOwnerTypesInGroup)

// change transfer type and check for mixed owners again
// change transfer type and check for removed basic owners
await selectTransferType(ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL)
const updatedHomeOwnerGroup2 = [...updatedHomeOwnerGroup]
updatedHomeOwnerGroup2.pop()
await store.setMhrTransferHomeOwnerGroups(updatedHomeOwnerGroup2)

expect(wrapper.vm.getHomeOwners.length).toBe(2)
expect(homeOwners.find(getTestId('invalid-group-msg')).text()).toContain(MixedRolesErrors.hasMixedOwnerTypes)
expect(homeOwners.find(getTestId('invalid-group-msg')).text()).toContain(transfersErrors.ownersMustBeDeceased)

// change transfer type and check for mixed owners again
// change transfer type and check for removed basic owners again
await selectTransferType(ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL)
await store.setMhrTransferHomeOwnerGroups([...updatedHomeOwnerGroup2])

expect(homeOwners.find(getTestId('invalid-group-msg')).text()).toContain(MixedRolesErrors.hasMixedOwnerTypes)
expect(homeOwners.find(getTestId('invalid-group-msg')).text()).toContain(transfersErrors.ownersMustBeDeceased)
})

it('TRANS SALE: validations for under allocated group ownership interest', async () => {
Expand Down Expand Up @@ -951,7 +950,7 @@ describe('Home Owners', () => {
await homeOwners.find(getTestId('table-undo-btn')).trigger('click')

expect(homeOwners.find(getTestId('invalid-group-msg')).text())
.toContain(MixedRolesErrors.hasMixedOwnerTypes)
.toContain(transfersErrors.ownersMustBeDeceased)

await homeOwners.find(getTestId('table-delete-btn')).trigger('click')

Expand Down Expand Up @@ -1035,7 +1034,7 @@ describe('Home Owners', () => {

// since we did not delete the second owner from the group one, the error message should be displayed
expect(homeOwners.find(getTestId('invalid-group-msg')).text())
.toContain(MixedRolesErrors.hasMixedOwnerTypesInGroup)
.toContain(transfersErrors.ownersMustBeDeceased)

// delete the second owner from the first group
allDeleteButtons.at(1).trigger('click')
Expand Down Expand Up @@ -1205,7 +1204,7 @@ describe('Home Owners', () => {
{ groupId: 2, owners: [mockedPerson], type: '' }
])

expect(groupError.text()).toContain(MixedRolesErrors.hasMixedOwnerTypesInGroup)
expect(groupError.text()).toContain(transfersErrors.ownersMustBeDeceased)
})

it('TRANS ADMIN No Will: display Supporting Document component for deleted Owner', async () => {
Expand Down

0 comments on commit b08a96a

Please sign in to comment.