diff --git a/source/backend/api/Pims.Api.csproj b/source/backend/api/Pims.Api.csproj index 79dcc9d373..55486ab240 100644 --- a/source/backend/api/Pims.Api.csproj +++ b/source/backend/api/Pims.Api.csproj @@ -2,8 +2,8 @@ 0ef6255f-9ea0-49ec-8c65-c172304b4926 - 5.7.0-95.20 - 5.7.0.95 + 5.7.1-95.20 + 5.7.1.95 true {16BC0468-78F6-4C91-87DA-7403C919E646} net8.0 diff --git a/source/backend/api/Services/AcquisitionFileService.cs b/source/backend/api/Services/AcquisitionFileService.cs index 8f23f5fdce..acd7df194a 100644 --- a/source/backend/api/Services/AcquisitionFileService.cs +++ b/source/backend/api/Services/AcquisitionFileService.cs @@ -229,7 +229,10 @@ public PimsAcquisitionFile Add(PimsAcquisitionFile acquisitionFile, IEnumerable< _propertyService.PopulateNewFileProperty(incomingAcquisitionProperty); } + // Set default values, according to business rules acquisitionFile.AcquisitionFileStatusTypeCode = AcquisitionStatusTypes.ACTIVE.ToString(); + acquisitionFile.AssignedDate ??= DateTime.Today; + var newAcqFile = _acqFileRepository.Add(acquisitionFile); _acqFileRepository.CommitTransaction(); diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs index 5b54ba2d29..28a46032cf 100644 --- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs +++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileMap.cs @@ -26,7 +26,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.ProductId, src => src.ProductId) .Map(dest => dest.FundingTypeCode, src => src.AcquisitionFundingTypeCodeNavigation) .Map(dest => dest.FundingOther, src => src.FundingOther) - .Map(dest => dest.AssignedDate, src => src.AssignedDate) + .Map(dest => dest.AssignedDate, src => src.AssignedDate.ToNullableDateOnly()) .Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateOnly()) .Map(dest => dest.EstimatedCompletionDate, src => src.EstCompletionDt.ToNullableDateOnly()) .Map(dest => dest.PossessionDate, src => src.PossessionDt.ToNullableDateOnly()) @@ -58,7 +58,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.ProductId, src => src.ProductId) .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.AssignedDate, src => src.AssignedDate.ToNullableDateTime()) .Map(dest => dest.DeliveryDate, src => src.DeliveryDate.ToNullableDateTime()) .Map(dest => dest.EstCompletionDt, src => src.EstimatedCompletionDate.ToNullableDateTime()) .Map(dest => dest.PossessionDt, src => src.PossessionDate.ToNullableDateTime()) diff --git a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs index 36534e3d87..aadf35ac51 100644 --- a/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs +++ b/source/backend/apimodels/Models/Concepts/AcquisitionFile/AcquisitionFileModel.cs @@ -36,7 +36,7 @@ public class AcquisitionFileModel : FileWithChecklistModel /// /// The assigned date. /// - public DateTime? AssignedDate { get; set; } + public DateOnly? AssignedDate { get; set; } /// /// The date for delivery of the property to the project. diff --git a/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs b/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs index 5369e25725..4626d5cfc7 100644 --- a/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs +++ b/source/backend/tests/unit/api/Services/AcquisitionFileServiceTest.cs @@ -65,6 +65,62 @@ public void Add_Success() repository.Verify(x => x.Add(It.IsAny()), Times.Once); } + [Fact] + public void Add_Success_DefaultValues() + { + // Arrange + var service = this.CreateAcquisitionServiceWithPermissions(Permissions.AcquisitionFileAdd); + + var acqFile = EntityHelper.CreateAcquisitionFile(); + acqFile.AssignedDate = null; + + var repository = this._helper.GetService>(); + repository.Setup(x => x.Add(It.IsAny())).Returns(acqFile); + + var lookupRepository = this._helper.GetService>(); + lookupRepository.Setup(x => x.GetAllRegions()).Returns(new List() { new PimsRegion() { Code = 4, RegionName = "Cannot determine" } }); + + var userRepository = this._helper.GetService>(); + userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny())).Returns(EntityHelper.CreateUser(1, Guid.NewGuid(), "Test", regionCode: 1)); + + // Act + var result = service.Add(acqFile, new List()); + + // Assert + repository.Verify(x => x.Add(It.IsAny()), Times.Once); + result.AssignedDate.Should().Be(DateTime.Today); + result.AcquisitionFileStatusTypeCode.Should().Be(AcquisitionStatusTypes.ACTIVE.ToString()); + } + + [Fact] + public void Add_Success_WithUserSuppliedAssignedDate() + { + // Arrange + var service = this.CreateAcquisitionServiceWithPermissions(Permissions.AcquisitionFileAdd); + + DateTime customDate = DateTime.Today.AddMonths(3); + + var acqFile = EntityHelper.CreateAcquisitionFile(); + acqFile.AssignedDate = customDate; + + var repository = this._helper.GetService>(); + repository.Setup(x => x.Add(It.IsAny())).Returns(acqFile); + + var lookupRepository = this._helper.GetService>(); + lookupRepository.Setup(x => x.GetAllRegions()).Returns(new List() { new PimsRegion() { Code = 4, RegionName = "Cannot determine" } }); + + var userRepository = this._helper.GetService>(); + userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny())).Returns(EntityHelper.CreateUser(1, Guid.NewGuid(), "Test", regionCode: 1)); + + // Act + var result = service.Add(acqFile, new List()); + + // Assert + repository.Verify(x => x.Add(It.IsAny()), Times.Once); + result.AssignedDate.Should().Be(customDate); + result.AcquisitionFileStatusTypeCode.Should().Be(AcquisitionStatusTypes.ACTIVE.ToString()); + } + [Fact] public void Add_CannotDetermineRegion_Error() { diff --git a/source/frontend/package-lock.json b/source/frontend/package-lock.json index c7a32606b0..a0cd004462 100644 --- a/source/frontend/package-lock.json +++ b/source/frontend/package-lock.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "5.7.0-95.0", + "version": "5.7.1-95.20", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/source/frontend/package.json b/source/frontend/package.json index cf0713c1a2..ec84a89e2b 100644 --- a/source/frontend/package.json +++ b/source/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "5.7.0-95.20", + "version": "5.7.1-95.20", "private": true, "dependencies": { "@bcgov/bc-sans": "1.0.1", diff --git a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap index 436212a8bd..72ffbca419 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap @@ -1168,7 +1168,7 @@ exports[`AcquisitionView component > renders as expected 1`] = ` class="c35 text-left col" data-testid="assigned-date" > - Dec 17, 2024 + Dec 18, 2024
matches snapshot 1`] = ` class="c7 text-left col" data-testid="assigned-date" > - Dec 17, 2024 + Dec 18, 2024
{ await waitForEffects(); expect(getByText('Jan 10, 2030')).toBeVisible(); expect(getByText('Mar 10, 2035')).toBeVisible(); - expect(getByTestId('assigned-date')).toHaveTextContent('Dec 17, 2024'); + expect(getByTestId('assigned-date')).toHaveTextContent('Dec 18, 2024'); }); it('renders owner solicitor information with primary contact', async () => { diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/AcquisitionSummaryView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/AcquisitionSummaryView.tsx index ab9b60622a..7e6e9b52d4 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/AcquisitionSummaryView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/AcquisitionSummaryView.tsx @@ -14,7 +14,7 @@ import { InterestHolderType } from '@/constants/interestHolderTypes'; import { usePersonRepository } from '@/features/contacts/repositories/usePersonRepository'; import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; import { ApiGen_Concepts_AcquisitionFile } from '@/models/api/generated/ApiGen_Concepts_AcquisitionFile'; -import { exists, prettyFormatDate, prettyFormatUTCDate } from '@/utils'; +import { exists, prettyFormatDate } from '@/utils'; import { formatApiPersonNames } from '@/utils/personUtils'; import { cannotEditMessage } from '../../../common/constants'; @@ -94,7 +94,7 @@ const AcquisitionSummaryView: React.FC = ({
- {prettyFormatUTCDate(detail.assignedDate)} + {prettyFormatDate(detail.assignedDate)} matches snapshot 1`] = ` class="c5 text-left col" data-testid="assigned-date" > - Dec 17, 2024 + Dec 18, 2024
{ }); it('displays estimated completion, assigned and possession dates', async () => { - const { getEstimatedCompletionDatePicker, getPossessionDatePicker, getAssignedDatePicker } = setup({ initialValues }); + const { getEstimatedCompletionDatePicker, getPossessionDatePicker, getAssignedDatePicker } = + setup({ initialValues }); await act(async () => {}); expect(getEstimatedCompletionDatePicker()).toHaveValue('Jul 10, 2024'); expect(getPossessionDatePicker()).toHaveValue('Jul 10, 2025'); - expect(getAssignedDatePicker()).toHaveValue('Dec 17, 2024'); + expect(getAssignedDatePicker()).toHaveValue('Dec 18, 2024'); }); it('displays Individual type Owner with data', async () => { diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/__snapshots__/UpdateAcquisitionForm.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/__snapshots__/UpdateAcquisitionForm.test.tsx.snap index 60042f1871..ce940393fe 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/__snapshots__/UpdateAcquisitionForm.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/__snapshots__/UpdateAcquisitionForm.test.tsx.snap @@ -860,7 +860,7 @@ exports[`UpdateAcquisitionForm component > Sub-interest files > renders as expec name="assignedDate" placeholder="MMM DD, YYYY" type="text" - value="Dec 17, 2024" + value="Dec 18, 2024" />
@@ -4554,7 +4554,7 @@ exports[`UpdateAcquisitionForm component > renders as expected 1`] = ` name="assignedDate" placeholder="MMM DD, YYYY" type="text" - value="Dec 17, 2024" + value="Dec 18, 2024" /> diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/models.ts b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/models.ts index f3416a42f3..dc2911336b 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/models.ts +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/update/models.ts @@ -5,7 +5,6 @@ import { ApiGen_Concepts_AcquisitionFile } from '@/models/api/generated/ApiGen_C import { ApiGen_Concepts_AcquisitionFileOwner } from '@/models/api/generated/ApiGen_Concepts_AcquisitionFileOwner'; import { ApiGen_Concepts_InterestHolder } from '@/models/api/generated/ApiGen_Concepts_InterestHolder'; import { getEmptyBaseAudit } from '@/models/defaultInitializers'; -import { formatUTCDateTime } from '@/utils'; import { fromTypeCode, toTypeCodeNullable } from '@/utils/formUtils'; import { exists, isValidId, isValidIsoDateTime } from '@/utils/utils'; @@ -121,7 +120,7 @@ export class UpdateAcquisitionSummaryFormModel newForm.legacyFileNumber = model.legacyFileNumber ?? undefined; newForm.fileName = model.fileName || ''; newForm.rowVersion = model.rowVersion ?? undefined; - newForm.assignedDate = model.assignedDate ? formatUTCDateTime(model.assignedDate) : ''; + newForm.assignedDate = model.assignedDate ?? undefined; newForm.deliveryDate = model.deliveryDate ?? undefined; newForm.estimatedCompletionDate = model.estimatedCompletionDate ?? undefined; newForm.possessionDate = model.possessionDate ?? undefined;