Skip to content

Commit

Permalink
Add new error for MHR Transfers (#1573)
Browse files Browse the repository at this point in the history
* Show error when not all Exec, Admins, Trustees removed
  • Loading branch information
dimak1 authored Oct 10, 2023
1 parent edab8bc commit 07af978
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 20 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": "2.1.13",
"version": "2.1.14",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,9 @@ export default defineComponent({
)
}
if (isTransferDueToSaleOrGift.value) return TransSaleOrGift.hasMixedOwnersInGroup(groupId)
if (isTransferDueToSaleOrGift.value) {
return TransSaleOrGift.hasMixedOwnersInGroup(groupId) || TransSaleOrGift.hasPartlyRemovedEATOwners(groupId)
}
}
const removeOwnerHandler = (owner: MhrRegistrationHomeOwnerIF): void => {
Expand Down
4 changes: 4 additions & 0 deletions ppr-ui/src/components/mhrTransfers/HomeOwnersGroupError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
MixedRolesErrors.hasMixedOwnerTypes :
MixedRolesErrors.hasMixedOwnerTypesInGroup }}
</span>
<span v-else-if="isTransferDueToSaleOrGift && TransSaleOrGift.hasPartlyRemovedEATOwners(groupId)">
{{ transfersErrors.eatOwnersMustBeDeleted }}
</span>

<!-- Transfer to Admin error messages -->
<span v-else-if="isTransferToAdminNoWill">
<span v-if="!TransToAdmin.hasAddedAdministratorsInGroup(groupId) &&
Expand Down
43 changes: 28 additions & 15 deletions ppr-ui/src/composables/mhrInformation/useTransferOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
].includes(getMhrTransferType.value?.transferType)
})

/** Returns true when the selected transfer involves Executors or Administrators **/
const isTransferToExecOrAdmin = computed((): boolean => {
return [
// transfers to Executors or Administrators
ApiTransferTypes.TO_ADMIN_NO_WILL,
ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL,
ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL
].includes(getMhrTransferType.value?.transferType)
})
const EATOwnerTypes: Array<HomeOwnerPartyTypes> = [
HomeOwnerPartyTypes.EXECUTOR,
HomeOwnerPartyTypes.ADMINISTRATOR,
HomeOwnerPartyTypes.TRUSTEE
]

const isRemovedHomeOwnerGroup = (group: MhrHomeOwnerGroupIF): boolean => {
return group.action === ActionTypes.REMOVED
Expand All @@ -88,6 +84,16 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
return group.action === ActionTypes.CHANGED
}

/** Returns true when the selected transfer involves Executors or Administrators **/
const isTransferToExecOrAdmin = computed((): boolean => {
return [
// transfers to Executors or Administrators
ApiTransferTypes.TO_ADMIN_NO_WILL,
ApiTransferTypes.TO_EXECUTOR_UNDER_25K_WILL,
ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL
].includes(getMhrTransferType.value?.transferType)
})

/** Returns true when the selected transfer type is a 'SALE_OR_GIFT' scenario **/
const isTransferDueToSaleOrGift = computed((): boolean => {
return getMhrTransferType.value?.transferType === ApiTransferTypes.SALE_OR_GIFT
Expand Down Expand Up @@ -323,6 +329,17 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
.filter(owner => owner.action !== ActionTypes.REMOVED)
.map(owner => owner.partyType)
return ownerTypes.length === 1 ? false : uniq(ownerTypes).length > 1
},
hasPartlyRemovedEATOwners: (groupId: number): boolean => {
// check if there are more than one Exec, Admin, Trustee owner that is not deleted
const ownerTypes: MhrRegistrationHomeOwnerIF[] = getMhrTransferHomeOwnerGroups.value
.find(group => group.groupId === groupId).owners
.filter(owner => EATOwnerTypes.includes(owner.partyType))

const hasOneDeleted: boolean = !!find(ownerTypes, { action: ActionTypes.REMOVED })
const hasSomeNotDeleted: boolean = ownerTypes.filter(owner => owner.action !== ActionTypes.REMOVED).length >= 1

return hasOneDeleted && hasSomeNotDeleted
}
}

