From f371920d8f0915aa88b6045229a69bba4690db9e Mon Sep 17 00:00:00 2001 From: CameronEYDS <53542131+cameron-eyds@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:44:01 -0700 Subject: [PATCH] Enable Home Dealer Transfers (#1992) --- ppr-ui/package-lock.json | 4 ++-- ppr-ui/package.json | 2 +- .../components/unitNotes/UnitNoteReview.vue | 4 +++- .../composables/userAccess/useUserAccess.ts | 21 ++++++++++------ .../views/mhrInformation/MhrInformation.vue | 16 ++++++------- .../unit/MhrInformationQsTransfers.spec.ts | 24 +++++++++---------- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/ppr-ui/package-lock.json b/ppr-ui/package-lock.json index d18ceb193..4f68140d0 100644 --- a/ppr-ui/package-lock.json +++ b/ppr-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "ppr-ui", - "version": "3.2.41", + "version": "3.2.42", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ppr-ui", - "version": "3.2.41", + "version": "3.2.42", "dependencies": { "@bcrs-shared-components/input-field-date-picker": "^1.0.0", "@lemoncode/fonk": "^1.5.1", diff --git a/ppr-ui/package.json b/ppr-ui/package.json index 42ae934ba..322955ffa 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "3.2.41", + "version": "3.2.42", "private": true, "appName": "Assets UI", "sbcName": "SBC Common Components", diff --git a/ppr-ui/src/components/unitNotes/UnitNoteReview.vue b/ppr-ui/src/components/unitNotes/UnitNoteReview.vue index c9f35638a..dcbfc1ac3 100644 --- a/ppr-ui/src/components/unitNotes/UnitNoteReview.vue +++ b/ppr-ui/src/components/unitNotes/UnitNoteReview.vue @@ -200,7 +200,9 @@ export default defineComponent({ const localState = reactive({ validateSubmittingParty: false, - initialAttention: (isCancelUnitNote.value || isRedemptionUnitNote.value) ? '' : getMhrUnitNoteRegistration.value?.attentionReference, + initialAttention: (isCancelUnitNote.value || isRedemptionUnitNote.value) + ? '' + : getMhrUnitNoteRegistration.value?.attentionReference, unitNoteType: UnitNotesInfo[getMhrUnitNote.value.documentType], givingNoticeParty: computed((): PartyIF => getMhrUnitNote.value.givingNoticeParty), unitNoteSubmittingParty: computed(() => getMhrUnitNoteRegistration.value.submittingParty || {}), diff --git a/ppr-ui/src/composables/userAccess/useUserAccess.ts b/ppr-ui/src/composables/userAccess/useUserAccess.ts index 0abfe6668..4dc101549 100644 --- a/ppr-ui/src/composables/userAccess/useUserAccess.ts +++ b/ppr-ui/src/composables/userAccess/useUserAccess.ts @@ -325,7 +325,7 @@ export const useUserAccess = () => { * Disable manufacturer transfer based on name match conditions and restricted to Sole Owners * @returns {Promise} Promise that returns true when Manufacturer matches name records and is a sole owner */ - const disableManufacturerTransfer = async (): Promise => { + const disableDealerManufacturerTransfer = async (isDealer: boolean = false): Promise => { let isSoleOwner: boolean, isNameMatch: boolean, currentOwnerName: string // First verify a single owner group & SOLE ownership @@ -334,12 +334,19 @@ export const useUserAccess = () => { currentOwnerName = getMhrTransferCurrentHomeOwnerGroups.value[0]?.owners[0]?.organizationName } else return true - // If a Sole Owner: Fetch and verify the sole owner name matches the manufacturers records org or dba name + // If a Sole Owner: Fetch and verify the sole owner name matches the dealers/manufacturers records org or dba name if (isSoleOwner) { - const manufacturerData: MhrManufacturerInfoIF = await getMhrManufacturerInfo() - const manufacturerOrgName = manufacturerData?.ownerGroups[0]?.owners[0]?.organizationName - const manufacturerDbaName = manufacturerData?.dbaName - isNameMatch = (currentOwnerName === manufacturerOrgName || currentOwnerName === manufacturerDbaName) + let orgName, dbaName + if (isDealer) { + const dealerData: MhrQsPayloadIF = await getQualifiedSupplier() + orgName = dealerData?.businessName + dbaName = dealerData?.dbaName + } else { + const manufacturerData: MhrManufacturerInfoIF = await getMhrManufacturerInfo() + orgName = manufacturerData?.ownerGroups[0]?.owners[0]?.organizationName + dbaName = manufacturerData?.dbaName + } + isNameMatch = (currentOwnerName === orgName || currentOwnerName === dbaName) } else return true return !isNameMatch @@ -504,7 +511,7 @@ export const useUserAccess = () => { isUserAccessRoute, isAuthorizationValid, downloadServiceAgreement, - disableManufacturerTransfer, + disableDealerManufacturerTransfer, disableDealerManufacturerLocationChange, submitQsApplication } diff --git a/ppr-ui/src/views/mhrInformation/MhrInformation.vue b/ppr-ui/src/views/mhrInformation/MhrInformation.vue index 36cc5cfbe..36e104831 100644 --- a/ppr-ui/src/views/mhrInformation/MhrInformation.vue +++ b/ppr-ui/src/views/mhrInformation/MhrInformation.vue @@ -521,11 +521,11 @@

Note: You cannot register an ownership transfer or change - because the home does not have a sole owner whose name matches your manufacturer’s name. Transfers can - be registered by BC Registries staff or by a qualified lawyer or notary. + because the home does not have a sole owner whose name matches your dealer's or manufacturer’s name. + Transfers can be registered by BC Registries staff or by a qualified lawyer or notary.

{ - return !isRoleStaffSbc.value && getFeatureFlag('mhr-transfer-enabled') && - localState.enableRoleBasedTransfer + return !isRoleStaffSbc.value && getFeatureFlag('mhr-transfer-enabled') }), isDraft: computed((): boolean => { return getMhrInformation.value.draftNumber @@ -1076,11 +1074,11 @@ export default defineComponent({ // Check for product based Transfer access switch(true) { case isRoleManufacturer.value: - localState.disableRoleBaseTransfer = await disableManufacturerTransfer() + localState.disableRoleBaseTransfer = await disableDealerManufacturerTransfer() localState.disableRoleBaseLocationChange = await disableDealerManufacturerLocationChange() break; case isRoleQualifiedSupplierHomeDealer.value: - localState.enableRoleBasedTransfer = false + localState.disableRoleBaseTransfer = await disableDealerManufacturerTransfer(true) localState.disableRoleBaseLocationChange = await disableDealerManufacturerLocationChange(true) break; } diff --git a/ppr-ui/tests/unit/MhrInformationQsTransfers.spec.ts b/ppr-ui/tests/unit/MhrInformationQsTransfers.spec.ts index 170f147b4..cf2890c53 100644 --- a/ppr-ui/tests/unit/MhrInformationQsTransfers.spec.ts +++ b/ppr-ui/tests/unit/MhrInformationQsTransfers.spec.ts @@ -76,14 +76,10 @@ for (const subProduct of subProducts) { }) it('renders change owners button conditionally', async () => { - // enable transfers based on role - const isNotDealer = subProduct !== MhrSubTypes.DEALERS - wrapper.vm.enableRoleBasedTransfer = isNotDealer - await nextTick() expect(wrapper.find('#home-owners-header').exists()).toBe(true) - expect(wrapper.vm.enableHomeOwnerChanges).toBe(isNotDealer) - expect(wrapper.find('#home-owners-change-btn').exists()).toBe(isNotDealer) + expect(wrapper.vm.enableHomeOwnerChanges).toBe(true) + expect(wrapper.find('#home-owners-change-btn').exists()).toBe(true) }) it('renders Lien Alert', async () => { @@ -113,28 +109,30 @@ for (const subProduct of subProducts) { it('verify role based transfer messaging and button states', async () => { const isManufacturer = subProduct === MhrSubTypes.MANUFACTURER + const isDealer = subProduct === MhrSubTypes.DEALERS // enable transfers based on role - wrapper.vm.enableRoleBasedTransfer = subProduct !== MhrSubTypes.DEALERS - wrapper.vm.disableRoleBaseTransfer = isManufacturer + wrapper.vm.disableRoleBaseTransfer = isManufacturer || isDealer await nextTick() // Verify showTransfer type expect(wrapper.vm.showTransferType).toBe(false) // Verify Mismatch text - expect(wrapper.find('.manufacturer-mismatch-text').exists()).toBe(isManufacturer) + expect(wrapper.find('.dealer-manufacturer-mismatch-text').exists()).toBe(isManufacturer || isDealer) // Role based tests switch (subProduct) { case MhrSubTypes.DEALERS: - expect(wrapper.find('#home-owners-change-btn').exists()).toBe(false) + expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeDefined() + // Verify Mismatch text content + expect(wrapper.find('.dealer-manufacturer-mismatch-text').text()).toContain('You cannot register an ownership ' + + 'transfer or change because the home does not have a sole owner whose name matches') break; case MhrSubTypes.MANUFACTURER: expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeDefined() // Verify Mismatch text content - expect(wrapper.find('.manufacturer-mismatch-text').text()).toContain('You cannot register an ownership ' + - 'transfer or change because the home does not have a sole owner whose name matches your manufacturer’s' + - ' name') + expect(wrapper.find('.dealer-manufacturer-mismatch-text').text()).toContain('You cannot register an ownership ' + + 'transfer or change because the home does not have a sole owner whose name matches') break; case MhrSubTypes.LAWYERS_NOTARIES: expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeUndefined()