Skip to content

Commit

Permalink
SSCSCI-1356 fixing draft appeals for IBC (#4177)
Browse files Browse the repository at this point in the history
* SSCSCI-1356 fixing draft appeals for IBC

* SSCSCI-1356 pointing to PR

* sonar fixes

* checkstyle fix

* sya flag on

* Update values.preview.template.yaml
  • Loading branch information
nilay913 authored Dec 12, 2024
1 parent d2b5462 commit 15f4f54
Show file tree
Hide file tree
Showing 15 changed files with 899 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package uk.gov.hmcts.reform.sscs.model.draft;

import lombok.Value;

@Value
public class SessionAppellantIbcRole {
String ibcRole;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package uk.gov.hmcts.reform.sscs.model.draft;

import lombok.Value;

@Value
public class SessionAppellantIbcaReference {
String ibcaReference;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class SessionContactDetails {
private String addressLine2;
private String townCity;
private String county;
private String country;
private String postCode;
private String portOfEntry;
private String phoneNumber;
private String emailAddress;
private String postcodeLookup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,21 @@ public class SessionDraft {
@JsonProperty("AppellantNINO")
SessionAppellantNino appellantNino;

@JsonProperty("AppellantIBCAReference")
SessionAppellantIbcaReference appellantIbcaReference;

@JsonProperty("AppellantRole")
SessionAppellantIbcRole appellantIbcRole;

@JsonProperty("AppellantInMainlandUk")
SessionInMainlandUk appellantInMainlandUk;

@JsonProperty("AppellantContactDetails")
SessionContactDetails appellantContactDetails;

@JsonProperty("AppellantInternationalContactDetails")
SessionContactDetails appellantInternationalContactDetails;

@JsonProperty("SameAddress")
SessionSameAddress sameAddress;

Expand All @@ -87,6 +99,12 @@ public class SessionDraft {
@JsonProperty("Representative")
SessionRepresentative representative;

@JsonProperty("RepresentativeInMainlandUk")
SessionInMainlandUk representativeInMainlandUk;

@JsonProperty("RepresentativeInternationalDetails")
SessionRepresentativeDetails representativeInternationalDetails;

@JsonProperty("RepresentativeDetails")
SessionRepresentativeDetails representativeDetails;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package uk.gov.hmcts.reform.sscs.model.draft;

import lombok.Value;

@Value
public class SessionInMainlandUk {
String inMainlandUk;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class SessionRepresentativeDetails {
private String addressLine2;
private String townCity;
private String county;
private String country;
private String postCode;
private String phoneNumber;
private String emailAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,25 @@ public SessionDraft convert(SscsCaseData caseData) {
.dwpIssuingOfficeEsa(buildDwpIssuingOfficeEsa(appeal))
.appointeeName(buildName(getAppointeeName(appeal)))
.appointeeDob(buildDob(getAppointeeIdentity(appeal)))
.appointeeContactDetails(buildContactDetails(getAppointeeAddress(appeal), getAppointeeContact(appeal)))
.appointeeContactDetails(buildContactDetails(getAppointeeAddress(appeal), getAppointeeContact(appeal), YesNo.NO))
.appointee(buildAppointee(appeal))
.appellantName(buildName(getAppellantName(appeal)))
.appellantDob(buildDob(getAppellantIdentity(appeal)))
.appellantNino(buildAppellantNino(appeal))
.appellantContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal)))
.appellantIbcaReference(getAppellantIbcaReference(appeal))
.appellantIbcRole(getAppellantIbcRole(appeal))
.appellantInMainlandUk(getAppellantInMainlandUk(appeal))
.appellantContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal), YesNo.NO))
.appellantInternationalContactDetails(buildContactDetails(getAppellantAddress(appeal), getAppellantContact(appeal), YesNo.YES))
.sameAddress(buildSameAddress(appeal))
.textReminders(buildTextReminders(caseData.getSubscriptions()))
.sendToNumber(buildSendToNumber(caseData))
.enterMobile(buildEnterMobile(caseData))
.smsConfirmation(buildSmsConfirmation(caseData))
.representative(buildRepresentative(appeal))
.representativeDetails(buildRepresentativeDetails(appeal))
.representativeInMainlandUk(getRepresentativeInMainlandUk(appeal))
.representativeDetails(buildRepresentativeDetails(appeal, YesNo.NO))
.representativeInternationalDetails(buildRepresentativeDetails(appeal, YesNo.YES))
.reasonForAppealing(buildReasonForAppealing(appeal))
.otherReasonForAppealing(buildOtherReasonForAppealing(appeal))
.evidenceProvide(buildEvidenceProvide(caseData.getEvidencePresent()))
Expand Down Expand Up @@ -287,7 +293,15 @@ private SessionRepresentative buildRepresentative(Appeal appeal) {
return new SessionRepresentative(StringUtils.lowerCase(appeal.getRep().getHasRepresentative()));
}

private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal) {
private SessionInMainlandUk getRepresentativeInMainlandUk(Appeal appeal) {
if (!hasRep(appeal) || appeal.getRep().getAddress() == null || appeal.getRep().getAddress().getInMainlandUk() == null) {
return null;
}

return new SessionInMainlandUk(appeal.getRep().getAddress().getInMainlandUk().getValue().toLowerCase());
}

private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal, YesNo international) {
SessionRepresentative sessionRepresentative = buildRepresentative(appeal);
if (!hasRep(appeal)
|| sessionRepresentative == null
Expand All @@ -307,12 +321,16 @@ private SessionRepresentativeDetails buildRepresentativeDetails(Appeal appeal) {
boolean hasAddress = appeal.getRep().getAddress() != null;
boolean hasContact = appeal.getRep().getContact() != null;

if (hasAddress && international.equals(appeal.getRep().getAddress().getInMainlandUk())) {
return null;
}
return new SessionRepresentativeDetails(
repName,
hasAddress ? appeal.getRep().getAddress().getLine1() : null,
hasAddress ? appeal.getRep().getAddress().getLine2() : null,
hasAddress ? appeal.getRep().getAddress().getTown() : null,
hasAddress ? appeal.getRep().getAddress().getCounty() : null,
hasAddress ? appeal.getRep().getAddress().getCountry() : null,
hasAddress ? appeal.getRep().getAddress().getPostcode() : null,
hasContact ? appeal.getRep().getContact().getMobile() : null,
hasContact ? appeal.getRep().getContact().getEmail() : null,
Expand Down Expand Up @@ -512,6 +530,35 @@ private SessionAppellantNino buildAppellantNino(Appeal appeal) {
return new SessionAppellantNino(appeal.getAppellant().getIdentity().getNino());
}

private SessionAppellantIbcaReference getAppellantIbcaReference(Appeal appeal) {
if (appeal.getAppellant() == null
|| appeal.getAppellant().getIdentity() == null
|| appeal.getAppellant().getIdentity().getIbcaReference() == null) {
return null;
}

return new SessionAppellantIbcaReference(appeal.getAppellant().getIdentity().getIbcaReference());
}

private SessionAppellantIbcRole getAppellantIbcRole(Appeal appeal) {
if (appeal.getAppellant() == null
|| appeal.getAppellant().getIbcRole() == null) {
return null;
}

return new SessionAppellantIbcRole(appeal.getAppellant().getIbcRole());
}

private SessionInMainlandUk getAppellantInMainlandUk(Appeal appeal) {
if (appeal.getAppellant() == null
|| appeal.getAppellant().getAddress() == null
|| appeal.getAppellant().getAddress().getInMainlandUk() == null) {
return null;
}

return new SessionInMainlandUk(appeal.getAppellant().getAddress().getInMainlandUk().getValue().toLowerCase());
}

private Address getAppellantAddress(Appeal appeal) {
if (appeal.getAppellant() == null) {
return null;
Expand Down Expand Up @@ -544,16 +591,18 @@ private Contact getAppointeeContact(Appeal appeal) {
return appeal.getAppellant().getAppointee().getContact();
}

private SessionContactDetails buildContactDetails(Address address, Contact contact) {
if (address == null || address.getLine1() == null) {
private SessionContactDetails buildContactDetails(Address address, Contact contact, YesNo international) {
if (address == null || address.getLine1() == null || international.equals(address.getInMainlandUk())) {
return null;
}
return new SessionContactDetails(
address.getLine1(),
address.getLine2(),
address.getTown(),
address.getCounty(),
address.getCountry(),
address.getPostcode(),
address.getPortOfEntry(),
contact.getMobile(),
contact.getEmail(),
StringUtils.isEmpty(address.getPostcodeLookup()) ? null : address.getPostcodeLookup(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ public void givenGetDraftIsCalled_shouldReturn200AndTheDraft() throws Exception
"line2",
"town-city",
"county",
null,
"AP1 4NT",
null,
"07000000000",
"appellant@test.com",
null,
Expand Down Expand Up @@ -478,7 +480,9 @@ public void givenGetDraftWithRepIsCalled_shouldReturn200AndTheDraft() throws Exc
"line2",
"town-city",
"county",
null,
"AP1 4NT",
null,
"07000000000",
"appellant@test.com",
null,
Expand All @@ -500,6 +504,7 @@ public void givenGetDraftWithRepIsCalled_shouldReturn200AndTheDraft() throws Exc
"rep-line2",
"rep-town-city",
"rep-county",
null,
"RE7 7ES",
"07222222222",
"representative@test.com",
Expand Down Expand Up @@ -576,7 +581,9 @@ public void givenGetDraftWithAppointeeIsCalled_shouldReturn200AndTheDraft() thro
"tee-line2",
"tee-town-city",
"tee-county",
null,
"AP1 33T",
null,
"07111111111",
"appointee@test.com",
null,
Expand Down
Loading

0 comments on commit 15f4f54

Please sign in to comment.