Expand Down Expand Up @@ -375,9 +392,7 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
if (!owner.action || owner.action === ActionTypes.ADDED) return true

// if deleted Exec, Admin or Trustee, then docs are not required and are valid
if (owner.action === ActionTypes.REMOVED &&
[HomeOwnerPartyTypes.EXECUTOR, HomeOwnerPartyTypes.ADMINISTRATOR, HomeOwnerPartyTypes.TRUSTEE]
.includes(owner.partyType)) return true
if (owner.action === ActionTypes.REMOVED && EATOwnerTypes.includes(owner.partyType)) return true

let hasValidSupportingDoc = false

Expand Down Expand Up @@ -444,9 +459,7 @@ export const useTransferOwners = (enableAllActions: boolean = false) => {
(owner.action === ActionTypes.REMOVED &&
[HomeOwnerPartyTypes.OWNER_IND, HomeOwnerPartyTypes.OWNER_BUS].includes(owner.partyType) &&
owner.supportingDocument === TransToExec.getSupportingDocForActiveTransfer()) ||
(owner.action === ActionTypes.REMOVED &&
[HomeOwnerPartyTypes.EXECUTOR, HomeOwnerPartyTypes.ADMINISTRATOR, HomeOwnerPartyTypes.TRUSTEE]
.includes(owner.partyType)))
(owner.action === ActionTypes.REMOVED && EATOwnerTypes.includes(owner.partyType)))
)
},
prefillOwnerAsExecOrAdmin: (owner: MhrRegistrationHomeOwnerIF): void => {
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/resources/mhr-transfers/transfers-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { ApiTransferTypes } from '@/enums'
/* eslint-disable max-len */
export const transfersErrors = {
ownersMustBeDeceased: 'All owners must be deceased.',

// Executors, Administrators and Trustees Owner Types
eatOwnersMustBeDeleted: 'All executors, administrators, or bankruptcy trustees must be deleted.',
// Transfer to Executor
ownersMustBeDeceasedAndExecutorAdded: 'All owners must be deceased and an executor added.',
mustContainOneExecutor: 'Must contain at least one executor.',
Expand Down
25 changes: 25 additions & 0 deletions ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,31 @@ describe('Home Owners', () => {
expect(radioButtons.at(3).attributes('disabled')).toBe('disabled')
})

it('TRANS SALE GIFT: should show error when some Exec, Admin or Trustees are not deleted', async () => {
const homeOwnerGroup: MhrRegistrationHomeOwnerGroupIF[] = [
{ groupId: 1, owners: [mockedExecutor, mockedAdministrator], type: '' }
]

await store.setMhrTransferCurrentHomeOwnerGroups(homeOwnerGroup)
await store.setMhrTransferHomeOwnerGroups(homeOwnerGroup)

const homeOwnersTable = wrapper.findComponent(HomeOwnersTable)

// should not be any errors
expect(homeOwnersTable.find(getTestId('invalid-group-msg')).exists()).toBeFalsy()
// should show all Delete buttons in the table
const allDeleteButtons = homeOwnersTable.findAll(getTestId('table-delete-btn'))
expect(allDeleteButtons).toHaveLength(homeOwnerGroup[0].owners.length)

// delete first owner which is Executor
allDeleteButtons.at(0).trigger('click')
await Vue.nextTick()

expect(homeOwnersTable.find(getTestId('invalid-group-msg')).exists()).toBeTruthy()
expect(homeOwnersTable.find(getTestId('invalid-group-msg')).text())
.toContain(transfersErrors.eatOwnersMustBeDeleted)
})

it('TRANS SALE GIFT + Unit Note: renders Home Owners table buttons when Confidential Note filed', async () => {
const homeOwnerGroup: MhrRegistrationHomeOwnerGroupIF[] = [
{ groupId: 1, owners: [mockedPerson, mockedPerson2], type: '' }
Expand Down

0 comments on commit 07af978

Please sign in to comment.