-
Notifications
You must be signed in to change notification settings - Fork 24
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-8771 & psp-8683 | Lease expiry using renewal information #4189
Changes from all commits
b35e35a
6f63c4a
a064465
28f4fe4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,19 +11,19 @@ public class LeaseMap : IRegister | |
{ | ||
public void Register(TypeAdapterConfig config) | ||
{ | ||
config.NewConfig<(Entity.PimsLeasePeriod period, Entity.PimsLease lease, Entity.PimsPropertyLease property, Entity.PimsLeaseTenant tenant), Model.LeaseModel>() | ||
config.NewConfig<(Entity.PimsLeasePeriod period, Entity.PimsLease lease, Entity.PimsPropertyLease property, Entity.PimsLeaseTenant tenant, DateTime? expiryDate), Model.LeaseModel>() | ||
.AfterMapping((src, dest) => | ||
{ | ||
MapLease(src, dest); | ||
}); | ||
} | ||
|
||
private static void MapLease((Entity.PimsLeasePeriod period, Entity.PimsLease lease, Entity.PimsPropertyLease property, Entity.PimsLeaseTenant tenant) src, Model.LeaseModel dest) | ||
private static void MapLease((Entity.PimsLeasePeriod period, Entity.PimsLease lease, Entity.PimsPropertyLease property, Entity.PimsLeaseTenant tenant, DateTime? expiryDate) src, Model.LeaseModel dest) | ||
{ | ||
dest.LFileNo = src.lease.LFileNo; | ||
dest.MotiRegion = src.lease.RegionCodeNavigation?.RegionName; | ||
dest.StartDate = src.lease.OrigStartDate.FilterSqlMinDate().ToNullableDateOnly(); | ||
dest.EndDate = src.lease.OrigExpiryDate?.FilterSqlMinDate().ToNullableDateOnly(); | ||
dest.EndDate = src.expiryDate.ToNullableDateOnly(); | ||
dest.CurrentPeriodStartDate = src.lease.GetCurrentPeriodStartDate()?.FilterSqlMinDate().ToNullableDateOnly(); | ||
dest.CurrentTermEndDate = src.lease.GetCurrentPeriodEndDate()?.FilterSqlMinDate().ToNullableDateOnly(); | ||
dest.ProgramName = src.lease.LeaseProgramTypeCodeNavigation?.GetTypeDescriptionOther(src.lease.OtherLeaseProgramType); | ||
|
@@ -36,7 +36,7 @@ private static void MapLease((Entity.PimsLeasePeriod period, Entity.PimsLease le | |
dest.InspectionNotes = src.lease.InspectionNotes; | ||
dest.InspectionDate = src.lease.InspectionDate?.FilterSqlMinDate(); | ||
dest.LeaseNotes = src.lease.LeaseNotes; | ||
dest.IsExpired = (src.lease.GetExpiryDate() < DateTime.Now).BoolToYesNo(); | ||
dest.IsExpired = (src.expiryDate < DateTime.Now).BoolToYesNo(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to include renewals in this calculation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100%. I dont think this field is actually used in the frontend. But I will clean it up as tech debt |
||
dest.LeaseAmount = src.period?.PaymentAmount; | ||
dest.PeriodStartDate = src.period?.PeriodStartDate.FilterSqlMinDate().ToNullableDateOnly(); | ||
dest.PeriodExpiryDate = src.period?.PeriodExpiryDate?.FilterSqlMinDate().ToNullableDateOnly(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import moment from 'moment'; | ||
|
||
import { ApiGen_Concepts_Lease } from '@/models/api/generated/ApiGen_Concepts_Lease'; | ||
import { ApiGen_Concepts_LeaseRenewal } from '@/models/api/generated/ApiGen_Concepts_LeaseRenewal'; | ||
import { ApiGen_Concepts_LeaseTenant } from '@/models/api/generated/ApiGen_Concepts_LeaseTenant'; | ||
import { isValidId } from '@/utils'; | ||
import { formatNames } from '@/utils/personUtils'; | ||
|
@@ -16,6 +20,21 @@ export const getAllNames = (tenants: ApiGen_Concepts_LeaseTenant[]): string[] => | |
return allNames; | ||
}; | ||
|
||
export const getCalculatedExpiry = ( | ||
lease: ApiGen_Concepts_Lease, | ||
renewals: ApiGen_Concepts_LeaseRenewal[], | ||
): string => { | ||
const excercisedRenewalDates = renewals.filter(r => r.isExercised).flatMap(fr => fr.expiryDt); | ||
|
||
let calculatedExpiry: string | null = lease?.expiryDate ?? ''; | ||
for (let i = 0; i < excercisedRenewalDates.length; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could also do with a sort? this seems fine though. |
||
if (moment(excercisedRenewalDates[i]).isAfter(calculatedExpiry)) { | ||
calculatedExpiry = excercisedRenewalDates[i]; | ||
} | ||
} | ||
return calculatedExpiry; | ||
}; | ||
|
||
export const getSuggestedFee = (isPublicBenefit: boolean, isFinancialGain: boolean): string => { | ||
if (isPublicBenefit == null || isFinancialGain == null) return 'Unknown'; | ||
else if (isPublicBenefit && isFinancialGain) return 'Licence Administration Fee (LAF) *'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to filter the sql min date here? previously this would cause exceptions converting from an sql min date to a date time.