Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into release/uat_is92
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Nov 6, 2024
2 parents d18d511 + 3e7a254 commit cf116f2
Show file tree
Hide file tree
Showing 555 changed files with 111,723 additions and 13,779 deletions.
2,615 changes: 2,615 additions & 0 deletions etl/PAT_PIMS_DOCUMENT_IMPORT/PAT_PIMS_DOCUMENT_IMPORT/DOCUMENT_IMPORT.dtsx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<DataTransformationsUserConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Configurations>
<Configuration>
<Name>Development</Name>
<Options>
<AssessmentRuleSuppressionSetting />
<UseWinAuth>false</UseWinAuth>
<WinAuthUserName />
<WinAuthDomain />
<UserIDs />
<UserPasswords />
<OfflineMode>false</OfflineMode>
<ProgressReporting>true</ProgressReporting>
<ParameterConfigurationSensitiveValues>
<ConfigurationSetting>
<Id>LastModifiedTime</Id>
<Name>LastModifiedTime</Name>
<Value xsi:type="xsd:dateTime">2024-10-11T23:15:29.0697001Z</Value>
</ConfigurationSetting>
</ParameterConfigurationSensitiveValues>
</Options>
</Configuration>
</Configurations>
</DataTransformationsUserConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33027.164
MinimumVisualStudioVersion = 10.0.40219.1
Project("{C9674DCB-5085-4A16-B785-4C70DD1589BD}") = "PAT_PIMS_DOCUMENT_IMPORT", "PAT_PIMS_DOCUMENT_IMPORT.dtproj", "{8D688065-BC77-4671-BF5F-057201FBF3F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Development|Default = Development|Default
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D688065-BC77-4671-BF5F-057201FBF3F4}.Development|Default.ActiveCfg = Development
{8D688065-BC77-4671-BF5F-057201FBF3F4}.Development|Default.Build.0 = Development
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A0AAEAFE-BC23-413A-AC3B-8C50D579C4D3}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0"?>
<SSIS:Parameters xmlns:SSIS="www.microsoft.com/SqlServer/SSIS" />
2 changes: 2 additions & 0 deletions source/backend/api/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public IActionResult GetAll()
var leaseChecklistSectionTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllLeaseChecklistSectionTypes());
var leasePaymentCategoryTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllLeasePaymentCategoryTypes());
var consultationOutcomeTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllConsultationOutcomeTypes());
var subfileInterestTypes = _mapper.Map<Model.LookupModel[]>(_lookupRepository.GetAllSubfileInterestTypes());

var codes = new List<object>();
codes.AddRange(areaUnitTypes);
Expand Down Expand Up @@ -207,6 +208,7 @@ public IActionResult GetAll()
codes.AddRange(leaseChecklistSectionTypes);
codes.AddRange(leasePaymentCategoryTypes);
codes.AddRange(consultationOutcomeTypes);
codes.AddRange(subfileInterestTypes);

var response = new JsonResult(codes);

Expand Down
6 changes: 3 additions & 3 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.6.0-91.23</Version>
<Version>5.6.0-91.23</Version>
<AssemblyVersion>5.6.0.91</AssemblyVersion>
<Version>5.6.0-92.30</Version>
<Version>5.6.0-92.30</Version>
<AssemblyVersion>5.6.0.92</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>16BC0468-78F6-4C91-87DA-7403C919E646</ProjectGuid>
<TargetFramework>net8.0</TargetFramework>
Expand Down
22 changes: 18 additions & 4 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ public PimsAcquisitionFile Update(PimsAcquisitionFile acquisitionFile, IEnumerab
ValidateMinistryRegion(acquisitionFile.Internal_Id, acquisitionFile.RegionCode);
}

if (!userOverrides.Contains(UserOverrideCode.UpdateSubFilesProjectProduct))
{
ValidateSubFileDependency(acquisitionFile);
}

ValidateStaff(acquisitionFile);
ValidateOrganizationStaff(acquisitionFile);

