Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-7039 Take SRW Expiry Date #3565

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions source/backend/api/Models/Concepts/Take/TakeMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.IsSurplus, src => src.IsThereSurplus)
.Map(dest => dest.LicenseToConstructArea, src => src.LicenseToConstructArea)
.Map(dest => dest.LtcEndDt, src => src.LtcEndDt)
.Map(dest => dest.NewRightOfWayArea, src => src.StatutoryRightOfWayArea)
.Map(dest => dest.NewRightOfWayArea, src => src.NewHighwayDedicationArea)
.Map(dest => dest.LandActArea, src => src.LandActArea)
.Map(dest => dest.LandActEndDt, src => src.LandActEndDt)
.Map(dest => dest.PropertyAcquisitionFile, src => src.PropertyAcquisitionFile)
Expand All @@ -25,22 +25,23 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode)
.Map(dest => dest.LandActTypeCode, src => src.LandActTypeCodeNavigation)
.Map(dest => dest.IsLicenseToConstruct, src => src.IsNewLicenseToConstruct)
//.Map(dest => dest.IsNewRightOfWay, src => src.IsNewRightOfWay) // TODO: Fix this
.Map(dest => dest.IsNewRightOfWay, src => src.IsNewHighwayDedication)
.Map(dest => dest.IsLandAct, src => src.IsNewLandAct)
//.Map(dest => dest.IsStatutoryRightOfWay, src => src.IsStatutoryRightOfWay) // TODO: Fix this
.Inherits<Entity.IBaseAppEntity, Api.Models.BaseAppModel>();
.Map(dest => dest.IsNewInterestInSrw, src => src.IsNewInterestInSrw)
.Map(dest => dest.SrwEndDt, src => src.SrwEndDt)
.Inherits<Entity.IBaseAppEntity, BaseAppModel>();

config.NewConfig<TakeModel, Entity.PimsTake>()
.Map(dest => dest.TakeId, src => src.Id)
.Map(dest => dest.Description, src => src.Description)
.Map(dest => dest.IsThereSurplus, src => src.IsSurplus)
//.Map(dest => dest.IsNewRightOfWay, src => src.IsNewRightOfWay) // TODO: Fix this.
.Map(dest => dest.IsNewHighwayDedication, src => src.IsNewRightOfWay)
.Map(dest => dest.IsNewLandAct, src => src.IsLandAct)
//.Map(dest => dest.IsStatutoryRightOfWay, src => src.IsStatutoryRightOfWay) // TODO: Fix this
.Map(dest => dest.IsNewInterestInSrw, src => src.IsNewInterestInSrw)
.Map(dest => dest.IsNewLicenseToConstruct, src => src.IsLicenseToConstruct)
.Map(dest => dest.LicenseToConstructArea, src => src.LicenseToConstructArea)
.Map(dest => dest.LtcEndDt, src => src.LtcEndDt)
.Map(dest => dest.StatutoryRightOfWayArea, src => src.NewRightOfWayArea)
.Map(dest => dest.NewHighwayDedicationArea, src => src.NewRightOfWayArea)
.Map(dest => dest.LandActArea, src => src.LandActArea)
.Map(dest => dest.LandActEndDt, src => src.LandActEndDt)
.Map(dest => dest.PropertyAcquisitionFile, src => src.PropertyAcquisitionFile)
Expand All @@ -51,6 +52,8 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.TakeTypeCode, src => src.TakeTypeCode)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode)
.Map(dest => dest.LandActTypeCode, src => src.LandActTypeCode.Id)
.Map(dest => dest.SrwEndDt, src => src.SrwEndDt)
.Map(dest => dest.IsAcquiredForInventory, () => true) // TODO: fix this
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FuriousLlama - you will have to fix this mapping in your PR

.Inherits<BaseAppModel, Entity.IBaseAppEntity>();
}
}
Expand Down
4 changes: 3 additions & 1 deletion source/backend/api/Models/Concepts/Take/TakeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class TakeModel : BaseAppModel

public bool IsLandAct { get; set; }

