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-8556 | Updated payments export with Historical numbers and new fields #4219

Merged
merged 6 commits into from
Jul 23, 2024
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
31 changes: 29 additions & 2 deletions source/backend/api/Models/Report/LeasePaymentReportMap.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Mapster;
using Pims.Api.Services;
Expand All @@ -15,8 +17,7 @@ public void Register(TypeAdapterConfig config)
config.NewConfig<Entity.PimsLeasePayment, LeasePaymentReportModel>()
.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)))
Expand All @@ -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))
Expand Down Expand Up @@ -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<string, PimsHistoricalFileNumberType>();
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));
}
}
}
48 changes: 18 additions & 30 deletions source/backend/api/Models/Report/LeasePaymentReportModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,41 @@ public class LeasePaymentReportModel
/// <summary>
/// get/set - PIMS L File Number.
/// </summary>
///
[DisplayName("L-File Number")]
[CsvHelper.Configuration.Attributes.Name("L-File Number")]
public string LFileNumber { get; set; }

/// <summary>
/// get/set - legacy lis number.
/// get/set - The set of historical files numbers as a contatenated string.
/// </summary>
///
[DisplayName("LIS number")]
[CsvHelper.Configuration.Attributes.Name("LIS number")]
public string LisNumber { get; set; }

/// <summary>
/// get/set - legacy ps file name.
/// </summary>
///
[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; }

/// <summary>
/// get/set - Lease status description.
/// </summary>
///
[DisplayName("Lease status")]
[CsvHelper.Configuration.Attributes.Name("Lease status")]
public string LeaseStatus { get; set; }

/// <summary>
/// get/set - The value of the program name.
/// </summary>
///
[DisplayName("Properties")]
[CsvHelper.Configuration.Attributes.Name("Properties")]
public string PropertyList { get; set; }

/// <summary>
/// get/set - Tenant list, separated by commas. Only display if type is "tenant".
/// </summary>
///
[DisplayName("Tenant(s)")]
[CsvHelper.Configuration.Attributes.Name("Tenant(s)")]
public string TenantList { get; set; }

/// <summary>
/// get/set - Either Payable or Receivable.
/// </summary>
///
[DisplayName("Payable/Receivable")]
[CsvHelper.Configuration.Attributes.Name("Payable/Receivable")]
public string PayableOrReceivable { get; set; }
Expand All @@ -83,95 +69,97 @@ public class LeasePaymentReportModel
/// <summary>
/// get/set - Start date of the period parent for this lease.
/// </summary>
///
[DisplayName("Period start")]
[CsvHelper.Configuration.Attributes.Name("Period start")]
public string PeriodStart { get; set; }

/// <summary>
/// get/set - Expiry date of the period parent for this lease.
/// </summary>
///
[DisplayName("Period expiry")]
[CsvHelper.Configuration.Attributes.Name("Period expiry")]
public string PeriodExpiry { get; set; }

/// <summary>
/// get/set - Whether or not this period is exercised (Yes/No).
/// </summary>
///
[DisplayName("Period exercised")]
[CsvHelper.Configuration.Attributes.Name("Period exercised")]
public string IsPeriodExercised { get; set; }

/// <summary>
/// get/set - How often this payment occurs within the period.
/// </summary>
///
[DisplayName("Payment frequency")]
[CsvHelper.Configuration.Attributes.Name("Payment frequency")]
public string PaymentFrequency { get; set; }

/// <summary>
/// get/set - A text description of when the payment is due.
/// </summary>
///
[DisplayName("Payment due")]
[CsvHelper.Configuration.Attributes.Name("Payment due")]
public string PaymentDueString { get; set; }

/// <summary>
/// get/set - The payment type
/// </summary>
[DisplayName("Payment type")]
[CsvHelper.Configuration.Attributes.Name("Payment type")]
public string PaymentType { get; set; }

/// <summary>
/// get/set - The payment type
/// </summary>
[DisplayName("Rent category")]
[CsvHelper.Configuration.Attributes.Name("Rent category")]
public string RentCategory { get; set; }

/// <summary>
/// get/set - The expected payment total, including GST.
/// </summary>
///
[DisplayName("Expected payment")]
[CsvHelper.Configuration.Attributes.Name("Expected payment")]
public decimal ExpectedPayment { get; set; }

/// <summary>
/// get/set - The actual payment total, including GST.
/// </summary>
///
[DisplayName("Payment total")]
[CsvHelper.Configuration.Attributes.Name("Payment total")]
public decimal PaymentTotal { get; set; }

/// <summary>
/// get/set - For this payment, if the payment is partial, complete, etc.
/// </summary>
///
[DisplayName("Payment status")]
[CsvHelper.Configuration.Attributes.Name("Payment status")]
public string PaymentStatus { get; set; }

/// <summary>
/// get/set - The payment amount, not including GST.
/// </summary>
///
[DisplayName("Payment amount (pretax)")]
[CsvHelper.Configuration.Attributes.Name("Payment amount (pretax)")]
public decimal PaymentAmount { get; set; }

/// <summary>
/// get/set - The GST portion of the payment.
/// </summary>
///
[DisplayName("Payment GST")]
[CsvHelper.Configuration.Attributes.Name("Payment GST")]
public decimal PaymentGst { get; set; }

/// <summary>
/// get/set - The date the payment was received.
/// </summary>
///
[DisplayName("Payment received date")]
[CsvHelper.Configuration.Attributes.Name("Payment received date")]
public string PaymentReceivedDate { get; set; }

/// <summary>
/// get/set - Most recent payment made for the file.
/// </summary>
///
[DisplayName("Latest payment date")]
[CsvHelper.Configuration.Attributes.Name("Latest payment date")]
public string LatestPaymentDate { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions source/backend/dal/Repositories/LeasePaymentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public IEnumerable<PimsLeasePayment> 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)
Expand Down
Loading