Expand Down Expand Up @@ -567,7 +572,7 @@ public PimsExpropriationPayment AddExpropriationPayment(long acquisitionFileId,
public IList<PimsExpropriationPayment> GetAcquisitionExpropriationPayments(long acquisitionFileId)
{

_logger.LogInformation("Getting Expropiation Payments for acquisition file id: {acquisitionFileId}", acquisitionFileId);
_logger.LogInformation("Getting Expropriation Payments for acquisition file id: {acquisitionFileId}", acquisitionFileId);
_user.ThrowIfNotAuthorized(Permissions.AcquisitionFileView);
_user.ThrowInvalidAccessToAcquisitionFile(_userRepository, _acqFileRepository, acquisitionFileId);

Expand All @@ -576,14 +581,14 @@ public IList<PimsExpropriationPayment> GetAcquisitionExpropriationPayments(long

public List<PimsAcquisitionFile> GetAcquisitionSubFiles(long id)
{
_logger.LogInformation("Fetch acquistion sub-files for fileId: {id}", id);
_logger.LogInformation("Fetch acquisition sub-files for file id: {id}", id);
_user.ThrowIfNotAuthorized(Permissions.AcquisitionFileView);
_user.ThrowInvalidAccessToAcquisitionFile(_userRepository, _acqFileRepository, id);

var currentAcquisitionFile = GetById(id);
if(currentAcquisitionFile.PrntAcquisitionFileId is not null)
if (currentAcquisitionFile.PrntAcquisitionFileId is not null)
{
throw new BadRequestException("Acquistion file should not be a sub-file.");
throw new BadRequestException("Acquisition file should not be a sub-file.");
}

// Limit search results to user's assigned region(s)
Expand Down Expand Up @@ -699,6 +704,15 @@ private void ValidateMinistryRegion(long acqFileId, short updatedRegion)
}
}

private void ValidateSubFileDependency(PimsAcquisitionFile incomingFile)
{
var currentAcquisitionFile = _acqFileRepository.GetById(incomingFile.Internal_Id);
if (currentAcquisitionFile.ProjectId != incomingFile.ProjectId || currentAcquisitionFile.ProductId != incomingFile.ProductId)
{
throw new UserOverrideException(UserOverrideCode.UpdateSubFilesProjectProduct, "This change will be reflected on other related entities - generated documents, sub-files, etc.\n\nDo you want to proceed?");
}
}

private void ValidateDraftsOnComplete(PimsAcquisitionFile incomingFile)
{
var agreements = _agreementRepository.GetAgreementsByAcquisitionFile(incomingFile.AcquisitionFileId);
Expand Down
35 changes: 34 additions & 1 deletion source/backend/api/Services/LeaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class LeaseService : BaseService, ILeaseService
private readonly IEntityNoteRepository _entityNoteRepository;
private readonly IInsuranceRepository _insuranceRepository;
private readonly ILeaseStakeholderRepository _stakeholderRepository;
private readonly ICompensationRequisitionRepository _compensationRequisitionRepository;
private readonly ILeaseRenewalRepository _renewalRepository;
private readonly IConsultationRepository _consultationRepository;
private readonly IUserRepository _userRepository;
Expand All @@ -42,13 +43,13 @@ public LeaseService(
ClaimsPrincipal user,
ILogger<LeaseService> logger,
ILeaseRepository leaseRepository,
ICoordinateTransformService coordinateTransformService,
IPropertyRepository propertyRepository,
IPropertyLeaseRepository propertyLeaseRepository,
IPropertyImprovementRepository propertyImprovementRepository,
IEntityNoteRepository entityNoteRepository,
IInsuranceRepository insuranceRepository,
ILeaseStakeholderRepository stakeholderRepository,
ICompensationRequisitionRepository compensationRequisitionRepository,
ILeaseRenewalRepository renewalRepository,
IConsultationRepository consultationRepository,
IUserRepository userRepository,
Expand All @@ -66,6 +67,7 @@ public LeaseService(
_propertyImprovementRepository = propertyImprovementRepository;
_insuranceRepository = insuranceRepository;
_stakeholderRepository = stakeholderRepository;
_compensationRequisitionRepository = compensationRequisitionRepository;
_renewalRepository = renewalRepository;
_consultationRepository = consultationRepository;
_userRepository = userRepository;
Expand Down Expand Up @@ -180,6 +182,7 @@ public IEnumerable<PimsLeaseStakeholder> UpdateStakeholdersByLeaseId(long leaseI
var pimsUser = _userRepository.GetByKeycloakUserId(_user.GetUserKey());
pimsUser.ThrowInvalidAccessToLeaseFile(_leaseRepository.GetNoTracking(leaseId).RegionCode);

ValidateStakeholdersDependency(leaseId, pimsLeaseStakeholders);
_stakeholderRepository.Update(leaseId, pimsLeaseStakeholders);
_stakeholderRepository.CommitTransaction();

Expand Down Expand Up @@ -667,5 +670,35 @@ private void AppendNewItemsToChecklist(PimsLease lease, ref List<PimsLeaseCheckl
}
}
}

private void ValidateStakeholdersDependency(long leaseId, IEnumerable<PimsLeaseStakeholder> stakeholders)
{
var currentLease = _leaseRepository.GetNoTracking(leaseId);
var compensationRequisitions = _compensationRequisitionRepository.GetAllByLeaseFileId(leaseId);

if (compensationRequisitions.Count == 0)
{
return;
}

foreach (var compReq in compensationRequisitions)
{
var leaseStakeholderCompensationRequisitions = compReq.PimsLeaseStakeholderCompReqs;
if (leaseStakeholderCompensationRequisitions is null || leaseStakeholderCompensationRequisitions.Count == 0)
{
continue;
}

// Check for lease stakeholders
foreach (var leaseStakeholderCompReq in leaseStakeholderCompensationRequisitions)
{
if (!stakeholders.Any(x => x.Internal_Id.Equals(leaseStakeholderCompReq.LeaseStakeholderId))
&& currentLease.PimsLeaseStakeholders.Any(x => x.Internal_Id.Equals(leaseStakeholderCompReq.LeaseStakeholderId)))
{
throw new ForeignKeyDependencyException("Lease File Stakeholder can not be removed since it's assigned as a payee for a compensation requisition");
}
}
}
}
}
}
39 changes: 39 additions & 0 deletions source/backend/apimodels/CodeTypes/SubfileInterestTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Pims.Api.Models.CodeTypes
{
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum SubfileInterestTypes
{
[EnumMember(Value = "EASEMENT")]
EASEMENT,

[EnumMember(Value = "LICOCCUPY")]
LICOCCUPY,

[EnumMember(Value = "LIEN")]
LIEN,

[EnumMember(Value = "MORTGAGE")]
MORTGAGE,

[EnumMember(Value = "OTHER")]
OTHER,

[EnumMember(Value = "SRWUTILITY")]
SRWUTILITY,

[EnumMember(Value = "STRATALOT")]
STRATALOT,

[EnumMember(Value = "SUBTENANT")]
SUBTENANT,

[EnumMember(Value = "TENANT")]
TENANT,

[EnumMember(Value = "XINGPERMIT")]
XINGPERMIT,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.FundingOther, src => src.FundingOther)
.Map(dest => dest.AssignedDate, src => src.AssignedDate)
.Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateOnly())
.Map(dest => dest.EstimatedCompletionDate, src => src.EstCompletionDt.ToNullableDateOnly())
.Map(dest => dest.PossessionDate, src => src.PossessionDt.ToNullableDateOnly())
.Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation)
.Map(dest => dest.FileStatusTypeCode, src => src.AcquisitionFileStatusTypeCodeNavigation)
.Map(dest => dest.AcquisitionPhysFileStatusTypeCode, src => src.AcqPhysFileStatusTypeCodeNavigation)
.Map(dest => dest.AcquisitionTypeCode, src => src.AcquisitionTypeCodeNavigation)
.Map(dest => dest.RegionCode, src => src.RegionCodeNavigation)
.Map(dest => dest.SubfileInterestTypeCode, src => src.SubfileInterestTypeCodeNavigation)
.Map(dest => dest.OtherSubfileInterestType, src => src.OtherSubfileInterestType)
.Map(dest => dest.FileProperties, src => src.PimsPropertyAcquisitionFiles)
.Map(dest => dest.AcquisitionTeam, src => src.PimsAcquisitionFileTeams)
.Map(dest => dest.AcquisitionFileOwners, src => src.PimsAcquisitionOwners)
Expand All @@ -46,7 +50,7 @@ public void Register(TypeAdapterConfig config)
config.NewConfig<AcquisitionFileModel, PimsAcquisitionFile>()
.PreserveReference(true)
.Map(dest => dest.AcquisitionFileId, src => src.Id)
.Map(dest => dest.PrntAcquisitionFile, src => src.ParentAcquisitionFileId)
.Map(dest => dest.PrntAcquisitionFileId, src => src.ParentAcquisitionFileId)
.Map(dest => dest.FileNo, src => src.FileNo)
.Map(dest => dest.FileNumber, src => src.FileNumber)
.Map(dest => dest.FileName, src => src.FileName)
Expand All @@ -57,11 +61,15 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.FundingOther, src => src.FundingOther)
.Map(dest => dest.AssignedDate, src => src.AssignedDate)
.Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateTime())
.Map(dest => dest.EstCompletionDt, src => src.EstimatedCompletionDate.ToNullableDateTime())
.Map(dest => dest.PossessionDt, src => src.PossessionDate.ToNullableDateTime())
.Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation)
.Map(dest => dest.AcquisitionFileStatusTypeCode, src => src.FileStatusTypeCode.Id)
.Map(dest => dest.AcqPhysFileStatusTypeCode, src => src.AcquisitionPhysFileStatusTypeCode.Id)
.Map(dest => dest.AcquisitionTypeCode, src => src.AcquisitionTypeCode.Id)
.Map(dest => dest.RegionCode, src => src.RegionCode.Id)
.Map(dest => dest.SubfileInterestTypeCode, src => src.SubfileInterestTypeCode.Id)
.Map(dest => dest.OtherSubfileInterestType, src => src.OtherSubfileInterestType)
.Map(dest => dest.PimsPropertyAcquisitionFiles, src => src.FileProperties.ToImmutableList())
.Map(dest => dest.PimsAcquisitionFileTeams, src => src.AcquisitionTeam)
.Map(dest => dest.PimsAcquisitionOwners, src => src.AcquisitionFileOwners)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public class AcquisitionFileModel : FileWithChecklistModel
/// </summary>
public DateOnly? DeliveryDate { get; set; }

