diff --git a/source/backend/api/Models/Report/LeasePaymentReportMap.cs b/source/backend/api/Models/Report/LeasePaymentReportMap.cs index b7a8105a23..129e16d178 100644 --- a/source/backend/api/Models/Report/LeasePaymentReportMap.cs +++ b/source/backend/api/Models/Report/LeasePaymentReportMap.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using System.Linq; using Mapster; using Pims.Api.Services; @@ -15,8 +17,7 @@ public void Register(TypeAdapterConfig config) config.NewConfig() .Map(dest => dest.Region, src => src.LeasePeriod.Lease.RegionCodeNavigation != null ? src.LeasePeriod.Lease.RegionCodeNavigation.Description : string.Empty) .Map(dest => dest.LFileNumber, src => src.LeasePeriod.Lease.LFileNo) - .Map(dest => dest.LisNumber, src => src.LeasePeriod.Lease.TfaFileNumber) - .Map(dest => dest.PsFileNumber, src => src.LeasePeriod.Lease.PsFileNo) + .Map(dest => dest.HistoricalFiles, src => GetHistoricalFileNumbers(src.LeasePeriod.Lease)) .Map(dest => dest.LeaseStatus, src => src.LeasePeriod.Lease.LeaseStatusTypeCodeNavigation.Description) .Map(dest => dest.PropertyList, src => string.Join(",", src.LeasePeriod.Lease.PimsPropertyLeases.Select(x => GetFallbackPropertyIdentifier(x)))) .Map(dest => dest.TenantList, src => string.Join(",", src.LeasePeriod.Lease.PimsLeaseTenants.Where(t => t != null && t.TenantTypeCode == "TEN").Select(x => x != null && x.Person != null ? x.Person.GetFullName(false) : x != null && x.Organization != null ? x.Organization.OrganizationName : string.Empty))) @@ -28,6 +29,8 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.IsPeriodExercised, src => src.LeasePeriod.LeasePeriodStatusTypeCode == "EXER" ? "Yes" : "No") .Map(dest => dest.PaymentFrequency, src => src.LeasePeriod.LeasePmtFreqTypeCodeNavigation != null ? src.LeasePeriod.LeasePmtFreqTypeCodeNavigation.Description : string.Empty) .Map(dest => dest.PaymentDueString, src => src.LeasePeriod.PaymentDueDate) + .Map(dest => dest.PaymentType, src => src.LeasePeriod.IsVariablePayment ? "Variable" : "Predeterminded") + .Map(dest => dest.RentCategory, src => src.LeasePaymentCategoryTypeCodeNavigation.Description) .Map(dest => dest.ExpectedPayment, src => src.LeasePeriod.PaymentAmount) .Map(dest => dest.PaymentTotal, src => src.PaymentAmountTotal) .Map(dest => dest.PaymentStatus, src => src.LeasePaymentStatusTypeCodeNavigation != null ? src.LeasePaymentStatusTypeCodeNavigation.Description : LeasePaymentService.GetPaymentStatus(src, src.LeasePeriod)) @@ -67,5 +70,29 @@ private static string GetFallbackPropertyIdentifier(PimsPropertyLease propertyLe return "No Property Identifier"; } } + + private static string GetHistoricalFileNumbers(PimsLease lease) + { + var properties = lease.PimsPropertyLeases.Select(pl => pl.Property).Where(p => p != null); + var historicalDictionary = new Dictionary(); + foreach (var property in properties) + { + foreach (var historical in property.PimsHistoricalFileNumbers) + { + var historicalType = historical.HistoricalFileNumberTypeCodeNavigation.Description; + if (historical.HistoricalFileNumberTypeCodeNavigation.HistoricalFileNumberTypeCode == "OTHER") + { + historicalType = historical.OtherHistFileNumberTypeCode; + } + + var identifier = $"{historicalType}: {historical.HistoricalFileNumber}"; + historicalDictionary[identifier] = historical.HistoricalFileNumberTypeCodeNavigation; + } + } + + var historicalList = historicalDictionary.ToList(); + historicalList.Sort((a, b) => a.Value.DisplayOrder.GetValueOrDefault() - b.Value.DisplayOrder.GetValueOrDefault()); + return string.Join("; ", historicalList.Select(a => a.Key)); + } } } diff --git a/source/backend/api/Models/Report/LeasePaymentReportModel.cs b/source/backend/api/Models/Report/LeasePaymentReportModel.cs index 47d3361e6c..b6ec9b284d 100644 --- a/source/backend/api/Models/Report/LeasePaymentReportModel.cs +++ b/source/backend/api/Models/Report/LeasePaymentReportModel.cs @@ -17,31 +17,20 @@ public class LeasePaymentReportModel /// /// get/set - PIMS L File Number. /// - /// [DisplayName("L-File Number")] [CsvHelper.Configuration.Attributes.Name("L-File Number")] public string LFileNumber { get; set; } /// - /// get/set - legacy lis number. + /// get/set - The set of historical files numbers as a contatenated string. /// - /// - [DisplayName("LIS number")] - [CsvHelper.Configuration.Attributes.Name("LIS number")] - public string LisNumber { get; set; } - - /// - /// get/set - legacy ps file name. - /// - /// - [DisplayName("PS File number")] - [CsvHelper.Configuration.Attributes.Name("PS File number")] - public string PsFileNumber { get; set; } + [DisplayName("Historical files")] + [CsvHelper.Configuration.Attributes.Name("Historical files")] + public string HistoricalFiles { get; set; } /// /// get/set - Lease status description. /// - /// [DisplayName("Lease status")] [CsvHelper.Configuration.Attributes.Name("Lease status")] public string LeaseStatus { get; set; } @@ -49,7 +38,6 @@ public class LeasePaymentReportModel /// /// get/set - The value of the program name. /// - /// [DisplayName("Properties")] [CsvHelper.Configuration.Attributes.Name("Properties")] public string PropertyList { get; set; } @@ -57,7 +45,6 @@ public class LeasePaymentReportModel /// /// get/set - Tenant list, separated by commas. Only display if type is "tenant". /// - /// [DisplayName("Tenant(s)")] [CsvHelper.Configuration.Attributes.Name("Tenant(s)")] public string TenantList { get; set; } @@ -65,7 +52,6 @@ public class LeasePaymentReportModel /// /// get/set - Either Payable or Receivable. /// - /// [DisplayName("Payable/Receivable")] [CsvHelper.Configuration.Attributes.Name("Payable/Receivable")] public string PayableOrReceivable { get; set; } @@ -83,7 +69,6 @@ public class LeasePaymentReportModel /// /// get/set - Start date of the period parent for this lease. /// - /// [DisplayName("Period start")] [CsvHelper.Configuration.Attributes.Name("Period start")] public string PeriodStart { get; set; } @@ -91,7 +76,6 @@ public class LeasePaymentReportModel /// /// get/set - Expiry date of the period parent for this lease. /// - /// [DisplayName("Period expiry")] [CsvHelper.Configuration.Attributes.Name("Period expiry")] public string PeriodExpiry { get; set; } @@ -99,7 +83,6 @@ public class LeasePaymentReportModel /// /// get/set - Whether or not this period is exercised (Yes/No). /// - /// [DisplayName("Period exercised")] [CsvHelper.Configuration.Attributes.Name("Period exercised")] public string IsPeriodExercised { get; set; } @@ -107,7 +90,6 @@ public class LeasePaymentReportModel /// /// get/set - How often this payment occurs within the period. /// - /// [DisplayName("Payment frequency")] [CsvHelper.Configuration.Attributes.Name("Payment frequency")] public string PaymentFrequency { get; set; } @@ -115,15 +97,27 @@ public class LeasePaymentReportModel /// /// get/set - A text description of when the payment is due. /// - /// [DisplayName("Payment due")] [CsvHelper.Configuration.Attributes.Name("Payment due")] public string PaymentDueString { get; set; } + /// + /// get/set - The payment type + /// + [DisplayName("Payment type")] + [CsvHelper.Configuration.Attributes.Name("Payment type")] + public string PaymentType { get; set; } + + /// + /// get/set - The payment type + /// + [DisplayName("Rent category")] + [CsvHelper.Configuration.Attributes.Name("Rent category")] + public string RentCategory { get; set; } + /// /// get/set - The expected payment total, including GST. /// - /// [DisplayName("Expected payment")] [CsvHelper.Configuration.Attributes.Name("Expected payment")] public decimal ExpectedPayment { get; set; } @@ -131,7 +125,6 @@ public class LeasePaymentReportModel /// /// get/set - The actual payment total, including GST. /// - /// [DisplayName("Payment total")] [CsvHelper.Configuration.Attributes.Name("Payment total")] public decimal PaymentTotal { get; set; } @@ -139,7 +132,6 @@ public class LeasePaymentReportModel /// /// get/set - For this payment, if the payment is partial, complete, etc. /// - /// [DisplayName("Payment status")] [CsvHelper.Configuration.Attributes.Name("Payment status")] public string PaymentStatus { get; set; } @@ -147,7 +139,6 @@ public class LeasePaymentReportModel /// /// get/set - The payment amount, not including GST. /// - /// [DisplayName("Payment amount (pretax)")] [CsvHelper.Configuration.Attributes.Name("Payment amount (pretax)")] public decimal PaymentAmount { get; set; } @@ -155,7 +146,6 @@ public class LeasePaymentReportModel /// /// get/set - The GST portion of the payment. /// - /// [DisplayName("Payment GST")] [CsvHelper.Configuration.Attributes.Name("Payment GST")] public decimal PaymentGst { get; set; } @@ -163,7 +153,6 @@ public class LeasePaymentReportModel /// /// get/set - The date the payment was received. /// - /// [DisplayName("Payment received date")] [CsvHelper.Configuration.Attributes.Name("Payment received date")] public string PaymentReceivedDate { get; set; } @@ -171,7 +160,6 @@ public class LeasePaymentReportModel /// /// get/set - Most recent payment made for the file. /// - /// [DisplayName("Latest payment date")] [CsvHelper.Configuration.Attributes.Name("Latest payment date")] public string LatestPaymentDate { get; set; } diff --git a/source/backend/dal/Repositories/LeasePaymentRepository.cs b/source/backend/dal/Repositories/LeasePaymentRepository.cs index 8a6563a359..206fe92679 100644 --- a/source/backend/dal/Repositories/LeasePaymentRepository.cs +++ b/source/backend/dal/Repositories/LeasePaymentRepository.cs @@ -50,6 +50,8 @@ public IEnumerable GetAllTracking(DateTime startDate, DateTime .ThenInclude(t => t.Lease) .ThenInclude(p => p.PimsPropertyLeases) .ThenInclude(p => p.Property) + .ThenInclude(p => p.PimsHistoricalFileNumbers) + .ThenInclude(h => h.HistoricalFileNumberTypeCodeNavigation) .Include(p => p.LeasePeriod) .ThenInclude(t => t.Lease) .ThenInclude(p => p.RegionCodeNavigation)