public bool IsStatutoryRightOfWay { get; set; }
public bool IsNewInterestInSrw { get; set; }

public float? LicenseToConstructArea { get; set; }

Expand All @@ -42,6 +42,8 @@ public class TakeModel : BaseAppModel

public float? StatutoryRightOfWayArea { get; set; }

public DateTime? SrwEndDt { get; set; }

public float? SurplusArea { get; set; }

public string TakeSiteContamTypeCode { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,10 @@ private void TransferPropertiesOfInterest(PimsAcquisitionFile acquisitionFile, b
}
var takes = _takeRepository.GetAllByPropertyAcquisitionFileId(acquisitionProperty.Internal_Id);
var coreInventoryInterestCodes = new string[] { "Section 15", "Section 17", "NOI", "Section 66" };
var activeTakes = takes.Where(t => !(t.IsNewLandAct.HasValue && t.IsNewLandAct.Value && t.LandActEndDt.HasValue && t.LandActEndDt.Value.Date < DateTime.UtcNow.Date)
&& !(t.IsNewLicenseToConstruct.HasValue && t.IsNewLicenseToConstruct.Value && t.LtcEndDt.HasValue && t.LtcEndDt.Value.Date < DateTime.UtcNow.Date));
var activeTakes = takes.Where(t =>
!(t.IsNewLandAct.HasValue && t.IsNewLandAct.Value && t.LandActEndDt.HasValue && t.LandActEndDt.Value.Date < DateTime.UtcNow.Date) &&
!(t.IsNewLicenseToConstruct.HasValue && t.IsNewLicenseToConstruct.Value && t.LtcEndDt.HasValue && t.LtcEndDt.Value.Date < DateTime.UtcNow.Date) &&
!(t.IsNewInterestInSrw.HasValue && t.IsNewInterestInSrw.Value && t.SrwEndDt.HasValue && t.SrwEndDt.Value.Date < DateTime.UtcNow.Date));
//see psp-6589 for business rules.
var isOwned = !(activeTakes.All(t => (t.IsNewLandAct.HasValue && t.IsNewLandAct.Value && coreInventoryInterestCodes.Contains(t.LandActTypeCode))
|| (t.IsNewInterestInSrw.HasValue && t.IsNewInterestInSrw.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('TakesDetailView component', () => {
isLicenseToConstruct: false,
isNewRightOfWay: false,
isLandAct: false,
isStatutoryRightOfWay: false,
isNewInterestInSrw: false,
isSurplus: false,
},
],
Expand All @@ -107,7 +107,7 @@ describe('TakesDetailView component', () => {
isLicenseToConstruct: true,
isNewRightOfWay: true,
isLandAct: true,
isStatutoryRightOfWay: true,
isNewInterestInSrw: true,
isSurplus: true,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@ export const TakesDetailView: React.FunctionComponent<ITakesDetailViewProps> = (
labelWidth="8"
>
<YesNoButtons
id="statutoryRightOfWayToggle"
id="newInterestInSrwToggle"
disabled
value={take.isStatutoryRightOfWay}
value={take.isNewInterestInSrw}
/>
</SectionField>
{take.isStatutoryRightOfWay && (
{take.isNewInterestInSrw && (
<>
<SectionField label="Area" labelWidth="12">
<AreaContainer landArea={take.statutoryRightOfWayArea ?? undefined} />
</SectionField>

<SectionField label="SRW end date" labelWidth="3" contentWidth="4">
{prettyFormatDate(take.srwEndDt ?? undefined)}
</SectionField>
</>
)}
</StyledBorderSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({

const isSurplus = getIn(values, withNameSpace(nameSpace, 'isSurplus'));
const isNewRightOfWay = getIn(values, withNameSpace(nameSpace, 'isNewRightOfWay'));
const isStatutoryRightOfWay = getIn(values, withNameSpace(nameSpace, 'isStatutoryRightOfWay'));
const isNewInterestInSrw = getIn(values, withNameSpace(nameSpace, 'isNewInterestInSrw'));
const isLandAct = getIn(values, withNameSpace(nameSpace, 'isLandAct'));
const isLicenseToConstruct = getIn(values, withNameSpace(nameSpace, 'isLicenseToConstruct'));

Expand Down Expand Up @@ -113,7 +113,11 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
</SectionField>
<StyledNoTabSection header="Area">
<StyledBorderSection>
<SectionField label="Is there a new right of way? *" labelWidth="8">
<SectionField
label="Is there a new highway dedication? *"
labelWidth="8"
tooltip="The term new highway dedication includes municipal road or provincial public highway."
>
<RadioGroup
field={withNameSpace(nameSpace, 'isNewRightOfWay')}
radioValues={yesNoRadioGroupValues}
Expand Down Expand Up @@ -151,18 +155,22 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
)}
</StyledBorderSection>
<StyledBorderSection>
<SectionField label="Is there a Statutory Right of Way: (SRW)? *" labelWidth="8">
<SectionField
label="Is there a new registered interest in land (SRW, Easement or Covenant)? *"
labelWidth="8"
>
<RadioGroup
radioValues={yesNoRadioGroupValues}
flexDirection="row"
field={withNameSpace(nameSpace, 'isStatutoryRightOfWay')}
field={withNameSpace(nameSpace, 'isNewInterestInSrw')}
handleChange={getModalWarning(() => {
setFieldValue(withNameSpace(nameSpace, 'isStatutoryRightOfWay'), 'false');
setFieldValue(withNameSpace(nameSpace, 'isNewInterestInSrw'), 'false');
setFieldValue(withNameSpace(nameSpace, 'statutoryRightOfWayArea'), 0);
setFieldValue(withNameSpace(nameSpace, 'srwEndDt'), '');
})}
/>
</SectionField>
{isStatutoryRightOfWay === 'true' && (
{isNewInterestInSrw === 'true' && (
<>
<SectionField label="Area" labelWidth="12">
<AreaContainer
Expand All @@ -185,14 +193,17 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
field={withNameSpace(nameSpace, 'statutoryRightOfWayArea')}
/>
</SectionField>
<SectionField label="SRW end date" contentWidth="4">
<FastDatePicker
field={withNameSpace(nameSpace, 'srwEndDt')}
formikProps={formikProps}
/>
</SectionField>
</>
)}
</StyledBorderSection>
<StyledBorderSection>
<SectionField
label="Is there Land Act-Reserve(s)/Withdrawal(s)/Notation(s)? *"
labelWidth="8"
>
<SectionField label="Is a there a new Land Act tenure? *" labelWidth="8">
<RadioGroup
radioValues={yesNoRadioGroupValues}
flexDirection="row"
Expand Down Expand Up @@ -239,7 +250,10 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
)}
</StyledBorderSection>
<StyledBorderSection>
<SectionField label="Is there a License to Construct (LTC)? *" labelWidth="8">
<SectionField
label="Is there a new License for Construction Access (TLCA/LTC)? *"
labelWidth="8"
>
<RadioGroup
radioValues={yesNoRadioGroupValues}
flexDirection="row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,18 @@ describe('TakesUpdateForm component', () => {
expect(queryByDisplayValue('4046.86')).toBeNull();
});

it('resets isstatutoryrightofway values if radio button toggled from yes to no', async () => {
it('resets isNewInterestInSrw values if radio button toggled from yes to no', async () => {
const { getByTestId, queryByDisplayValue } = setup({});
const noButton = getByTestId('radio-takes.0.isstatutoryrightofway-no');
const noButton = getByTestId('radio-takes.0.isnewinterestinsrw-no');
await act(async () => userEvent.click(noButton));

expect(queryByDisplayValue('8093.71')).not.toBeNull();
expect(queryByDisplayValue('Nov 20, 2022')).not.toBeNull();
const confirmButton = await screen.findByText('Confirm');
await act(async () => userEvent.click(confirmButton));

expect(queryByDisplayValue('8093.71')).toBeNull();
expect(queryByDisplayValue('Nov 20, 2022')).toBeNull();
});

it('resets islandAct values if radio button toggled from yes to no', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const emptyTake: Api_Take = {
description: '',
isSurplus: false,
isLandAct: false,
isStatutoryRightOfWay: false,
isNewInterestInSrw: false,
isNewRightOfWay: false,
isLicenseToConstruct: false,
licenseToConstructArea: null,
Expand All @@ -111,6 +111,7 @@ export const emptyTake: Api_Take = {
landActEndDt: null,
landActTypeCode: null,
statutoryRightOfWayArea: null,
srwEndDt: null,
surplusArea: null,
propertyAcquisitionFileId: null,
takeSiteContamTypeCode: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,31 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
<label
class="c8"
>
Is there a new right of way? *:
Is there a new highway dedication? *:
<span
class="ml-2"
>
<span
class="tooltip-icon"
data-testid="tooltip-icon-section-field-tooltip"
id="section-field-tooltip"
>
<svg
class="tooltip-icon"
fill="currentColor"
height="1em"
stroke="currentColor"
stroke-width="0"
viewBox="0 0 512 512"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"
/>
</svg>
</span>
</span>
</label>
</div>
<div
Expand Down Expand Up @@ -832,7 +856,7 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
<label
class="c8"
>
Is there a Statutory Right of Way: (SRW)? *:
Is there a new registered interest in land (SRW, Easement or Covenant)? *:
</label>
</div>
<div
Expand All @@ -853,16 +877,16 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
<input
checked=""
class="form-check-input position-static"
data-testid="radio-takes.0.isstatutoryrightofway-yes"
data-testid="radio-takes.0.isnewinterestinsrw-yes"
id="input-true"
name="takes.0.isStatutoryRightOfWay"
name="takes.0.isNewInterestInSrw"
type="radio"
value="true"
/>
</div>
<label
class="form-check-label form-label"
for="takes.0.isStatutoryRightOfWay"
for="takes.0.isNewInterestInSrw"
>
Yes
</label>
Expand All @@ -875,16 +899,16 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
>
<input
class="form-check-input position-static"
data-testid="radio-takes.0.isstatutoryrightofway-no"
data-testid="radio-takes.0.isnewinterestinsrw-no"
id="input-false"
name="takes.0.isStatutoryRightOfWay"
name="takes.0.isNewInterestInSrw"
type="radio"
value="false"
/>
</div>
<label
class="form-check-label form-label"
for="takes.0.isStatutoryRightOfWay"
for="takes.0.isNewInterestInSrw"
>
No
</label>
Expand Down Expand Up @@ -1014,6 +1038,53 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
</div>
</div>
</div>
<div
class="pb-2 row"
>
<div
class="pr-0 text-left col-4"
>
<label
class="c8"
>
SRW end date:
</label>
</div>
<div
class="c9 text-left col-4"
>
<div
class="c17 form-group"
>
<div
class="react-datepicker-wrapper d-block"
>
<div
class="react-datepicker__input-container react-datepicker__view-calendar-icon"
>
<svg
class="react-datepicker__calendar-icon"
viewBox="0 0 448 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M96 32V64H48C21.5 64 0 85.5 0 112v48H448V112c0-26.5-21.5-48-48-48H352V32c0-17.7-14.3-32-32-32s-32 14.3-32 32V64H160V32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192H0V464c0 26.5 21.5 48 48 48H400c26.5 0 48-21.5 48-48V192z"
/>
</svg>
<input
autocomplete="off"
class="c18 form-control date-picker"
id="datepicker-takes.0.srwEndDt"
name="takes.0.srwEndDt"
placeholder="MTH DD, YYYY"
type="text"
value="Nov 20, 2022"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
Expand All @@ -1031,7 +1102,7 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
<label
class="c8"
>
Is there Land Act-Reserve(s)/Withdrawal(s)/Notation(s)? *:
Is a there a new Land Act tenure? *:
</label>
</div>
<div
Expand Down Expand Up @@ -1344,7 +1415,7 @@ exports[`TakesUpdateForm component renders as expected 1`] = `
<label
class="c8"
>
Is there a License to Construct (LTC)? *:
Is there a new License for Construction Access (TLCA/LTC)? *:
</label>
</div>
<div
Expand Down
Loading
Loading