/// <summary>
/// Estimated date by which the acquisition would be completed.
/// </summary>
public DateOnly? EstimatedCompletionDate { get; set; }

/// <summary>
/// Date of possession following acquisition completion.
/// </summary>
public DateOnly? PossessionDate { get; set; }

/// <summary>
/// get/set - The acquisition physical file status type.
/// </summary>
Expand Down Expand Up @@ -88,6 +98,16 @@ public class AcquisitionFileModel : FileWithChecklistModel
/// </summary>
public CodeTypeModel<short> RegionCode { get; set; }

/// <summary>
/// get/set - The SubfileInterestTypeCode that this acquisition file falls under.
/// </summary>
public CodeTypeModel<string> SubfileInterestTypeCode { get; set; }

/// <summary>
/// get/set - Description wheb 'Other' SubfileInterestTypeCode.
/// </summary>
public string OtherSubfileInterestType { get; set; }

/// <summary>
/// get/set - List of Legacy Stakeholders.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions source/backend/dal/Exceptions/OverrideExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public static UserOverrideCode DeleteTakeActiveDisposition
get { return new UserOverrideCode("DELETE_TAKE_ACTIVE_DISPOSITION"); }
}

public static UserOverrideCode UpdateSubFilesProjectProduct
{
get { return new UserOverrideCode("UPDATE_SUBFILES_PROJECT_PRODUCT"); }
}

