Skip to content

Commit

Permalink
Lease purpose fixes (#4242)
Browse files Browse the repository at this point in the history
Co-authored-by: Herrera <eduardo.herrera@quartech.com>
  • Loading branch information
eddherrera and Herrera committed Aug 2, 2024
1 parent d04c5d0 commit 702fc30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion source/backend/dal/Repositories/LeasePaymentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public IEnumerable<PimsLeasePayment> GetAllTracking(DateTime startDate, DateTime
.ThenInclude(t => t.LeaseProgramTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
//.ThenInclude(t => t.LeasePurposeTypeCodeNavigation) TODO: fix mappings
.ThenInclude(p => p.PimsLeaseLeasePurposes)
.ThenInclude(c => c.LeasePurposeTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.LeasePeriodStatusTypeCodeNavigation)
.Include(p => p.LeasePeriod)
Expand Down
13 changes: 5 additions & 8 deletions source/backend/tests/core/Entities/LeaseHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml.Office2010.Excel;
using Pims.Dal;
using Pims.Dal.Entities;
using Entity = Pims.Dal.Entities;
Expand All @@ -16,7 +18,7 @@ public static partial class EntityHelper
/// </summary>
/// <returns></returns>
public static Entity.PimsLease CreateLease(int pid, string lFileNo = null, string stakeholderFirstName = null, string stakeholderLastName = null, string motiFirstName = null, string motiLastName = null, PimsAddress address = null, bool addStakeholder = false, bool addProperty = true,
PimsLeaseProgramType pimsLeaseProgramType = null, PimsLeasePurposeType pimsLeasePurposeType = null, PimsLeaseStatusType pimsLeaseStatusType = null, PimsLeasePayRvblType pimsLeasePayRvblType = null, PimsLeaseInitiatorType pimsLeaseInitiatorType = null, PimsLeaseResponsibilityType pimsLeaseResponsibilityType = null, PimsLeaseLicenseType pimsLeaseLicenseType = null, PimsRegion region = null)
PimsLeaseProgramType pimsLeaseProgramType = null, PimsLeaseStatusType pimsLeaseStatusType = null, PimsLeasePayRvblType pimsLeasePayRvblType = null, PimsLeaseInitiatorType pimsLeaseInitiatorType = null, PimsLeaseResponsibilityType pimsLeaseResponsibilityType = null, PimsLeaseLicenseType pimsLeaseLicenseType = null, PimsRegion region = null)
{
var lease = new Entity.PimsLease()
{
Expand All @@ -38,13 +40,10 @@ public static Entity.PimsLease CreateLease(int pid, string lFileNo = null, strin
}
lease.MotiContact = $"{motiFirstName} {motiLastName}";
lease.LeaseProgramTypeCodeNavigation = pimsLeaseProgramType ?? new Entity.PimsLeaseProgramType() { Id = "testProgramType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
//lease.LeaseProgramTypeCode = "testProgramType"; TODO: Fix Mappings
//lease.LeasePurposeTypeCodeNavigation = pimsLeasePurposeType ?? new Entity.PimsLeasePurposeType() { Id = "testPurposeType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
//lease.LeasePurposeTypeCode = "testPurposeType";
lease.LeaseProgramTypeCode = "testProgramType";
lease.LeaseStatusTypeCode = "testStatusType";
lease.LeaseStatusTypeCodeNavigation = pimsLeaseStatusType ?? new Entity.PimsLeaseStatusType() { Id = "testStatusType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
lease.LeasePayRvblTypeCodeNavigation = pimsLeasePayRvblType ?? new Entity.PimsLeasePayRvblType() { Id = "testRvblType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
//lease.LeaseCategoryTypeCodeNavigation = pimsLeaseCategoryType ?? new Entity.PimsLeaseCategoryType() { Id = "testCategoryType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
lease.LeaseInitiatorTypeCodeNavigation = pimsLeaseInitiatorType ?? new Entity.PimsLeaseInitiatorType() { Id = "testInitiatorType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
lease.LeaseResponsibilityTypeCodeNavigation = pimsLeaseResponsibilityType ?? new Entity.PimsLeaseResponsibilityType() { Id = "testResponsibilityType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
lease.LeaseLicenseTypeCodeNavigation = pimsLeaseLicenseType ?? new Entity.PimsLeaseLicenseType() { Id = "testType", DbCreateUserid = "test", DbLastUpdateUserid = "test", Description = "desc" };
Expand All @@ -69,13 +68,11 @@ public static Entity.PimsLease CreateLease(this PimsContext context, int pid, st
var leasePurposeType = context.PimsLeasePurposeTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease purpose type.");
var leaseStatusType = context.PimsLeaseStatusTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease status type.");
var leasePayRvblType = context.PimsLeasePayRvblTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease rvbl type.");
//var leaseCategoryType = context.PimsLeaseCategoryTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease category type.");
// TODO: Fix Mappings
var leaseInitiatorType = context.PimsLeaseInitiatorTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease initiator type.");
var leaseResponsibilityType = context.PimsLeaseResponsibilityTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease reponsibility type.");
var leaseLicenseType = context.PimsLeaseLicenseTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease license type.");

var lease = EntityHelper.CreateLease(pid, lFileNo, stakeholderFirstName, stakeholderLastName, motiFirstName, motiLastName, address, addStakeholder, addProperty, programType, leasePurposeType, leaseStatusType, leasePayRvblType, leaseInitiatorType, leaseResponsibilityType, leaseLicenseType);
var lease = CreateLease(pid, lFileNo, stakeholderFirstName, stakeholderLastName, motiFirstName, motiLastName, address, addStakeholder, addProperty, programType, leaseStatusType, leasePayRvblType, leaseInitiatorType, leaseResponsibilityType, leaseLicenseType);
context.PimsLeases.Add(lease);
return lease;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,15 @@ public void GetMatchingIds_LeasePurpose_Success()
// Arrange
var repository = CreateRepositoryWithPermissions(Permissions.PropertyView);
var property = EntityHelper.CreateProperty(100, isCoreInventory: true);
var lease = EntityHelper.CreateLease(1, pimsLeasePurposeType: new PimsLeasePurposeType() { Id = "test", Description = "Active", DbCreateUserid = "test", DbLastUpdateUserid = "test" }, addProperty: false);
var lease = EntityHelper.CreateLease(1, addProperty: false);

lease.PimsLeaseLeasePurposes.Add(new PimsLeaseLeasePurpose()
{
LeaseLeasePurposeId = 100,
LeaseId = lease.LeaseId,
LeasePurposeTypeCode = "test",
});

property.PimsPropertyLeases.Add(new PimsPropertyLease() { PropertyId = property.Internal_Id, LeaseId = lease.Internal_Id, Lease = lease });
_helper.AddAndSaveChanges(property);

Expand Down

0 comments on commit 702fc30

Please sign in to comment.