From 39d161427948d31b558dda4685371ab163048782 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Thu, 18 Jul 2024 17:04:39 -0700 Subject: [PATCH] psp-8912 show suggested text for fee determination. --- .../add/FeeDeterminationSubForm.test.tsx | 62 +++++++++++-------- .../leases/add/FeeDeterminationSubForm.tsx | 38 +++++++++++- .../FeeDeterminationSubForm.test.tsx.snap | 8 +++ .../details/DetailFeeDetermination.test.tsx | 30 +++++++++ .../details/DetailFeeDetermination.tsx | 35 ++++++++++- .../DetailFeeDetermination.test.tsx.snap | 25 ++++++++ .../src/features/leases/leaseUtils.ts | 24 ++++--- 7 files changed, 185 insertions(+), 37 deletions(-) diff --git a/source/frontend/src/features/leases/add/FeeDeterminationSubForm.test.tsx b/source/frontend/src/features/leases/add/FeeDeterminationSubForm.test.tsx index c2f9d84251..47d6ddd8d8 100644 --- a/source/frontend/src/features/leases/add/FeeDeterminationSubForm.test.tsx +++ b/source/frontend/src/features/leases/add/FeeDeterminationSubForm.test.tsx @@ -10,6 +10,7 @@ import { fillInput, renderAsync } from '@/utils/test-utils'; import { lookupCodesSlice } from '@/store/slices/lookupCodes'; import { mockLookups } from '@/mocks/lookups.mock'; import { Simulate } from 'react-dom/test-utils'; +import { SuggestedFeeCode } from '../leaseUtils'; const history = createMemoryHistory(); const storeState = { @@ -44,7 +45,7 @@ describe('LeaseFeeDeterminationSubForm component', () => { it('displays expected Nominal fee', async () => { const { - component: { container }, + component: { container, getByText }, } = await setup({}); let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); @@ -57,11 +58,16 @@ describe('LeaseFeeDeterminationSubForm component', () => { }); expect(suggestedFeeField).toHaveTextContent('$1 - Nominal'); + expect( + getByText('No or nominal fee determinations should include justification in the', { + exact: false, + }), + ).toBeVisible(); }); it('displays expected LAF fee', async () => { const { - component: { container }, + component: { container, getByText }, } = await setup({}); let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); @@ -74,11 +80,16 @@ describe('LeaseFeeDeterminationSubForm component', () => { }); expect(suggestedFeeField).toHaveTextContent('Licence Administration Fee (LAF) *'); + expect( + getByText('License administration fees are charged when there is either: a financial', { + exact: false, + }), + ).toBeVisible(); }); it('displays expected FMV fee', async () => { const { - component: { container }, + component: { container, getByText }, } = await setup({}); let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); @@ -93,28 +104,16 @@ describe('LeaseFeeDeterminationSubForm component', () => { expect(suggestedFeeField).toHaveTextContent( 'Fair Market Value (FMV) - (Licence Administration Fee Minimum)', ); + expect( + getByText('Fair market value fee determination should include the square footage rate', { + exact: false, + }), + ).toBeVisible(); }); - it('displays expected LAF fee', async () => { - const { - component: { container }, - } = await setup({}); - - let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); - - expect(suggestedFeeField).toHaveTextContent('Unknown'); - - await act(async () => { - await fillInput(container, 'isPublicBenefit', 'true', 'select'); - await fillInput(container, 'isFinancialGain', 'true', 'select'); - }); - - expect(suggestedFeeField).toHaveTextContent('Licence Administration Fee (LAF) *'); - }); - - it('displays expected LAF fee', async () => { + it('displays expected any fee', async () => { const { - component: { container }, + component: { container, getByText }, } = await setup({}); let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); @@ -122,10 +121,23 @@ describe('LeaseFeeDeterminationSubForm component', () => { expect(suggestedFeeField).toHaveTextContent('Unknown'); await act(async () => { - await fillInput(container, 'isPublicBenefit', 'true', 'select'); - await fillInput(container, 'isFinancialGain', 'true', 'select'); + await fillInput(container, 'isPublicBenefit', 'false', 'select'); + await fillInput(container, 'isFinancialGain', 'false', 'select'); }); - expect(suggestedFeeField).toHaveTextContent('Licence Administration Fee (LAF) *'); + expect(suggestedFeeField).toHaveTextContent(SuggestedFeeCode.ANY); + expect( + getByText('No or nominal fee determinations should include justification', { exact: false }), + ).toBeVisible(); + expect( + getByText('Fair market value fee determination should include the square footage rate', { + exact: false, + }), + ).toBeVisible(); + expect( + getByText('License administration fees are charged when there is either: a financial', { + exact: false, + }), + ).toBeVisible(); }); }); diff --git a/source/frontend/src/features/leases/add/FeeDeterminationSubForm.tsx b/source/frontend/src/features/leases/add/FeeDeterminationSubForm.tsx index 4732b178b7..e305ed2575 100644 --- a/source/frontend/src/features/leases/add/FeeDeterminationSubForm.tsx +++ b/source/frontend/src/features/leases/add/FeeDeterminationSubForm.tsx @@ -1,12 +1,13 @@ import { FormikProps, getIn } from 'formik'; import { useEffect, useState } from 'react'; +import styled from 'styled-components'; import { TextArea } from '@/components/common/form'; import { InlineYesNoSelect } from '@/components/common/form/styles'; import { Section } from '@/components/common/Section/Section'; import { SectionField } from '@/components/common/Section/SectionField'; -import { getSuggestedFee } from '../leaseUtils'; +import { getSuggestedFee, SuggestedFeeCode } from '../leaseUtils'; import { LeaseFormModel } from '../models'; export interface IFeeDeterminationSubFormProps { @@ -20,7 +21,7 @@ const FeeDeterminationSubForm: React.FunctionComponent(SuggestedFeeCode.UNKNOWN); useEffect(() => { setFee(getSuggestedFee(isPublicBenefit, financialGain)); @@ -42,7 +43,33 @@ const FeeDeterminationSubForm: React.FunctionComponent - {fee} + + {fee} + + {(fee === SuggestedFeeCode.NOMINAL || fee === SuggestedFeeCode.ANY) && ( +

+ Nominal:  + No or nominal fee determinations should include justification in the Comments field. +

+ )} + {(fee === SuggestedFeeCode.FMV || fee === SuggestedFeeCode.ANY) && ( +

+ FMV:  + Fair market value fee determination should include the square footage rate in the + Comments field. The rate determination summary or appraisal should be uploaded. +

+ )} + {(fee === SuggestedFeeCode.LAF || fee === SuggestedFeeCode.ANY) && ( +

+ LAF:  + License administration fees are charged when there is either: a financial gain for + the licensee and a benefit to the public, or when there is no financial gain to the + licensee and there is no benefit for the public. The LAF can vary based on the + impact to the land, the length of the LOO, and if MOTI requires a legal review. +

+ )} +
+
renders as expected 1`] = ` font-weight: bold; } +.c5 { + font-size: 1.4rem; + margin-top: 1rem; +} +
@@ -193,6 +198,9 @@ exports[`LeaseFeeDeterminationSubForm component > renders as expected 1`] = ` data-testid="suggestedFee" > Unknown +
diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.test.tsx b/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.test.tsx index de819610c2..abee74960d 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.test.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.test.tsx @@ -71,6 +71,11 @@ describe('DetailFeeDetermination component', () => { }, }); expect(getByText('$1 - Nominal')).toBeVisible(); + expect( + getByText('No or nominal fee determinations should include justification in the', { + exact: false, + }), + ).toBeVisible(); }); it('renders the suggested Fee field with LAF calculation', () => { @@ -84,6 +89,11 @@ describe('DetailFeeDetermination component', () => { }, }); expect(getByText('Licence Administration Fee (LAF) *')).toBeVisible(); + expect( + getByText('License administration fees are charged when there is either: a financial', { + exact: false, + }), + ).toBeVisible(); }); it('renders the suggested Fee field with FMV calculation', () => { @@ -99,6 +109,11 @@ describe('DetailFeeDetermination component', () => { expect( getByText('Fair Market Value (FMV) - (Licence Administration Fee Minimum)'), ).toBeVisible(); + expect( + getByText('Fair market value fee determination should include the square footage rate', { + exact: false, + }), + ).toBeVisible(); }); it('renders the suggested Fee field with non-defined calculation', () => { @@ -112,6 +127,21 @@ describe('DetailFeeDetermination component', () => { }, }); expect(getByText('$1 / Fair Market Value / Licence Administration Fee')).toBeVisible(); + expect( + getByText('No or nominal fee determinations should include justification in the', { + exact: false, + }), + ).toBeVisible(); + expect( + getByText('Fair market value fee determination should include the square footage rate', { + exact: false, + }), + ).toBeVisible(); + expect( + getByText('License administration fees are charged when there is either: a financial', { + exact: false, + }), + ).toBeVisible(); }); it('renders the suggested Fee field with unknown calculation', async () => { diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.tsx b/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.tsx index dae86d10bf..88fe98223a 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/details/DetailFeeDetermination.tsx @@ -1,4 +1,5 @@ import { getIn, useFormikContext } from 'formik'; +import styled from 'styled-components'; import { YesNoSelect } from '@/components/common/form/YesNoSelect'; import { Section } from '@/components/common/Section/Section'; @@ -6,7 +7,7 @@ import { SectionField } from '@/components/common/Section/SectionField'; import { ApiGen_Concepts_Lease } from '@/models/api/generated/ApiGen_Concepts_Lease'; import { withNameSpace } from '@/utils/formUtils'; -import { getSuggestedFee } from '../../../leaseUtils'; +import { getSuggestedFee, SuggestedFeeCode } from '../../../leaseUtils'; export interface IDetailFeeDeterminationProps { nameSpace?: string; @@ -27,6 +28,7 @@ export const DetailFeeDetermination: React.FunctionComponent< formikProps.values, withNameSpace(nameSpace, 'feeDeterminationNote'), ); + const fee = getSuggestedFee(isPublicBenefit, isFinancialGain); return (
@@ -43,7 +45,31 @@ export const DetailFeeDetermination: React.FunctionComponent< tooltip="Licence Administration Fee (LAF) *: If the financial gain far outweighs the public benefit, Fair Market Value should be considered over Licence Administration Fee" labelWidth="3" > - {getSuggestedFee(isPublicBenefit, isFinancialGain)} + {fee} + + {(fee === SuggestedFeeCode.NOMINAL || fee === SuggestedFeeCode.ANY) && ( +

+ Nominal:  + No or nominal fee determinations should include justification in the Comments field. +

+ )} + {(fee === SuggestedFeeCode.FMV || fee === SuggestedFeeCode.ANY) && ( +

+ FMV:  + Fair market value fee determination should include the square footage rate in the + Comments field. The rate determination summary or appraisal should be uploaded. +

+ )} + {(fee === SuggestedFeeCode.LAF || fee === SuggestedFeeCode.ANY) && ( +

+ LAF:  + License administration fees are charged when there is either: a financial gain for the + licensee and a benefit to the public, or when there is no financial gain to the + licensee and there is no benefit for the public. The LAF can vary based on the impact + to the land, the length of the LOO, and if MOTI requires a legal review. +

+ )} +
); }; + +const StyledHelpText = styled.div` + font-size: 1.4rem; + margin-top: 1rem; +`; diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/DetailFeeDetermination.test.tsx.snap b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/DetailFeeDetermination.test.tsx.snap index caf0c39a07..31c48ae246 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/DetailFeeDetermination.test.tsx.snap +++ b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/DetailFeeDetermination.test.tsx.snap @@ -36,6 +36,11 @@ exports[`DetailFeeDetermination component > renders a complete lease as expected font-weight: bold; } +.c5 { + font-size: 1.4rem; + margin-top: 1rem; +} +
@@ -206,6 +211,18 @@ exports[`DetailFeeDetermination component > renders a complete lease as expected > $1 - Nominal +
+

+ + Nominal:  + + No or nominal fee determinations should include justification in the Comments field. +

+
renders minimally as expected 1`] = font-weight: bold; } +.c5 { + font-size: 1.4rem; + margin-top: 1rem; +} +
@@ -459,6 +481,9 @@ exports[`DetailFeeDetermination component > renders minimally as expected 1`] = > Unknown +
{ - if (isPublicBenefit == null || isFinancialGain == null) return 'Unknown'; - else if (isPublicBenefit && isFinancialGain) return 'Licence Administration Fee (LAF) *'; - else if (isPublicBenefit && !isFinancialGain) return '$1 - Nominal'; - else if (!isPublicBenefit && isFinancialGain) - return 'Fair Market Value (FMV) - (Licence Administration Fee Minimum)'; - else return '$1 / Fair Market Value / Licence Administration Fee'; +export enum SuggestedFeeCode { + LAF = 'Licence Administration Fee (LAF) *', + FMV = 'Fair Market Value (FMV) - (Licence Administration Fee Minimum)', + ANY = '$1 / Fair Market Value / Licence Administration Fee', + NOMINAL = '$1 - Nominal', + UNKNOWN = 'Unknown', +} + +export const getSuggestedFee = ( + isPublicBenefit: boolean, + isFinancialGain: boolean, +): SuggestedFeeCode => { + if (isPublicBenefit == null || isFinancialGain == null) return SuggestedFeeCode.UNKNOWN; + else if (isPublicBenefit && isFinancialGain) return SuggestedFeeCode.LAF; + else if (isPublicBenefit && !isFinancialGain) return SuggestedFeeCode.NOMINAL; + else if (!isPublicBenefit && isFinancialGain) return SuggestedFeeCode.FMV; + else return SuggestedFeeCode.ANY; };