public string Code { get; private set; }

private static List<UserOverrideCode> UserOverrideCodes => new List<UserOverrideCode>()
Expand All @@ -81,6 +86,7 @@ public static UserOverrideCode DeleteTakeActiveDisposition
UserOverrideCode.DeleteCompletedTake,
UserOverrideCode.DeleteLastTake,
UserOverrideCode.DeleteTakeActiveDisposition,
UserOverrideCode.UpdateSubFilesProjectProduct,
};

private UserOverrideCode(string code)
Expand Down
31 changes: 31 additions & 0 deletions source/backend/dal/Helpers/Extensions/AcquisitionFileExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Pims.Dal.Entities;

namespace Pims.Dal.Helpers.Extensions
{
public static class AcquisitionFileExtensions
{
/// <summary>
/// Returns the suffix portion of the supplied Acquisition File Number.
/// </summary>
/// <param name="pimsAcquisitionFile">The Acquisition File entity.</param>
/// <returns>The file number suffix (e.g. "1", "2", "3", etc) if it is found, or -1 if it is not.</returns>
public static int GetAcquisitionNumberSuffix(this PimsAcquisitionFile pimsAcquisitionFile)
{
if (pimsAcquisitionFile is null)
{
return -1;
}

int lastIndex = pimsAcquisitionFile.FileNumber.LastIndexOf('-');
if (lastIndex >= 0 && lastIndex < pimsAcquisitionFile.FileNumber.Length - 1)
{
string suffix = pimsAcquisitionFile.FileNumber.Substring(lastIndex + 1);
return int.TryParse(suffix, out int number) ? number : -1;
}
else
{
return -1;
}
}
}
}
Loading

0 comments on commit cf116f2

Please sign in to comment.