Skip to content

Commit

Permalink
Merge branch 'PSP-9471' of https://github.com/stairaku/PSP into PSP-9471
Browse files Browse the repository at this point in the history
  • Loading branch information
stairaku committed Dec 24, 2024
2 parents 991b36d + 914c15e commit acb5b41
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 16 deletions.
2 changes: 1 addition & 1 deletion source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.7.0-96.5</Version>
<Version>5.7.0-96.6</Version>
<AssemblyVersion>5.7.0.96</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>{16BC0468-78F6-4C91-87DA-7403C919E646}</ProjectGuid>
Expand Down
3 changes: 3 additions & 0 deletions source/backend/api/Services/AcquisitionFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AcquisitionFileModel : FileWithChecklistModel
/// <summary>
/// The assigned date.
/// </summary>
public DateTime? AssignedDate { get; set; }
public DateOnly? AssignedDate { get; set; }

/// <summary>
/// The date for delivery of the property to the project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,62 @@ public void Add_Success()
repository.Verify(x => x.Add(It.IsAny<PimsAcquisitionFile>()), 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<Mock<IAcquisitionFileRepository>>();
repository.Setup(x => x.Add(It.IsAny<PimsAcquisitionFile>())).Returns(acqFile);

var lookupRepository = this._helper.GetService<Mock<ILookupRepository>>();
lookupRepository.Setup(x => x.GetAllRegions()).Returns(new List<PimsRegion>() { new PimsRegion() { Code = 4, RegionName = "Cannot determine" } });

var userRepository = this._helper.GetService<Mock<IUserRepository>>();
userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny<Guid>())).Returns(EntityHelper.CreateUser(1, Guid.NewGuid(), "Test", regionCode: 1));

// Act
var result = service.Add(acqFile, new List<UserOverrideCode>());

// Assert
repository.Verify(x => x.Add(It.IsAny<PimsAcquisitionFile>()), 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<Mock<IAcquisitionFileRepository>>();
repository.Setup(x => x.Add(It.IsAny<PimsAcquisitionFile>())).Returns(acqFile);

var lookupRepository = this._helper.GetService<Mock<ILookupRepository>>();
lookupRepository.Setup(x => x.GetAllRegions()).Returns(new List<PimsRegion>() { new PimsRegion() { Code = 4, RegionName = "Cannot determine" } });

var userRepository = this._helper.GetService<Mock<IUserRepository>>();
userRepository.Setup(x => x.GetUserInfoByKeycloakUserId(It.IsAny<Guid>())).Returns(EntityHelper.CreateUser(1, Guid.NewGuid(), "Test", regionCode: 1));

// Act
var result = service.Add(acqFile, new List<UserOverrideCode>());

// Assert
repository.Verify(x => x.Add(It.IsAny<PimsAcquisitionFile>()), Times.Once);
result.AssignedDate.Should().Be(customDate);
result.AcquisitionFileStatusTypeCode.Should().Be(AcquisitionStatusTypes.ACTIVE.ToString());
}

[Fact]
public void Add_CannotDetermineRegion_Error()
{
Expand Down
2 changes: 1 addition & 1 deletion source/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "5.7.0-96.5",
"version": "5.7.0-96.6",
"private": true,
"dependencies": {
"@bcgov/bc-sans": "1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ exports[`AcquisitionView component > renders as expected 1`] = `
class="c35 text-left col"
data-testid="assigned-date"
>
Dec 17, 2024
Dec 18, 2024
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ exports[`AcquisitionFileTabs component > matches snapshot 1`] = `
class="c7 text-left col"
data-testid="assigned-date"
>
Dec 17, 2024
Dec 18, 2024
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('AcquisitionSummaryView component', () => {
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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -94,7 +94,7 @@ const AcquisitionSummaryView: React.FC<IAcquisitionSummaryViewProps> = ({
</Section>
<Section header="Schedule">
<SectionField label="Assigned date" valueTestId="assigned-date">
{prettyFormatUTCDate(detail.assignedDate)}
{prettyFormatDate(detail.assignedDate)}
</SectionField>
<SectionField
label="Delivery date"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ exports[`AcquisitionSummaryView component > matches snapshot 1`] = `
class="c5 text-left col"
data-testid="assigned-date"
>
Dec 17, 2024
Dec 18, 2024
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('UpdateAcquisitionForm component', () => {
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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
</div>
</div>
Expand Down Expand Up @@ -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"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit acb5b41

Please sign in to comment.