Skip to content

Commit e66f12f

Browse files
mazzopardi2Gautham059andrewdami11arun-hmctslibanAbdirahman1
authored
HDPI-7401 - Add additional defendants DOB and Addresses in two pages (#2114)
Co-authored-by: Gautham059 <gautham.bhikkumalla@hmcts.net> Co-authored-by: Andrew Ajube <andrew.ajube@hmcts.net> Co-authored-by: arun-hmcts <73122505+arun-hmcts@users.noreply.github.com> Co-authored-by: libanAbdirahman1 <Liban.Abdirahman@HMCTS.NET> Co-authored-by: SameenaHMCTS <sameena.javeed@hmcts.net> Co-authored-by: Simon Middleton <simon.middleton@solirius.com> Co-authored-by: scottstewart-sl <202802468+scottstewart-sl@users.noreply.github.com> Co-authored-by: Alex Buzea <60071473+AlexBuzea@users.noreply.github.com> Co-authored-by: guygrewal77 <163517291+guygrewal77@users.noreply.github.com> Co-authored-by: Fahra Akhlaq <f.akhlaq@outlook.com> Co-authored-by: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Rupali Lowalekar <Rupali.Lowalekar@HMCTS.NET> Co-authored-by: Lovelin <lovelin.marcus@hmcts.net>
1 parent 4cba3e5 commit e66f12f

4 files changed

Lines changed: 37 additions & 15 deletions

File tree

src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/respondpossessionclaim/ClaimResponseService.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void saveDraftDataForPartyInternal(PossessionClaimResponse dataFromDraft
8080
*/
8181
private void updatePartyContactDetails(PartyEntity party, DefendantContactDetails defendantContactDetails,
8282
DefendantResponses defendantResponses) {
83-
boolean nameNotConfirmed = defendantResponses.getDefendantNameConfirmation() == null;
83+
boolean nameNotConfirmed = defendantResponses.getDefendantNameConfirmation() != VerticalYesNo.YES;
8484

8585
if (nameNotConfirmed && StringUtils.isNotBlank(defendantContactDetails.getParty().getFirstName())) {
8686
party.setFirstName(defendantContactDetails.getParty().getFirstName());
@@ -92,6 +92,12 @@ private void updatePartyContactDetails(PartyEntity party, DefendantContactDetail
9292
log.debug("Updated last name for party ID: {}", party.getId());
9393
}
9494

95+
if (nameNotConfirmed
96+
&& (StringUtils.isNotBlank(defendantContactDetails.getParty().getFirstName())
97+
|| StringUtils.isNotBlank(defendantContactDetails.getParty().getLastName()))) {
98+
party.setNameKnown(VerticalYesNo.YES);
99+
}
100+
95101
if (defendantContactDetails.getParty().getDateOfBirth() != null) {
96102
party.setDateOfBirth(defendantContactDetails.getParty().getDateOfBirth());
97103
log.debug("Updated date of birth for party ID: {}", party.getId());
@@ -109,10 +115,12 @@ private void updatePartyContactDetails(PartyEntity party, DefendantContactDetail
109115
}
110116

111117
AddressUK newAddress = defendantContactDetails.getParty().getAddress();
112-
// Only override the party address when claimant did not provide it
113-
// and property address was shown as a fallback for user to confirm or enter a new address
114118
boolean isFallbackScenario = defendantResponses.getPropertyAddressConfirmation() != null;
115-
if (isFallbackScenario && newAddress != null && StringUtils.isNotBlank(newAddress.getAddressLine1())) {
119+
boolean disputedCorrespondenceAddress =
120+
defendantResponses.getCorrespondenceAddressConfirmation() == VerticalYesNo.NO;
121+
boolean hasNewAddress = newAddress != null && StringUtils.isNotBlank(newAddress.getAddressLine1());
122+
123+
if ((isFallbackScenario || disputedCorrespondenceAddress) && hasNewAddress) {
116124
AddressEntity existingAddress = party.getAddress();
117125

118126
if (existingAddress != null) {
@@ -126,13 +134,10 @@ private void updatePartyContactDetails(PartyEntity party, DefendantContactDetail
126134
} else {
127135
party.setAddress(modelMapper.map(newAddress, AddressEntity.class));
128136
}
137+
party.setAddressKnown(VerticalYesNo.YES);
129138
}
130139

131-
// Defendant disagreed with the claim-recorded address and supplied a different one,
132-
// so addressSameAsProperty no longer holds. On YES we leave the claim-time value alone:
133-
// claim YES + def YES → property still applies ✓
134-
// claim NO + def YES → claimant-typed (on party.address) still applies ✓
135-
if (defendantResponses.getCorrespondenceAddressConfirmation() == VerticalYesNo.NO) {
140+
if (disputedCorrespondenceAddress) {
136141
party.setAddressSameAsProperty(VerticalYesNo.NO);
137142
}
138143
}

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/PartiesView.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ private Party toParty(PartyEntity entity) {
9090
}
9191

9292
private Party toPartialParty(PartyEntity entity) {
93-
Party.PartyBuilder builder = Party.builder()
93+
return Party.builder()
9494
.firstName(entity.getFirstName())
9595
.lastName(entity.getLastName())
96-
.orgName(entity.getOrgName());
97-
98-
return builder.build();
96+
.orgName(entity.getOrgName())
97+
.nameKnown(entity.getNameKnown())
98+
.address(convertAddress(entity.getAddress()))
99+
.addressKnown(entity.getAddressKnown())
100+
.addressSameAsProperty(entity.getAddressSameAsProperty())
101+
.dateOfBirth(entity.getDateOfBirth())
102+
.build();
99103
}
100104

101105
private LegalRepresentative buildLegalRepresentative(PartyEntity partyEntity) {

src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimResponseServiceTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ void shouldUpdateAddressWhenClaimantDidNotProvideIt() {
344344

345345
// Then
346346
assertThat(testParty.getAddress()).isEqualTo(addressEntity);
347+
assertThat(testParty.getAddressKnown()).isEqualTo(VerticalYesNo.YES);
347348
}
348349

349350
@Test

src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/PartiesViewTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole;
1818
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
1919
import uk.gov.hmcts.reform.pcs.ccd.domain.Party;
20+
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
2021
import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity;
2122
import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity;
2223
import uk.gov.hmcts.reform.pcs.ccd.entity.party.ClaimPartyEntity;
@@ -25,6 +26,7 @@
2526
import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole;
2627
import uk.gov.hmcts.reform.pcs.security.SecurityContextService;
2728

29+
import java.time.LocalDate;
2830
import java.util.List;
2931
import java.util.UUID;
3032

@@ -95,6 +97,14 @@ void shouldMapPartialPartyOfOtherCitizenUsers() {
9597

9698
PartyEntity otherParty = buildParty(UUID.randomUUID(), "John", "Smith", "Org B",
9799
"john@example.com", "07700000002");
100+
otherParty.setDateOfBirth(LocalDate.of(1985, 7, 20));
101+
AddressEntity addressEntity = AddressEntity.builder().addressLine1("1 Other Street").build();
102+
otherParty.setAddress(addressEntity);
103+
otherParty.setAddressKnown(VerticalYesNo.YES);
104+
when(modelMapper.map(addressEntity, AddressUK.class)).thenReturn(
105+
AddressUK.builder().addressLine1("1 Other Street").build()
106+
);
107+
98108
ClaimPartyEntity claimParty = buildClaimPartyEntity(otherParty, PartyRole.DEFENDANT);
99109
when(claimEntity.getClaimParties()).thenReturn(List.of(claimParty));
100110

@@ -108,8 +118,10 @@ void shouldMapPartialPartyOfOtherCitizenUsers() {
108118
assertThat(party.getOrgName()).isEqualTo("Org B");
109119
assertThat(party.getEmailAddress()).isNull();
110120
assertThat(party.getPhoneNumber()).isNull();
111-
assertThat(party.getDateOfBirth()).isNull();
112-
assertThat(party.getAddress()).isNull();
121+
assertThat(party.getLegalRepresentative()).isNull();
122+
assertThat(party.getDateOfBirth()).isEqualTo(LocalDate.of(1985, 7, 20));
123+
assertThat(party.getAddress()).isNotNull();
124+
assertThat(party.getAddress().getAddressLine1()).isEqualTo("1 Other Street");
113125
}
114126

115127
@Test

0 commit comments

Comments
 (0)