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

Takes - Acquire property toggle #3574

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
43 changes: 23 additions & 20 deletions source/backend/api/Models/Concepts/Take/TakeMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,53 @@ public void Register(TypeAdapterConfig config)
config.NewConfig<Entity.PimsTake, TakeModel>()
.Map(dest => dest.Id, src => src.TakeId)
.Map(dest => dest.Description, src => src.Description)
.Map(dest => dest.IsSurplus, src => src.IsThereSurplus)
.Map(dest => dest.NewHighwayDedicationArea, src => src.NewHighwayDedicationArea)
.Map(dest => dest.AreaUnitTypeCode, src => src.AreaUnitTypeCodeNavigation)
.Map(dest => dest.IsAcquiredForInventory, src => src.IsAcquiredForInventory)
.Map(dest => dest.IsThereSurplus, src => src.IsThereSurplus)
.Map(dest => dest.IsNewLicenseToConstruct, src => src.IsNewLicenseToConstruct)
.Map(dest => dest.IsNewHighwayDedication, src => src.IsNewHighwayDedication)
.Map(dest => dest.IsNewLandAct, src => src.IsNewLandAct)
.Map(dest => dest.IsNewInterestInSrw, src => src.IsNewInterestInSrw)
.Map(dest => dest.LicenseToConstructArea, src => src.LicenseToConstructArea)
.Map(dest => dest.LtcEndDt, src => src.LtcEndDt)
.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)
.Map(dest => dest.PropertyAcquisitionFileId, src => src.PropertyAcquisitionFileId)
.Map(dest => dest.StatutoryRightOfWayArea, src => src.StatutoryRightOfWayArea)
.Map(dest => dest.SrwEndDt, src => src.SrwEndDt)
.Map(dest => dest.SurplusArea, src => src.SurplusArea)
.Map(dest => dest.TakeSiteContamTypeCode, src => src.TakeSiteContamTypeCode)
.Map(dest => dest.TakeTypeCode, src => src.TakeTypeCode)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode)
.Map(dest => dest.TakeSiteContamTypeCode, src => src.TakeSiteContamTypeCodeNavigation)
.Map(dest => dest.TakeTypeCode, src => src.TakeTypeCodeNavigation)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCodeNavigation)
.Map(dest => dest.LandActTypeCode, src => src.LandActTypeCodeNavigation)
.Map(dest => dest.IsLicenseToConstruct, src => src.IsNewLicenseToConstruct)
.Map(dest => dest.IsNewRightOfWay, src => src.IsNewHighwayDedication)
.Map(dest => dest.IsLandAct, src => src.IsNewLandAct)
.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.IsNewHighwayDedication, src => src.IsNewRightOfWay)
.Map(dest => dest.IsNewLandAct, src => src.IsLandAct)
.Map(dest => dest.NewHighwayDedicationArea, src => src.NewHighwayDedicationArea)
.Map(dest => dest.AreaUnitTypeCode, src => src.AreaUnitTypeCode.Id)
.Map(dest => dest.IsAcquiredForInventory, src => src.IsAcquiredForInventory)
.Map(dest => dest.IsThereSurplus, src => src.IsThereSurplus)
.Map(dest => dest.IsNewLicenseToConstruct, src => src.IsNewLicenseToConstruct)
.Map(dest => dest.IsNewHighwayDedication, src => src.IsNewHighwayDedication)
.Map(dest => dest.IsNewLandAct, src => src.IsNewLandAct)
.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.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)
.Map(dest => dest.PropertyAcquisitionFileId, src => src.PropertyAcquisitionFileId)
.Map(dest => dest.StatutoryRightOfWayArea, src => src.StatutoryRightOfWayArea)
.Map(dest => dest.SrwEndDt, src => src.SrwEndDt)
.Map(dest => dest.SurplusArea, src => src.SurplusArea)
.Map(dest => dest.TakeSiteContamTypeCode, src => src.TakeSiteContamTypeCode)
.Map(dest => dest.TakeTypeCode, src => src.TakeTypeCode)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode)
.Map(dest => dest.TakeSiteContamTypeCode, src => src.TakeSiteContamTypeCode.Id)
.Map(dest => dest.TakeTypeCode, src => src.TakeTypeCode.Id)
.Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode.Id)
.Map(dest => dest.LandActTypeCode, src => src.LandActTypeCode.Id)
.Map(dest => dest.SrwEndDt, src => src.SrwEndDt)
.Map(dest => dest.IsAcquiredForInventory, () => true) // TODO: fix this
.Inherits<BaseAppModel, Entity.IBaseAppEntity>();
}
}
Expand Down
29 changes: 15 additions & 14 deletions source/backend/api/Models/Concepts/Take/TakeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ namespace Pims.Api.Models.Concepts
{
/// <summary>
/// TakeModel class, provides a model to represent the take.
/// LINK @frontend/src/models/api/Take.ts
/// </summary>
public class TakeModel : BaseAppModel
{
#region Properties

/// <summary>
/// get/set - The primary key to identify the property.
/// </summary>
public long Id { get; set; }

public string Description { get; set; }

public bool IsSurplus { get; set; }
public float? NewHighwayDedicationArea { get; set; }

public TypeModel<string> AreaUnitTypeCode { get; set; }

public bool? IsAcquiredForInventory { get; set; }

public bool IsLicenseToConstruct { get; set; }
public bool? IsThereSurplus { get; set; }

public bool IsNewRightOfWay { get; set; }
public bool? IsNewLicenseToConstruct { get; set; }

public bool IsLandAct { get; set; }
public bool? IsNewHighwayDedication { get; set; }

public bool IsNewInterestInSrw { get; set; }
public bool? IsNewLandAct { get; set; }

public bool? IsNewInterestInSrw { get; set; }

public float? LicenseToConstructArea { get; set; }

public DateTime? LtcEndDt { get; set; }

public float? NewRightOfWayArea { get; set; }

public float? LandActArea { get; set; }

public DateTime? LandActEndDt { get; set; }
Expand All @@ -46,11 +47,11 @@ public class TakeModel : BaseAppModel

public float? SurplusArea { get; set; }

public string TakeSiteContamTypeCode { get; set; }
public TypeModel<string> TakeSiteContamTypeCode { get; set; }

public string TakeTypeCode { get; set; }
public TypeModel<string> TakeTypeCode { get; set; }

public string TakeStatusTypeCode { get; set; }
public TypeModel<string> TakeStatusTypeCode { get; set; }

public TypeModel<string> LandActTypeCode { get; set; }
#endregion
Expand Down
17 changes: 15 additions & 2 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,25 @@ private void TransferPropertiesOfInterest(PimsAcquisitionFile acquisitionFile, b
!(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.

// 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)
|| (t.IsThereSurplus.HasValue && t.IsThereSurplus.Value)
|| (t.IsNewLicenseToConstruct.HasValue && t.IsNewLicenseToConstruct.Value)) && activeTakes.Any());
_propertyRepository.TransferFileProperty(property, isOwned);
var isPropertyOfInterest = false;

// Override for dedication psp-7048.
var doNotAcquire = takes.All(t =>
t.IsNewHighwayDedication.HasValue && t.IsNewHighwayDedication.Value && t.IsAcquiredForInventory.HasValue && !t.IsAcquiredForInventory.Value);

if (doNotAcquire)
{
isOwned = false;
isPropertyOfInterest = true;
}

_propertyRepository.TransferFileProperty(property, isOwned, isPropertyOfInterest);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface IPropertyRepository : IRepository<PimsProperty>

void Delete(PimsProperty property);

PimsProperty TransferFileProperty(PimsProperty property, bool isOwned = true);
PimsProperty TransferFileProperty(PimsProperty property, bool isOwned, bool isPropertyOfInterest);

HashSet<long> GetMatchingIds(PropertyFilterCriteria filter);
}
Expand Down
13 changes: 9 additions & 4 deletions source/backend/dal/Repositories/PropertyRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,25 @@
/// </summary>
/// <param name="property">The property to update.</param>
/// <returns>The updated property.</returns>
public PimsProperty TransferFileProperty(PimsProperty property, bool isOwned = true)
public PimsProperty TransferFileProperty(PimsProperty property, bool isOwned, bool isPropertyOfInterest)
{
property.ThrowIfNull(nameof(property));

var existingProperty = Context.PimsProperties
.FirstOrDefault(p => p.PropertyId == property.Internal_Id) ?? throw new KeyNotFoundException();

existingProperty.IsPropertyOfInterest = false;
existingProperty.IsPropertyOfInterest = isPropertyOfInterest;

Check warning on line 391 in source/backend/dal/Repositories/PropertyRepository.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/dal/Repositories/PropertyRepository.cs#L391

Added line #L391 was not covered by tests
existingProperty.IsOwned = isOwned;
existingProperty.PropertyClassificationTypeCode = "COREOPER";
if (!isOwned)

if (isOwned)
{
existingProperty.PropertyClassificationTypeCode = "COREOPER";
}

Check warning on line 397 in source/backend/dal/Repositories/PropertyRepository.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/dal/Repositories/PropertyRepository.cs#L395-L397

Added lines #L395 - L397 were not covered by tests
else
{
existingProperty.PropertyClassificationTypeCode = "OTHER";
}

return existingProperty;
}

Expand Down
2 changes: 1 addition & 1 deletion source/backend/dal/Repositories/TakeRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

public IEnumerable<PimsTake> GetAllByPropertyAcquisitionFileId(long acquisitionFilePropertyId)
{
return Context.PimsTakes.Include(t => t.PropertyAcquisitionFile).Where(pf => pf.PropertyAcquisitionFileId == acquisitionFilePropertyId);
return Context.PimsTakes.Include(t => t.PropertyAcquisitionFile).Where(pf => pf.PropertyAcquisitionFileId == acquisitionFilePropertyId).ToList();

Check warning on line 88 in source/backend/dal/Repositories/TakeRepository.cs

View check run for this annotation

Codecov / codecov/patch

source/backend/dal/Repositories/TakeRepository.cs#L88

Added line #L88 was not covered by tests
}
}
}
Loading
Loading