From d262e1a4262b8793b0c926236f1ed2ffb1700aff Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Mon, 16 Oct 2023 13:17:01 -0700 Subject: [PATCH] add date and time aliases to frontend. Add model typing to backend. frontend/backend now use typings to better reflect desired use of field (id timestamp vs dateonly). --- .../AcquisitionFile/AcquisitionFileMap.cs | 9 ++--- .../AcquisitionFile/AcquisitionFileModel.cs | 4 +-- .../Concepts/AcquisitionFile/AgreementMap.cs | 33 ++++++++++--------- .../AcquisitionFile/AgreementModel.cs | 16 ++++----- .../CompensationRequisitionMap.cs | 25 +++++++------- .../CompensationRequisitionModel.cs | 12 +++---- .../Concepts/Deposit/SecurityDepositMap.cs | 6 ++-- .../Concepts/Deposit/SecurityDepositModel.cs | 2 +- .../Deposit/SecurityDepositReturnMap.cs | 9 ++--- .../Deposit/SecurityDepositReturnModel.cs | 4 +-- .../api/Models/Concepts/Lease/LeaseMap.cs | 10 +++--- .../api/Models/Concepts/Lease/LeaseModel.cs | 6 ++-- .../api/Models/Concepts/Lease/LeaseTermMap.cs | 18 +++++----- .../Models/Concepts/Lease/LeaseTermModel.cs | 8 ++--- .../api/Models/Concepts/Lease/PaymentMap.cs | 5 +-- .../api/Models/Concepts/Lease/PaymentModel.cs | 2 +- .../api/Models/Concepts/Product/ProductMap.cs | 9 ++--- .../Models/Concepts/Product/ProductModel.cs | 4 +-- .../Property/PropertyManagementModel.cs | 2 +- .../Models/Concepts/Property/PropertyMap.cs | 6 ++-- .../Models/Concepts/Property/PropertyModel.cs | 4 +-- .../Concepts/ResearchFile/ResearchFileMap.cs | 9 ++--- .../ResearchFile/ResearchFileModel.cs | 4 +-- .../api/Models/Concepts/Take/TakeMap.cs | 9 ++--- .../api/Models/Concepts/Take/TakeModel.cs | 4 +-- .../backend/api/Services/PropertyService.cs | 2 +- source/backend/api/Startup.cs | 3 ++ .../backend/core/Extensions/DateExtensions.cs | 20 +++++++++++ .../core/Json/DateOnlyJsonConverter.cs | 20 +++++++++++ .../components/common/form/FastDatePicker.tsx | 2 -- .../list/AcquisitionSearchResults/models.ts | 5 +-- .../features/admin/access-request/models.ts | 3 +- .../admin/users/interfaces/IUserRecord.ts | 4 ++- .../src/features/admin/users/models.ts | 3 +- .../features/documents/ComposedDocument.ts | 3 +- .../DepositsReceivedContainer.test.tsx | 2 +- .../DepositsReceivedContainer/columns.tsx | 2 +- .../deposits/models/FormLeaseDeposit.ts | 4 +-- .../payment/modal/term/TermForm.tsx | 2 +- .../payment/modal/term/TermModal.test.tsx | 4 +-- .../payment/modal/term/TermsYupSchema.tsx | 2 +- .../term/__snapshots__/TermForm.test.tsx.snap | 20 +++++------ .../detail/LeasePages/payment/models.ts | 6 ++-- .../payment/table/terms/columns.tsx | 2 +- .../tabs/checklist/update/models.ts | 5 +-- .../detail/PropertyDetailsTabView.helpers.tsx | 2 +- .../detail/PropertyDetailsTabView.test.tsx | 2 +- .../UpdatePropertyDetailsContainer.test.tsx | 2 +- .../update/UpdatePropertyDetailsForm.test.tsx | 2 +- .../properties/UpdateProperties.test.tsx | 2 +- source/frontend/src/features/notes/models.ts | 5 +-- .../research/list/ResearchListView.test.tsx | 4 +-- source/frontend/src/interfaces/IProperty.ts | 3 +- source/frontend/src/interfaces/IUser.ts | 7 ++-- .../src/mocks/acquisitionFiles.mock.ts | 4 +-- source/frontend/src/mocks/deposits.mock.ts | 4 +-- source/frontend/src/mocks/properties.mock.ts | 12 +++---- .../frontend/src/mocks/researchFile.mock.ts | 2 +- .../src/models/api/AcquisitionFile.ts | 8 +++-- source/frontend/src/models/api/Agreement.ts | 20 ++++++----- source/frontend/src/models/api/AuditFields.ts | 6 ++-- .../src/models/api/CompensationRequisition.ts | 13 ++++---- source/frontend/src/models/api/DateOnly.ts | 2 ++ source/frontend/src/models/api/File.ts | 5 +-- source/frontend/src/models/api/Insurance.ts | 3 +- source/frontend/src/models/api/Lease.ts | 7 ++-- .../frontend/src/models/api/LeasePayment.ts | 3 +- source/frontend/src/models/api/LeaseTerm.ts | 9 ++--- source/frontend/src/models/api/Property.ts | 5 +-- .../frontend/src/models/api/ResearchFile.ts | 5 +-- .../src/models/api/SecurityDeposit.ts | 5 +-- source/frontend/src/models/api/Take.ts | 5 +-- .../frontend/src/models/api/UtcIsoDateTime.ts | 2 ++ .../models/generate/lease/GenerateLease.ts | 2 +- .../lookupCodes/interfaces/ILookupCode.ts | 4 ++- 75 files changed, 288 insertions(+), 201 deletions(-) create mode 100644 source/backend/core/Json/DateOnlyJsonConverter.cs create mode 100644 source/frontend/src/models/api/DateOnly.ts create mode 100644 source/frontend/src/models/api/UtcIsoDateTime.ts diff --git a/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs b/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs index a8dd4ae140..968c8ac285 100644 --- a/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs +++ b/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Pims.Dal.Helpers.Extensions; using Entity = Pims.Dal.Entities; @@ -21,8 +22,8 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.FundingTypeCode, src => src.AcquisitionFundingTypeCodeNavigation) .Map(dest => dest.FundingOther, src => src.FundingOther) .Map(dest => dest.AssignedDate, src => src.AssignedDate) - .Map(dest => dest.DeliveryDate, src => src.DeliveryDate) - .Map(dest => dest.CompletionDate, src => src.CompletionDate) + .Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateOnly()) + .Map(dest => dest.CompletionDate, src => src.CompletionDate.ToNullableDateOnly()) .Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation) .Map(dest => dest.FileStatusTypeCode, src => src.AcquisitionFileStatusTypeCodeNavigation) .Map(dest => dest.AcquisitionPhysFileStatusTypeCode, src => src.AcqPhysFileStatusTypeCodeNavigation) @@ -48,8 +49,8 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.AcquisitionFundingTypeCode, src => src.FundingTypeCode.Id) .Map(dest => dest.FundingOther, src => src.FundingOther) .Map(dest => dest.AssignedDate, src => src.AssignedDate) - .Map(dest => dest.DeliveryDate, src => src.DeliveryDate) - .Map(dest => dest.CompletionDate, src => src.CompletionDate) + .Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateTime()) + .Map(dest => dest.CompletionDate, src => src.CompletionDate.ToNullableDateTime()) .Map(dest => dest.TotalAllowableCompensation, src => src.TotalAllowableCompensation) .Map(dest => dest.AcquisitionFileStatusTypeCode, src => src.FileStatusTypeCode.Id) .Map(dest => dest.AcqPhysFileStatusTypeCode, src => src.AcquisitionPhysFileStatusTypeCode.Id) diff --git a/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs b/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs index b0cdb9882f..77f39999ba 100644 --- a/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs +++ b/source/backend/api/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs @@ -25,12 +25,12 @@ public class AcquisitionFileModel : FileModel /// /// The date for delivery of the property to the project. /// - public DateTime? DeliveryDate { get; set; } + public DateOnly? DeliveryDate { get; set; } /// /// The date of acquisition file completion. /// - public DateTime? CompletionDate { get; set; } + public DateOnly? CompletionDate { get; set; } /// /// get/set - The acquisition physical file status type. diff --git a/source/backend/api/Models/Concepts/AcquisitionFile/AgreementMap.cs b/source/backend/api/Models/Concepts/AcquisitionFile/AgreementMap.cs index 8b745c5f2d..2a35dc892e 100644 --- a/source/backend/api/Models/Concepts/AcquisitionFile/AgreementMap.cs +++ b/source/backend/api/Models/Concepts/AcquisitionFile/AgreementMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -11,40 +12,40 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.AgreementId, src => src.AgreementId) .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId) .Map(dest => dest.AgreementType, src => src.AgreementTypeCodeNavigation) - .Map(dest => dest.AgreementDate, src => src.AgreementDate) + .Map(dest => dest.AgreementDate, src => src.AgreementDate.ToNullableDateOnly()) .Map(dest => dest.IsDraft, src => src.IsDraft) - .Map(dest => dest.CompletionDate, src => src.CompletionDate) - .Map(dest => dest.TerminationDate, src => src.TerminationDate) - .Map(dest => dest.CommencementDate, src => src.CommencementDate) - .Map(dest => dest.PossessionDate, src => src.PossessionDate) + .Map(dest => dest.CompletionDate, src => src.CompletionDate.ToNullableDateOnly()) + .Map(dest => dest.TerminationDate, src => src.TerminationDate.ToNullableDateOnly()) + .Map(dest => dest.CommencementDate, src => src.CommencementDate.ToNullableDateOnly()) + .Map(dest => dest.PossessionDate, src => src.PossessionDate.ToNullableDateOnly()) .Map(dest => dest.DepositAmount, src => src.DepositAmount) .Map(dest => dest.NoLaterThanDays, src => src.NoLaterThanDays) .Map(dest => dest.PurchasePrice, src => src.PurchasePrice) .Map(dest => dest.LegalSurveyPlanNum, src => src.LegalSurveyPlanNum) - .Map(dest => dest.OfferDate, src => src.OfferDate) + .Map(dest => dest.OfferDate, src => src.OfferDate.ToNullableDateOnly()) .Map(dest => dest.ExpiryDateTime, src => src.ExpiryTs) - .Map(dest => dest.SignedDate, src => src.SignedDate) - .Map(dest => dest.InspectionDate, src => src.InspectionDate) + .Map(dest => dest.SignedDate, src => src.SignedDate.ToNullableDateOnly()) + .Map(dest => dest.InspectionDate, src => src.InspectionDate.ToNullableDateOnly()) .Inherits(); config.NewConfig() .Map(dest => dest.AgreementId, src => src.AgreementId) .Map(dest => dest.AcquisitionFileId, src => src.AcquisitionFileId) .Map(dest => dest.AgreementTypeCode, src => src.AgreementType.Id) - .Map(dest => dest.AgreementDate, src => src.AgreementDate) + .Map(dest => dest.AgreementDate, src => src.AgreementDate.ToNullableDateTime()) .Map(dest => dest.IsDraft, src => src.IsDraft) - .Map(dest => dest.CompletionDate, src => src.CompletionDate) - .Map(dest => dest.TerminationDate, src => src.TerminationDate) - .Map(dest => dest.CommencementDate, src => src.CommencementDate) - .Map(dest => dest.PossessionDate, src => src.PossessionDate) + .Map(dest => dest.CompletionDate, src => src.CompletionDate.ToNullableDateTime()) + .Map(dest => dest.TerminationDate, src => src.TerminationDate.ToNullableDateTime()) + .Map(dest => dest.CommencementDate, src => src.CommencementDate.ToNullableDateTime()) + .Map(dest => dest.PossessionDate, src => src.PossessionDate.ToNullableDateTime()) .Map(dest => dest.DepositAmount, src => src.DepositAmount) .Map(dest => dest.NoLaterThanDays, src => src.NoLaterThanDays) .Map(dest => dest.PurchasePrice, src => src.PurchasePrice) .Map(dest => dest.LegalSurveyPlanNum, src => src.LegalSurveyPlanNum) - .Map(dest => dest.OfferDate, src => src.OfferDate) + .Map(dest => dest.OfferDate, src => src.OfferDate.ToNullableDateTime()) .Map(dest => dest.ExpiryTs, src => src.ExpiryDateTime) - .Map(dest => dest.SignedDate, src => src.SignedDate) - .Map(dest => dest.InspectionDate, src => src.InspectionDate) + .Map(dest => dest.SignedDate, src => src.SignedDate.ToNullableDateTime()) + .Map(dest => dest.InspectionDate, src => src.InspectionDate.ToNullableDateTime()) .Inherits(); } } diff --git a/source/backend/api/Models/Concepts/AcquisitionFile/AgreementModel.cs b/source/backend/api/Models/Concepts/AcquisitionFile/AgreementModel.cs index 54139f32ef..a88b33097a 100644 --- a/source/backend/api/Models/Concepts/AcquisitionFile/AgreementModel.cs +++ b/source/backend/api/Models/Concepts/AcquisitionFile/AgreementModel.cs @@ -10,17 +10,17 @@ public class AgreementModel : BaseAppModel public TypeModel AgreementType { get; set; } - public DateTime? AgreementDate { get; set; } + public DateOnly? AgreementDate { get; set; } public bool? IsDraft { get; set; } - public DateTime? CompletionDate { get; set; } + public DateOnly? CompletionDate { get; set; } - public DateTime? TerminationDate { get; set; } + public DateOnly? TerminationDate { get; set; } - public DateTime? CommencementDate { get; set; } + public DateOnly? CommencementDate { get; set; } - public DateTime? PossessionDate { get; set; } + public DateOnly? PossessionDate { get; set; } public decimal? DepositAmount { get; set; } @@ -30,12 +30,12 @@ public class AgreementModel : BaseAppModel public string LegalSurveyPlanNum { get; set; } - public DateTime? OfferDate { get; set; } + public DateOnly? OfferDate { get; set; } public DateTime? ExpiryDateTime { get; set; } - public DateTime? SignedDate { get; set; } + public DateOnly? SignedDate { get; set; } - public DateTime? InspectionDate { get; set; } + public DateOnly? InspectionDate { get; set; } } } diff --git a/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs b/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs index ab70d6bf80..cf349d094b 100644 --- a/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs +++ b/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -19,11 +20,11 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.ChartOfAccounts, src => src.ChartOfAccounts) .Map(dest => dest.ResponsibilityId, src => src.ResponsibilityId) .Map(dest => dest.Responsibility, src => src.Responsibility) - .Map(dest => dest.FinalizedDate, src => src.FinalizedDate) - .Map(dest => dest.AgreementDate, src => src.AgreementDt) - .Map(dest => dest.ExpropriationNoticeServedDate, src => src.ExpropNoticeServedDt) - .Map(dest => dest.ExpropriationVestingDate, src => src.ExpropVestingDt) - .Map(dest => dest.GenerationDate, src => src.GenerationDt) + .Map(dest => dest.FinalizedDate, src => src.FinalizedDate.ToNullableDateOnly()) + .Map(dest => dest.AgreementDate, src => src.AgreementDt.ToNullableDateOnly()) + .Map(dest => dest.ExpropriationNoticeServedDate, src => src.ExpropNoticeServedDt.ToNullableDateOnly()) + .Map(dest => dest.ExpropriationVestingDate, src => src.ExpropVestingDt.ToNullableDateOnly()) + .Map(dest => dest.GenerationDate, src => src.GenerationDt.ToNullableDateOnly()) .Map(dest => dest.Financials, src => src.PimsCompReqFinancials) .Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId) .Map(dest => dest.AcquisitionOwner, src => src.AcquisitionOwner) @@ -35,7 +36,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.IsPaymentInTrust, src => src.IsPaymentInTrust) .Map(dest => dest.GstNumber, src => src.GstNumber) .Map(dest => dest.FinalizedDate, src => src.FinalizedDate) - .Map(dest => dest.AdvancedPaymentServedDate, src => src.AdvPmtServedDt) + .Map(dest => dest.AdvancedPaymentServedDate, src => src.AdvPmtServedDt.ToNullableDateOnly()) .Map(dest => dest.SpecialInstruction, src => src.SpecialInstruction) .Map(dest => dest.DetailedRemarks, src => src.DetailedRemarks) .Map(dest => dest.AlternateProjectId, src => src.AlternateProjectId) @@ -50,12 +51,12 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.YearlyFinancialId, src => src.YearlyFinancialId) .Map(dest => dest.ChartOfAccountsId, src => src.ChartOfAccountsId) .Map(dest => dest.ResponsibilityId, src => src.ResponsibilityId) - .Map(dest => dest.FinalizedDate, src => src.FinalizedDate) - .Map(dest => dest.AgreementDt, src => src.AgreementDate) - .Map(dest => dest.ExpropNoticeServedDt, src => src.ExpropriationNoticeServedDate) - .Map(dest => dest.ExpropVestingDt, src => src.ExpropriationVestingDate) - .Map(dest => dest.AdvPmtServedDt, src => src.AdvancedPaymentServedDate) - .Map(dest => dest.GenerationDt, src => src.GenerationDate) + .Map(dest => dest.FinalizedDate, src => src.FinalizedDate.ToNullableDateTime()) + .Map(dest => dest.AgreementDt, src => src.AgreementDate.ToNullableDateTime()) + .Map(dest => dest.ExpropNoticeServedDt, src => src.ExpropriationNoticeServedDate.ToNullableDateTime()) + .Map(dest => dest.ExpropVestingDt, src => src.ExpropriationVestingDate.ToNullableDateTime()) + .Map(dest => dest.AdvPmtServedDt, src => src.AdvancedPaymentServedDate.ToNullableDateTime()) + .Map(dest => dest.GenerationDt, src => src.GenerationDate.ToNullableDateTime()) .Map(dest => dest.PimsCompReqFinancials, src => src.Financials) .Map(dest => dest.AcquisitionOwnerId, src => src.AcquisitionOwnerId) .Map(dest => dest.InterestHolderId, src => src.InterestHolderId) diff --git a/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionModel.cs b/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionModel.cs index e098a61bf6..c8e2a34111 100644 --- a/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionModel.cs +++ b/source/backend/api/Models/Concepts/CompensationRequisition/CompensationRequisitionModel.cs @@ -27,17 +27,17 @@ public class CompensationRequisitionModel : BaseAppModel public FinancialCodeModel Responsibility { get; set; } - public DateTime? FinalizedDate { get; set; } + public DateOnly? FinalizedDate { get; set; } - public DateTime? AgreementDate { get; set; } + public DateOnly? AgreementDate { get; set; } - public DateTime? ExpropriationNoticeServedDate { get; set; } + public DateOnly? ExpropriationNoticeServedDate { get; set; } - public DateTime? ExpropriationVestingDate { get; set; } + public DateOnly? ExpropriationVestingDate { get; set; } - public DateTime? AdvancedPaymentServedDate { get; set; } + public DateOnly? AdvancedPaymentServedDate { get; set; } - public DateTime? GenerationDate { get; set; } + public DateOnly? GenerationDate { get; set; } public List Financials { get; set; } diff --git a/source/backend/api/Models/Concepts/Deposit/SecurityDepositMap.cs b/source/backend/api/Models/Concepts/Deposit/SecurityDepositMap.cs index a331031748..61f0cc05a1 100644 --- a/source/backend/api/Models/Concepts/Deposit/SecurityDepositMap.cs +++ b/source/backend/api/Models/Concepts/Deposit/SecurityDepositMap.cs @@ -1,4 +1,6 @@ +using System; using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -12,7 +14,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.LeaseId, src => src.LeaseId) .Map(dest => dest.Description, src => src.Description) .Map(dest => dest.AmountPaid, src => src.AmountPaid) - .Map(dest => dest.DepositDate, src => src.DepositDate) + .Map(dest => dest.DepositDateOnly, src => DateOnly.FromDateTime(src.DepositDate)) .Map(dest => dest.DepositType, src => src.SecurityDepositTypeCodeNavigation) .Map(dest => dest.OtherTypeDescription, src => src.OtherDepositTypeDesc) .Map(dest => dest.DepositReturns, src => src.PimsSecurityDepositReturns) @@ -23,7 +25,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.SecurityDepositId, src => src.Id) .Map(dest => dest.Description, src => src.Description) .Map(dest => dest.AmountPaid, src => src.AmountPaid) - .Map(dest => dest.DepositDate, src => src.DepositDate) + .Map(dest => dest.DepositDate, src => src.DepositDateOnly.ToNullableDateTime()) .Map(dest => dest.SecurityDepositTypeCode, src => src.DepositType.Id) .Map(dest => dest.OtherDepositTypeDesc, src => src.OtherTypeDescription) .Map(dest => dest.PimsSecurityDepositHolder, src => src.ContactHolder) diff --git a/source/backend/api/Models/Concepts/Deposit/SecurityDepositModel.cs b/source/backend/api/Models/Concepts/Deposit/SecurityDepositModel.cs index 9e3cef1606..c53ca72a63 100644 --- a/source/backend/api/Models/Concepts/Deposit/SecurityDepositModel.cs +++ b/source/backend/api/Models/Concepts/Deposit/SecurityDepositModel.cs @@ -28,7 +28,7 @@ public class SecurityDepositModel : BaseModel /// /// get/set - Security deposit date. /// - public DateTime? DepositDate { get; set; } + public DateOnly? DepositDateOnly { get; set; } /// /// get/set - Security deposit type. diff --git a/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnMap.cs b/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnMap.cs index 9daba0e57e..3ba20cd12c 100644 --- a/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnMap.cs +++ b/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnMap.cs @@ -1,4 +1,5 @@ using Mapster; +using System; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -10,22 +11,22 @@ public void Register(TypeAdapterConfig config) config.NewConfig() .Map(dest => dest.Id, src => src.SecurityDepositReturnId) .Map(dest => dest.ParentDepositId, src => src.SecurityDepositId) - .Map(dest => dest.TerminationDate, src => src.TerminationDate) + .Map(dest => dest.TerminationDate, src => DateOnly.FromDateTime(src.TerminationDate)) .Map(dest => dest.ClaimsAgainst, src => src.ClaimsAgainst) .Map(dest => dest.ReturnAmount, src => src.ReturnAmount) .Map(dest => dest.InterestPaid, src => src.InterestPaid) - .Map(dest => dest.ReturnDate, src => src.ReturnDate) + .Map(dest => dest.ReturnDate, src => DateOnly.FromDateTime(src.ReturnDate)) .Map(dest => dest.ContactHolder, src => src.PimsSecurityDepositReturnHolder) .Inherits(); config.NewConfig() .Map(dest => dest.SecurityDepositReturnId, src => src.Id) .Map(dest => dest.SecurityDepositId, src => src.ParentDepositId) - .Map(dest => dest.TerminationDate, src => src.TerminationDate) + .Map(dest => dest.TerminationDate, src => src.TerminationDate.ToDateTime(TimeOnly.MinValue)) .Map(dest => dest.ClaimsAgainst, src => src.ClaimsAgainst) .Map(dest => dest.ReturnAmount, src => src.ReturnAmount) .Map(dest => dest.InterestPaid, src => src.InterestPaid) - .Map(dest => dest.ReturnDate, src => src.ReturnDate) + .Map(dest => dest.ReturnDate, src => src.ReturnDate.ToDateTime(TimeOnly.MinValue)) .Map(dest => dest.PimsSecurityDepositReturnHolder, src => src.ContactHolder) .Inherits(); } diff --git a/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnModel.cs b/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnModel.cs index 2ccb563d0b..08e5b4aff2 100644 --- a/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnModel.cs +++ b/source/backend/api/Models/Concepts/Deposit/SecurityDepositReturnModel.cs @@ -22,7 +22,7 @@ public class SecurityDepositReturnModel : BaseModel /// /// get/set - The termination date of the deposit. /// - public DateTime TerminationDate { get; set; } + public DateOnly TerminationDate { get; set; } /// /// get/set - any claims made against the deposit total, reducing the returned amount. @@ -42,7 +42,7 @@ public class SecurityDepositReturnModel : BaseModel /// /// get/set - The date when the deposit was returned. /// - public DateTime ReturnDate { get; set; } + public DateOnly ReturnDate { get; set; } /// /// get/set - Contact Holder. diff --git a/source/backend/api/Models/Concepts/Lease/LeaseMap.cs b/source/backend/api/Models/Concepts/Lease/LeaseMap.cs index 38ea2ff48b..062ae90fc1 100644 --- a/source/backend/api/Models/Concepts/Lease/LeaseMap.cs +++ b/source/backend/api/Models/Concepts/Lease/LeaseMap.cs @@ -1,6 +1,8 @@ using Mapster; using Pims.Api.Helpers.Extensions; +using Pims.Core.Extensions; using Pims.Dal.Helpers.Extensions; +using System; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -19,8 +21,8 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.TfaFileNumber, src => src.TfaFileNumber) .Map(dest => dest.PsFileNo, src => src.PsFileNo) .Map(dest => dest.MotiName, src => src.GetMotiName()) - .Map(dest => dest.ExpiryDate, src => src.GetExpiryDate()) - .Map(dest => dest.StartDate, src => src.OrigStartDate) + .Map(dest => dest.ExpiryDate, src => src.GetExpiryDate().ToNullableDateOnly()) + .Map(dest => dest.StartDate, src => DateOnly.FromDateTime(src.OrigStartDate)) .Map(dest => dest.ProgramName, src => src.GetProgramName()) .Map(dest => dest.OtherCategoryType, src => src.LeaseCategoryOtherDesc) .Map(dest => dest.OtherProgramType, src => src.OtherLeaseProgramType) @@ -66,8 +68,8 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.OtherLeasePurposeType, src => src.OtherPurposeType) .Map(dest => dest.LeasePurposeOtherDesc, src => src.OtherPurposeType) .Map(dest => dest.OtherLeaseLicenseType, src => src.OtherType) - .Map(dest => dest.OrigExpiryDate, src => src.ExpiryDate) - .Map(dest => dest.OrigStartDate, src => src.StartDate) + .Map(dest => dest.OrigExpiryDate, src => src.ExpiryDate.ToNullableDateTime()) + .Map(dest => dest.OrigStartDate, src => src.StartDate.ToNullableDateTime()) .Map(dest => dest.RegionCode, src => src.Region.Id) .Map(dest => dest.LeaseProgramTypeCode, src => src.ProgramType.GetTypeId()) .Map(dest => dest.LeasePayRvblTypeCode, src => src.PaymentReceivableType.GetTypeId()) diff --git a/source/backend/api/Models/Concepts/Lease/LeaseModel.cs b/source/backend/api/Models/Concepts/Lease/LeaseModel.cs index f9b6ce9917..b10d73f598 100644 --- a/source/backend/api/Models/Concepts/Lease/LeaseModel.cs +++ b/source/backend/api/Models/Concepts/Lease/LeaseModel.cs @@ -94,17 +94,17 @@ public class LeaseModel : BaseAppModel /// /// get/set - The calculated expiry date of the lease. /// - public DateTime? ExpiryDate { get; set; } + public DateOnly? ExpiryDate { get; set; } /// /// get/set - The original start date of the lease. /// - public DateTime? StartDate { get; set; } + public DateOnly? StartDate { get; set; } /// /// get/set - The most recent renewal date on the lease. /// - public DateTime? RenewalDate { get; set; } + public DateOnly? RenewalDate { get; set; } /// /// get/set - The lease renewal count. diff --git a/source/backend/api/Models/Concepts/Lease/LeaseTermMap.cs b/source/backend/api/Models/Concepts/Lease/LeaseTermMap.cs index c4e8c56c6e..86fc87e367 100644 --- a/source/backend/api/Models/Concepts/Lease/LeaseTermMap.cs +++ b/source/backend/api/Models/Concepts/Lease/LeaseTermMap.cs @@ -1,4 +1,6 @@ +using System; using Mapster; +using Pims.Core.Extensions; using static Pims.Dal.Entities.PimsLeaseTermStatusType; using Entity = Pims.Dal.Entities; @@ -11,9 +13,9 @@ public void Register(TypeAdapterConfig config) config.NewConfig() .Map(dest => dest.Id, src => src.LeaseTermId) .Map(dest => dest.LeaseId, src => src.LeaseId) - .Map(dest => dest.RenewalDate, src => src.TermRenewalDate) - .Map(dest => dest.ExpiryDate, src => src.TermExpiryDate) - .Map(dest => dest.StartDate, src => src.TermStartDate) + .Map(dest => dest.RenewalDate, src => src.TermRenewalDate.ToNullableDateOnly()) + .Map(dest => dest.ExpiryDate, src => src.TermExpiryDate.ToNullableDateOnly()) + .Map(dest => dest.StartDate, src => DateOnly.FromDateTime(src.TermStartDate)) .Map(dest => dest.StatusTypeCode, src => src.LeaseTermStatusTypeCodeNavigation) .Map(dest => dest.LeasePmtFreqTypeCode, src => src.LeasePmtFreqTypeCodeNavigation) .Map(dest => dest.IsGstEligible, src => src.IsGstEligible) @@ -21,16 +23,16 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.GstAmount, src => src.IsGstEligible.HasValue && src.IsGstEligible.Value ? src.GstAmount : null) .Map(dest => dest.PaymentAmount, src => src.PaymentAmount) .Map(dest => dest.PaymentNote, src => src.PaymentNote) - .Map(dest => dest.PaymentDueDate, src => src.PaymentDueDate) + .Map(dest => dest.PaymentDueDateStr, src => src.PaymentDueDate) .Map(dest => dest.Payments, src => src.PimsLeasePayments) .Inherits(); config.NewConfig() .Map(dest => dest.LeaseTermId, src => src.Id) .Map(dest => dest.LeaseId, src => src.LeaseId) - .Map(dest => dest.TermRenewalDate, src => src.RenewalDate) - .Map(dest => dest.TermExpiryDate, src => src.ExpiryDate) - .Map(dest => dest.TermStartDate, src => src.StartDate) + .Map(dest => dest.TermRenewalDate, src => src.RenewalDate.ToNullableDateTime()) + .Map(dest => dest.TermExpiryDate, src => src.ExpiryDate.ToNullableDateTime()) + .Map(dest => dest.TermStartDate, src => src.StartDate.ToNullableDateTime()) .Map(dest => dest.LeaseTermStatusTypeCode, src => src.StatusTypeCode != null ? src.StatusTypeCode.Id : null) .Map(dest => dest.LeasePmtFreqTypeCode, src => src.LeasePmtFreqTypeCode != null ? src.LeasePmtFreqTypeCode.Id : null) .Map(dest => dest.IsGstEligible, src => src.IsGstEligible) @@ -38,7 +40,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.GstAmount, src => src.IsGstEligible ? src.GstAmount : null) .Map(dest => dest.PaymentAmount, src => src.PaymentAmount) .Map(dest => dest.PaymentNote, src => src.PaymentNote) - .Map(dest => dest.PaymentDueDate, src => src.PaymentDueDate) + .Map(dest => dest.PaymentDueDate, src => src.PaymentDueDateStr) .Map(dest => dest.PimsLeasePayments, src => src.Payments) .Inherits(); } diff --git a/source/backend/api/Models/Concepts/Lease/LeaseTermModel.cs b/source/backend/api/Models/Concepts/Lease/LeaseTermModel.cs index b41465d1bb..81b3073e2a 100644 --- a/source/backend/api/Models/Concepts/Lease/LeaseTermModel.cs +++ b/source/backend/api/Models/Concepts/Lease/LeaseTermModel.cs @@ -48,22 +48,22 @@ public class LeaseTermModel : BaseAppModel /// /// get/set - the start date of this term. /// - public DateTime? StartDate { get; set; } + public DateOnly? StartDate { get; set; } /// /// get/set - The date this term expires. /// - public DateTime? ExpiryDate { get; set; } + public DateOnly? ExpiryDate { get; set; } /// /// get/set - The date this term was renewed. /// - public DateTime? RenewalDate { get; set; } + public DateOnly? RenewalDate { get; set; } /// /// get/set - Free text related to the date the payment for this term is normally due. /// - public string PaymentDueDate { get; set; } + public string PaymentDueDateStr { get; set; } /// /// get/set - The date the payment for this term is normally due, freetext. diff --git a/source/backend/api/Models/Concepts/Lease/PaymentMap.cs b/source/backend/api/Models/Concepts/Lease/PaymentMap.cs index 9a90e9e33b..9d4ee1d5e6 100644 --- a/source/backend/api/Models/Concepts/Lease/PaymentMap.cs +++ b/source/backend/api/Models/Concepts/Lease/PaymentMap.cs @@ -1,3 +1,4 @@ +using System; using Mapster; using Entity = Pims.Dal.Entities; @@ -16,7 +17,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.AmountPreTax, src => src.PaymentAmountPreTax) .Map(dest => dest.AmountPst, src => src.PaymentAmountPst) .Map(dest => dest.AmountTotal, src => src.PaymentAmountTotal) - .Map(dest => dest.ReceivedDate, src => src.PaymentReceivedDate) + .Map(dest => dest.ReceivedDate, src => DateOnly.FromDateTime(src.PaymentReceivedDate)) .Map(dest => dest.Note, src => src.Note) .Inherits(); @@ -29,7 +30,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.PaymentAmountPreTax, src => src.AmountPreTax) .Map(dest => dest.PaymentAmountPst, src => src.AmountPst) .Map(dest => dest.PaymentAmountTotal, src => src.AmountTotal) - .Map(dest => dest.PaymentReceivedDate, src => src.ReceivedDate) + .Map(dest => dest.PaymentReceivedDate, src => src.ReceivedDate.ToDateTime(TimeOnly.MinValue)) .Map(dest => dest.Note, src => src.Note) .Inherits(); } diff --git a/source/backend/api/Models/Concepts/Lease/PaymentModel.cs b/source/backend/api/Models/Concepts/Lease/PaymentModel.cs index 6e5050fb07..e6b7bbb717 100644 --- a/source/backend/api/Models/Concepts/Lease/PaymentModel.cs +++ b/source/backend/api/Models/Concepts/Lease/PaymentModel.cs @@ -37,7 +37,7 @@ public class PaymentModel : BaseAppModel /// /// get/set - The date the payment was or will be received. /// - public DateTime ReceivedDate { get; set; } + public DateOnly ReceivedDate { get; set; } /// /// get/set - The Expected Payment per interval before tax. diff --git a/source/backend/api/Models/Concepts/Product/ProductMap.cs b/source/backend/api/Models/Concepts/Product/ProductMap.cs index 8069898bbc..841c3f9d80 100644 --- a/source/backend/api/Models/Concepts/Product/ProductMap.cs +++ b/source/backend/api/Models/Concepts/Product/ProductMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -14,9 +15,9 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.AcquisitionFiles, src => src.PimsAcquisitionFiles) .Map(dest => dest.Code, src => src.Code) .Map(dest => dest.Description, src => src.Description) - .Map(dest => dest.StartDate, src => src.StartDate) + .Map(dest => dest.StartDate, src => src.StartDate.ToNullableDateOnly()) .Map(dest => dest.CostEstimate, src => src.CostEstimate) - .Map(dest => dest.CostEstimateDate, src => src.CostEstimateDate) + .Map(dest => dest.CostEstimateDate, src => src.CostEstimateDate.ToNullableDateOnly()) .Map(dest => dest.Objective, src => src.Objective) .Map(dest => dest.Scope, src => src.Scope) .Inherits(); @@ -27,9 +28,9 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.PimsAcquisitionFiles, src => src.AcquisitionFiles) .Map(dest => dest.Code, src => src.Code) .Map(dest => dest.Description, src => src.Description) - .Map(dest => dest.StartDate, src => src.StartDate) + .Map(dest => dest.StartDate, src => src.StartDate.ToNullableDateTime()) .Map(dest => dest.CostEstimate, src => src.CostEstimate) - .Map(dest => dest.CostEstimateDate, src => src.CostEstimateDate) + .Map(dest => dest.CostEstimateDate, src => src.CostEstimateDate.ToNullableDateTime()) .Map(dest => dest.Objective, src => src.Objective) .Map(dest => dest.Scope, src => src.Scope) .Inherits(); diff --git a/source/backend/api/Models/Concepts/Product/ProductModel.cs b/source/backend/api/Models/Concepts/Product/ProductModel.cs index 2470b6dfd9..7cfdb56e1d 100644 --- a/source/backend/api/Models/Concepts/Product/ProductModel.cs +++ b/source/backend/api/Models/Concepts/Product/ProductModel.cs @@ -40,7 +40,7 @@ public class ProductModel : BaseAppModel /// /// get/set - The product start date. /// - public DateTime? StartDate { get; set; } + public DateOnly? StartDate { get; set; } /// /// get/set - The product cost estimate. @@ -50,7 +50,7 @@ public class ProductModel : BaseAppModel /// /// get/set - The product cost estimate date. /// - public DateTime? CostEstimateDate { get; set; } + public DateOnly? CostEstimateDate { get; set; } /// /// get/set - The product objective. diff --git a/source/backend/api/Models/Concepts/Property/PropertyManagementModel.cs b/source/backend/api/Models/Concepts/Property/PropertyManagementModel.cs index d03c3d8e19..eb06feb919 100644 --- a/source/backend/api/Models/Concepts/Property/PropertyManagementModel.cs +++ b/source/backend/api/Models/Concepts/Property/PropertyManagementModel.cs @@ -42,6 +42,6 @@ public class PropertyManagementModel : BaseAppModel /// get/set - The expiry date of the lease when there is only ONE lease for this property (regardless of status). /// This field is null when the lease does not expire. /// - public DateTime? LeaseExpiryDate { get; set; } + public DateOnly? LeaseExpiryDate { get; set; } } } diff --git a/source/backend/api/Models/Concepts/Property/PropertyMap.cs b/source/backend/api/Models/Concepts/Property/PropertyMap.cs index 103176fd0f..f4dc90164a 100644 --- a/source/backend/api/Models/Concepts/Property/PropertyMap.cs +++ b/source/backend/api/Models/Concepts/Property/PropertyMap.cs @@ -1,4 +1,6 @@ using Mapster; +using Pims.Core.Extensions; +using System; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -22,7 +24,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.GeneralLocation, src => src.GeneralLocation) .Map(dest => dest.DataSource, src => src.PropertyDataSourceTypeCodeNavigation) - .Map(dest => dest.DataSourceEffectiveDate, src => src.PropertyDataSourceEffectiveDate) + .Map(dest => dest.DataSourceEffectiveDate, src => DateOnly.FromDateTime(src.PropertyDataSourceEffectiveDate)) .Map(dest => dest.Name, src => src.Name) .Map(dest => dest.Description, src => src.Description) @@ -61,7 +63,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.Longitude, src => src.Location.Coordinate.X) .Map(dest => dest.SurplusDeclarationComment, src => src.SurplusDeclarationComment) - .Map(dest => dest.SurplusDeclarationDate, src => src.SurplusDeclarationDate) + .Map(dest => dest.SurplusDeclarationDate, src => src.SurplusDeclarationDate.ToNullableDateOnly()) .Map(dest => dest.SurplusDeclarationType, src => src.SurplusDeclarationTypeCodeNavigation) .Inherits(); diff --git a/source/backend/api/Models/Concepts/Property/PropertyModel.cs b/source/backend/api/Models/Concepts/Property/PropertyModel.cs index d71bd3f026..d13466f37b 100644 --- a/source/backend/api/Models/Concepts/Property/PropertyModel.cs +++ b/source/backend/api/Models/Concepts/Property/PropertyModel.cs @@ -59,7 +59,7 @@ public class PropertyModel : BaseModel /// /// get/set - The data source effective date. /// - public DateTime DataSourceEffectiveDate { get; set; } + public DateOnly DataSourceEffectiveDate { get; set; } /// /// get/set - The GIS latitude location of the property. @@ -238,7 +238,7 @@ public class PropertyModel : BaseModel public string SurplusDeclarationComment { get; set; } - public DateTime SurplusDeclarationDate { get; set; } + public DateOnly SurplusDeclarationDate { get; set; } #endregion #endregion diff --git a/source/backend/api/Models/Concepts/ResearchFile/ResearchFileMap.cs b/source/backend/api/Models/Concepts/ResearchFile/ResearchFileMap.cs index 7fc3e5ee3f..ce4de5a71c 100644 --- a/source/backend/api/Models/Concepts/ResearchFile/ResearchFileMap.cs +++ b/source/backend/api/Models/Concepts/ResearchFile/ResearchFileMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -15,11 +16,11 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.RoadName, src => src.RoadName) .Map(dest => dest.FileStatusTypeCode, src => src.ResearchFileStatusTypeCodeNavigation) .Map(dest => dest.FileProperties, src => src.PimsPropertyResearchFiles) - .Map(dest => dest.RequestDate, src => src.RequestDate) + .Map(dest => dest.RequestDate, src => src.RequestDate.ToNullableDateOnly()) .Map(dest => dest.RequestDescription, src => src.RequestDescription) .Map(dest => dest.RequestSourceDescription, src => src.RequestSourceDescription) .Map(dest => dest.ResearchResult, src => src.ResearchResult) - .Map(dest => dest.ResearchCompletionDate, src => src.ResearchCompletionDate) + .Map(dest => dest.ResearchCompletionDate, src => src.ResearchCompletionDate.ToNullableDateOnly()) .Map(dest => dest.IsExpropriation, src => src.IsExpropriation) .Map(dest => dest.ExpropriationNotes, src => src.ExpropriationNotes) .Map(dest => dest.RequestSourceType, src => src.RequestSourceTypeCodeNavigation) @@ -37,11 +38,11 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.RoadName, src => src.RoadName) .Map(dest => dest.ResearchFileStatusTypeCode, src => src.FileStatusTypeCode.Id) .Map(dest => dest.PimsPropertyResearchFiles, src => src.FileProperties) - .Map(dest => dest.RequestDate, src => src.RequestDate) + .Map(dest => dest.RequestDate, src => src.RequestDate.ToNullableDateTime()) .Map(dest => dest.RequestDescription, src => src.RequestDescription) .Map(dest => dest.RequestSourceDescription, src => src.RequestSourceDescription) .Map(dest => dest.ResearchResult, src => src.ResearchResult) - .Map(dest => dest.ResearchCompletionDate, src => src.ResearchCompletionDate) + .Map(dest => dest.ResearchCompletionDate, src => src.ResearchCompletionDate.ToNullableDateTime()) .Map(dest => dest.IsExpropriation, src => src.IsExpropriation) .Map(dest => dest.ExpropriationNotes, src => src.ExpropriationNotes) .Map(dest => dest.RequestSourceTypeCode, src => src.RequestSourceType.Id) diff --git a/source/backend/api/Models/Concepts/ResearchFile/ResearchFileModel.cs b/source/backend/api/Models/Concepts/ResearchFile/ResearchFileModel.cs index 79ab3b3214..31ebbdffe1 100644 --- a/source/backend/api/Models/Concepts/ResearchFile/ResearchFileModel.cs +++ b/source/backend/api/Models/Concepts/ResearchFile/ResearchFileModel.cs @@ -16,7 +16,7 @@ public class ResearchFileModel : FileModel /// public IList FileProperties { get; set; } - public DateTime? RequestDate { get; set; } + public DateOnly? RequestDate { get; set; } public string RequestDescription { get; set; } @@ -24,7 +24,7 @@ public class ResearchFileModel : FileModel public string ResearchResult { get; set; } - public DateTime? ResearchCompletionDate { get; set; } + public DateOnly? ResearchCompletionDate { get; set; } public bool? IsExpropriation { get; set; } diff --git a/source/backend/api/Models/Concepts/Take/TakeMap.cs b/source/backend/api/Models/Concepts/Take/TakeMap.cs index 0d778e113f..41cf623f29 100644 --- a/source/backend/api/Models/Concepts/Take/TakeMap.cs +++ b/source/backend/api/Models/Concepts/Take/TakeMap.cs @@ -1,4 +1,5 @@ using Mapster; +using Pims.Core.Extensions; using Entity = Pims.Dal.Entities; namespace Pims.Api.Models.Concepts @@ -12,10 +13,10 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.Description, src => src.Description) .Map(dest => dest.IsSurplus, src => src.IsThereSurplus) .Map(dest => dest.LicenseToConstructArea, src => src.LicenseToConstructArea) - .Map(dest => dest.LtcEndDt, src => src.LtcEndDt) + .Map(dest => dest.LtcEndDt, src => src.LtcEndDt.ToNullableDateOnly()) .Map(dest => dest.NewRightOfWayArea, src => src.NewHighwayDedicationArea) .Map(dest => dest.LandActArea, src => src.LandActArea) - .Map(dest => dest.LandActEndDt, src => src.LandActEndDt) + .Map(dest => dest.LandActEndDt, src => src.LandActEndDt.ToNullableDateOnly()) .Map(dest => dest.PropertyAcquisitionFile, src => src.PropertyAcquisitionFile) .Map(dest => dest.PropertyAcquisitionFileId, src => src.PropertyAcquisitionFileId) .Map(dest => dest.StatutoryRightOfWayArea, src => src.StatutoryRightOfWayArea) @@ -40,10 +41,10 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.IsNewInterestInSrw, src => src.IsNewInterestInSrw) .Map(dest => dest.IsNewLicenseToConstruct, src => src.IsLicenseToConstruct) .Map(dest => dest.LicenseToConstructArea, src => src.LicenseToConstructArea) - .Map(dest => dest.LtcEndDt, src => src.LtcEndDt) + .Map(dest => dest.LtcEndDt, src => src.LtcEndDt.ToNullableDateTime()) .Map(dest => dest.NewHighwayDedicationArea, src => src.NewRightOfWayArea) .Map(dest => dest.LandActArea, src => src.LandActArea) - .Map(dest => dest.LandActEndDt, src => src.LandActEndDt) + .Map(dest => dest.LandActEndDt, src => src.LandActEndDt.ToNullableDateTime()) .Map(dest => dest.PropertyAcquisitionFile, src => src.PropertyAcquisitionFile) .Map(dest => dest.PropertyAcquisitionFileId, src => src.PropertyAcquisitionFileId) .Map(dest => dest.StatutoryRightOfWayArea, src => src.StatutoryRightOfWayArea) diff --git a/source/backend/api/Models/Concepts/Take/TakeModel.cs b/source/backend/api/Models/Concepts/Take/TakeModel.cs index cd069d432f..f5bad2407f 100644 --- a/source/backend/api/Models/Concepts/Take/TakeModel.cs +++ b/source/backend/api/Models/Concepts/Take/TakeModel.cs @@ -28,13 +28,13 @@ public class TakeModel : BaseAppModel public float? LicenseToConstructArea { get; set; } - public DateTime? LtcEndDt { get; set; } + public DateOnly? LtcEndDt { get; set; } public float? NewRightOfWayArea { get; set; } public float? LandActArea { get; set; } - public DateTime? LandActEndDt { get; set; } + public DateOnly? LandActEndDt { get; set; } public AcquisitionFileModel PropertyAcquisitionFile { get; set; } diff --git a/source/backend/api/Services/PropertyService.cs b/source/backend/api/Services/PropertyService.cs index 809bcf1cf5..179902efb1 100644 --- a/source/backend/api/Services/PropertyService.cs +++ b/source/backend/api/Services/PropertyService.cs @@ -185,7 +185,7 @@ public PropertyManagementModel GetPropertyManagement(long propertyId) var propertyManagement = _mapper.Map(property); propertyManagement.RelatedLeases = leaseCount; - propertyManagement.LeaseExpiryDate = leaseExpiryDate; + propertyManagement.LeaseExpiryDate = leaseExpiryDate.HasValue ? DateOnly.FromDateTime(leaseExpiryDate.Value) : null; return propertyManagement; } diff --git a/source/backend/api/Startup.cs b/source/backend/api/Startup.cs index 4381ca7ba0..221d2d8b8c 100644 --- a/source/backend/api/Startup.cs +++ b/source/backend/api/Startup.cs @@ -46,6 +46,7 @@ using Pims.Core.Converters; using Pims.Core.Http; using Pims.Core.Http.Configuration; +using Pims.Core.Json; using Pims.Dal; using Pims.Dal.Keycloak; using Pims.Geocoder; @@ -138,6 +139,7 @@ public void ConfigureServices(IServiceCollection services) options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); options.JsonSerializerOptions.Converters.Add(new Int32ToStringJsonConverter()); options.JsonSerializerOptions.Converters.Add(new GeometryJsonConverter()); + options.JsonSerializerOptions.Converters.Add(new DateOnlyJsonConverter()); }); services.AddMvcCore() @@ -150,6 +152,7 @@ public void ConfigureServices(IServiceCollection services) options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); options.JsonSerializerOptions.Converters.Add(new Int32ToStringJsonConverter()); options.JsonSerializerOptions.Converters.Add(new GeometryJsonConverter()); + options.JsonSerializerOptions.Converters.Add(new DateOnlyJsonConverter()); }); services.AddAuthentication(options => diff --git a/source/backend/core/Extensions/DateExtensions.cs b/source/backend/core/Extensions/DateExtensions.cs index 33b4a7d10c..1ddee12263 100644 --- a/source/backend/core/Extensions/DateExtensions.cs +++ b/source/backend/core/Extensions/DateExtensions.cs @@ -66,5 +66,25 @@ public static string FiscalYear(this int fiscalYear) { return date <= (DateTime)SqlDateTime.MinValue ? null : date; } + + /// + /// Returns the date time with only the date portion. + /// + /// + /// + public static DateOnly? ToNullableDateOnly(this DateTime? date) + { + return date.HasValue ? DateOnly.FromDateTime(date.Value) : null; + } + + /// + /// Returns the date time with only the date portion. + /// + /// + /// + public static DateTime? ToNullableDateTime(this DateOnly? date) + { + return date.HasValue ? date.Value.ToDateTime(TimeOnly.MinValue) : null; + } } } diff --git a/source/backend/core/Json/DateOnlyJsonConverter.cs b/source/backend/core/Json/DateOnlyJsonConverter.cs new file mode 100644 index 0000000000..44377e9edd --- /dev/null +++ b/source/backend/core/Json/DateOnlyJsonConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Pims.Core.Json +{ + public sealed class DateOnlyJsonConverter : JsonConverter + { + public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + return DateOnly.FromDateTime(reader.GetDateTime()); + } + + public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options) + { + var isoDate = value.ToString("O"); + writer.WriteStringValue(isoDate); + } + } +} diff --git a/source/frontend/src/components/common/form/FastDatePicker.tsx b/source/frontend/src/components/common/form/FastDatePicker.tsx index e6c7b2c2f6..30717861e6 100644 --- a/source/frontend/src/components/common/form/FastDatePicker.tsx +++ b/source/frontend/src/components/common/form/FastDatePicker.tsx @@ -53,14 +53,12 @@ const FormikDatePicker: FunctionComponent { diff --git a/source/frontend/src/features/acquisition/list/AcquisitionSearchResults/models.ts b/source/frontend/src/features/acquisition/list/AcquisitionSearchResults/models.ts index 19c72d8deb..74da8e3b91 100644 --- a/source/frontend/src/features/acquisition/list/AcquisitionSearchResults/models.ts +++ b/source/frontend/src/features/acquisition/list/AcquisitionSearchResults/models.ts @@ -6,6 +6,7 @@ import { import { Api_CompensationRequisition } from '@/models/api/CompensationRequisition'; import { Api_Project } from '@/models/api/Project'; import Api_TypeCode from '@/models/api/TypeCode'; +import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; export class AcquisitionSearchResultModel { id?: number; @@ -14,9 +15,9 @@ export class AcquisitionSearchResultModel { fileName?: string; regionCode?: string; appLastUpdateUserid?: string; - appCreateTimestamp?: string; + appCreateTimestamp?: UtcIsoDateTime; appCreateUserid?: string; - appLastUpdateTimestamp?: string; + appLastUpdateTimestamp?: UtcIsoDateTime; acquisitionFileStatusTypeCode?: Api_TypeCode; fileProperties?: Api_AcquisitionFileProperty[]; project?: Api_Project; diff --git a/source/frontend/src/features/admin/access-request/models.ts b/source/frontend/src/features/admin/access-request/models.ts index e29b9ceda8..b10361f63d 100644 --- a/source/frontend/src/features/admin/access-request/models.ts +++ b/source/frontend/src/features/admin/access-request/models.ts @@ -1,6 +1,7 @@ import { ContactMethodTypes } from '@/constants/contactMethodType'; import { UserTypes } from '@/constants/index'; import { Api_AccessRequest } from '@/models/api/AccessRequest'; +import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; import { NumberFieldValue } from '@/typings/NumberFieldValue'; import { getPreferredContactMethodValue } from '@/utils/contactMethodUtil'; import { fromTypeCode, stringToUndefined, toTypeCode } from '@/utils/formUtils'; @@ -15,7 +16,7 @@ export class FormAccessRequest { public accessRequestStatusTypeCodeName: string; public regionCodeId: NumberFieldValue; public regionName: string; - public appCreateTimestamp?: string; + public appCreateTimestamp?: UtcIsoDateTime; public email: string; public firstName: string; public surname: string; diff --git a/source/frontend/src/features/admin/users/interfaces/IUserRecord.ts b/source/frontend/src/features/admin/users/interfaces/IUserRecord.ts index 4feadbd933..3348d89194 100644 --- a/source/frontend/src/features/admin/users/interfaces/IUserRecord.ts +++ b/source/frontend/src/features/admin/users/interfaces/IUserRecord.ts @@ -1,3 +1,5 @@ +import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; + export interface IUserRecord { id?: number; keycloakUserId?: string; @@ -10,6 +12,6 @@ export interface IUserRecord { roles?: string; position?: string; lastLogin?: string; - appCreateTimestamp?: string; + appCreateTimestamp?: UtcIsoDateTime; rowVersion?: number; } diff --git a/source/frontend/src/features/admin/users/models.ts b/source/frontend/src/features/admin/users/models.ts index 9375e456bb..b652e87aa5 100644 --- a/source/frontend/src/features/admin/users/models.ts +++ b/source/frontend/src/features/admin/users/models.ts @@ -4,6 +4,7 @@ import { Api_Person } from '@/models/api/Person'; import { Api_Role } from '@/models/api/Role'; import Api_TypeCode from '@/models/api/TypeCode'; import { Api_User } from '@/models/api/User'; +import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; import { NumberFieldValue } from '@/typings/NumberFieldValue'; import { getPreferredContactMethodValue } from '@/utils/contactMethodUtil'; @@ -19,7 +20,7 @@ export class FormUser { position?: string; userTypeCode?: Api_TypeCode; lastLogin?: string; - appCreateTimestamp?: string; + appCreateTimestamp?: UtcIsoDateTime; issueDate?: string; rowVersion?: NumberFieldValue; note?: string; diff --git a/source/frontend/src/features/documents/ComposedDocument.ts b/source/frontend/src/features/documents/ComposedDocument.ts index 7f7c7c85d5..e01f2a8431 100644 --- a/source/frontend/src/features/documents/ComposedDocument.ts +++ b/source/frontend/src/features/documents/ComposedDocument.ts @@ -13,6 +13,7 @@ import { Api_Storage_DocumentTypeMetadataType, } from '@/models/api/DocumentStorage'; import Api_TypeCode from '@/models/api/TypeCode'; +import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; export interface ComposedDocument { mayanMetadata?: Api_Storage_DocumentMetadata[]; @@ -28,7 +29,7 @@ export class DocumentRow { statusTypeCode: Api_TypeCode | undefined; fileName: string | undefined; isFileAvailable: boolean | undefined; - appCreateTimestamp?: string; + appCreateTimestamp?: UtcIsoDateTime; appCreateUserid?: string; relationshipId: number | undefined; relationshipType: DocumentRelationshipType | undefined; diff --git a/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/DepositsReceivedContainer.test.tsx b/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/DepositsReceivedContainer.test.tsx index 3934bfd645..befe292b75 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/DepositsReceivedContainer.test.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/DepositsReceivedContainer.test.tsx @@ -87,7 +87,7 @@ describe('DepositsReceivedContainer component', () => { expect(findCell(dataRow, 0)?.textContent).toBe(deposit.depositType.description ?? ''); expect(findCell(dataRow, 1)?.textContent).toBe(deposit.description); expect(findCell(dataRow, 2)?.textContent).toBe(formatMoney(deposit.amountPaid)); - expect(findCell(dataRow, 3)?.textContent).toBe(prettyFormatDate(deposit.depositDate)); + expect(findCell(dataRow, 3)?.textContent).toBe(prettyFormatDate(deposit.depositDateOnly)); expect(findCell(dataRow, 4)?.textContent).toBe('test person'); }); diff --git a/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/columns.tsx b/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/columns.tsx index 426c8e99fb..7034243993 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/columns.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/deposits/components/DepositsReceivedContainer/columns.tsx @@ -33,7 +33,7 @@ export class DepositListEntry { } this.depositDescription = baseDeposit.description; this.amountPaid = baseDeposit.amountPaid; - this.paidDate = baseDeposit.depositDate || ''; + this.paidDate = baseDeposit.depositDateOnly || ''; this.contactHolder = baseDeposit.contactHolder || undefined; this.depositReturnCount = baseDeposit.depositReturns.length; } diff --git a/source/frontend/src/features/leases/detail/LeasePages/deposits/models/FormLeaseDeposit.ts b/source/frontend/src/features/leases/detail/LeasePages/deposits/models/FormLeaseDeposit.ts index 06d8a3c218..d824aa8510 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/deposits/models/FormLeaseDeposit.ts +++ b/source/frontend/src/features/leases/detail/LeasePages/deposits/models/FormLeaseDeposit.ts @@ -34,7 +34,7 @@ export class FormLeaseDeposit { model.id = baseModel.id ?? undefined; model.description = baseModel.description; model.amountPaid = baseModel.amountPaid; - model.depositDate = baseModel.depositDate || ''; + model.depositDate = baseModel.depositDateOnly || ''; model.depositTypeCode = baseModel.depositType.id; model.otherTypeDescription = baseModel.otherTypeDescription || ''; model.contactHolder = @@ -50,7 +50,7 @@ export class FormLeaseDeposit { leaseId: this.leaseId ?? null, description: this.description, amountPaid: this.amountPaid === '' ? 0 : this.amountPaid, - depositDate: this.depositDate, + depositDateOnly: this.depositDate, depositType: { id: this.depositTypeCode }, otherTypeDescription: this.otherTypeDescription === '' ? null : this.otherTypeDescription, contactHolder: this.contactHolder !== undefined ? toContact(this.contactHolder) : null, diff --git a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermForm.tsx b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermForm.tsx index 440f217d7a..b0047bbdb5 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermForm.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermForm.tsx @@ -73,7 +73,7 @@ export const TermForm: React.FunctionComponent { await fillInput(document.body, 'expiryDate', '2020-01-02', 'datepicker'); await fillInput(document.body, 'leasePmyFreqTypeCode.id', 'ANNUAL', 'select'); await fillInput(document.body, 'paymentAmount', '1,000.00'); - await fillInput(document.body, 'paymentDueDate', 'A due date'); + await fillInput(document.body, 'paymentDueDateStr', 'A due date'); await fillInput(document.body, 'statusTypeCode.id', 'NEXER', 'select'); const saveButton = getByText('Save term'); act(() => userEvent.click(saveButton)); @@ -88,7 +88,7 @@ describe('TermModal component', () => { isDisabled: false, }, paymentAmount: 1000, - paymentDueDate: 'A due date', + paymentDueDateStr: 'A due date', paymentNote: '', payments: [], renewalDate: '', diff --git a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermsYupSchema.tsx b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermsYupSchema.tsx index a1d9af3e05..f0d6fb963e 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermsYupSchema.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/TermsYupSchema.tsx @@ -7,7 +7,7 @@ export const LeaseTermSchema = Yup.object().shape({ startDate: Yup.date().required('Required'), expiryDate: Yup.date().min(Yup.ref('startDate'), 'Expiry Date must be after Start Date'), paymentAmount: Yup.number().max(MAX_SQL_MONEY_SIZE), - paymentDueDate: Yup.string().max(200), + paymentDueDateStr: Yup.string().max(200), paymentNote: Yup.string().max(2000), statusTypeCode: Yup.object() .test({ diff --git a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/__snapshots__/TermForm.test.tsx.snap b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/__snapshots__/TermForm.test.tsx.snap index 3d525ad352..1dc9ac3644 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/__snapshots__/TermForm.test.tsx.snap +++ b/source/frontend/src/features/leases/detail/LeasePages/payment/modal/term/__snapshots__/TermForm.test.tsx.snap @@ -291,13 +291,13 @@ exports[`TermForm component renders as expected 1`] = ` >