Skip to content

Commit

Permalink
Merge pull request #54 from companieshouse/feature/DSND-2107-psc-bug-fix
Browse files Browse the repository at this point in the history
add/ident bug fix
  • Loading branch information
maddytjCH authored Nov 15, 2023
2 parents 07ebf4d + 1e0415f commit abb1a95
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<!-- Internal -->
<structured-logging.version>1.9.14</structured-logging.version>
<private-api-sdk-java.version>2.0.310</private-api-sdk-java.version>
<private-api-sdk-java.version>2.0.326</private-api-sdk-java.version>
<data-sync-api-sdk-java.version>1.0.4</data-sync-api-sdk-java.version>
<api-security-java.version>0.4.1</api-security-java.version>
<api-sdk-manager-java-library.version>1.0.4</api-sdk-manager-java-library.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Address(uk.gov.companieshouse.api.psc.Address address) {
this.country = address.getCountry();
this.locality = address.getLocality();
this.postalCode = address.getPostalCode();
this.premises = address.getPremise();
this.premises = address.getPremises();
this.region = address.getRegion();
this.careOf = address.getCareOf();
this.poBox = address.getPoBox();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Objects;

import org.springframework.data.mongodb.core.mapping.Field;
import uk.gov.companieshouse.api.psc.Identification;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class PscData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public Individual transformPscDocToIndividual(
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
individual.setAddress(address);
individual.setAddress(convertAddress(address));
}
if (pscDocument.getData().getNaturesOfControl() != null) {
individual.setNaturesOfControl(pscDocument.getData().getNaturesOfControl());
Expand Down Expand Up @@ -248,7 +248,7 @@ public IndividualBeneficialOwner transformPscDocToIndividualBeneficialOwner(
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
individualBeneficialOwner.setAddress(address);
individualBeneficialOwner.setAddress(convertToBoAddress(address));
}
if (pscDocument.getData().getNaturesOfControl() != null) {
individualBeneficialOwner
Expand Down Expand Up @@ -421,7 +421,7 @@ public CorporateEntity transformPscDocToCorporateEntity(
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
corporateEntity.setAddress(address);
corporateEntity.setAddress(convertAddress(address));
}
if (pscDocument.getIdentification() != null) {
Identification identification = new Identification();
Expand Down Expand Up @@ -597,7 +597,7 @@ public CorporateEntityBeneficialOwner transformPscDocToCorporateEntityBeneficial
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
corporateEntityBeneficialOwner.setAddress(address);
corporateEntityBeneficialOwner.setAddress(convertToBoAddress(address));
}
if (pscDocument.getData().getNaturesOfControl() != null) {
corporateEntityBeneficialOwner
Expand Down Expand Up @@ -697,7 +697,7 @@ public LegalPerson transformPscDocToLegalPerson(Optional<PscDocument> optionalPs
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
legalPerson.setAddress(address);
legalPerson.setAddress(convertAddress(address));
}
if (pscDocument.getData().getNaturesOfControl() != null) {
legalPerson
Expand Down Expand Up @@ -785,7 +785,7 @@ public LegalPersonBeneficialOwner transformPscDocToLegalPersonBeneficialOwner(
if (pscDocument.getData().getAddress().getPoBox() != null) {
address.setPoBox(pscDocument.getData().getAddress().getPoBox());
}
legalPersonBeneficialOwner.setAddress(address);
legalPersonBeneficialOwner.setAddress(convertToBoAddress(address));
}
if (pscDocument.getData().getNaturesOfControl() != null) {
legalPersonBeneficialOwner
Expand Down Expand Up @@ -817,7 +817,35 @@ public LegalPersonBeneficialOwner transformPscDocToLegalPersonBeneficialOwner(
logger.error("Skipped transforming pscDoc to Legal Person");
throw new ResourceNotFoundException(HttpStatus.NOT_FOUND,"PscDocument not found");
}


}

private uk.gov.companieshouse.api.psc.Address convertAddress(
uk.gov.companieshouse.pscdataapi.models.Address inputAddress) {
uk.gov.companieshouse.api.psc.Address address =
new uk.gov.companieshouse.api.psc.Address();
address.setAddressLine1(inputAddress.getAddressLine1());
address.setAddressLine2(inputAddress.getAddressLine2());
address.setCountry(inputAddress.getCountry());
address.setLocality(inputAddress.getLocality());
address.setPoBox(inputAddress.getPoBox());
address.setPostalCode(inputAddress.getPostalCode());
address.setPremises(inputAddress.getPremises());
address.setRegion(inputAddress.getRegion());
return address;
}

private uk.gov.companieshouse.api.psc.BeneficialOwnerAddress convertToBoAddress(
uk.gov.companieshouse.pscdataapi.models.Address inputAddress) {
uk.gov.companieshouse.api.psc.BeneficialOwnerAddress address =
new uk.gov.companieshouse.api.psc.BeneficialOwnerAddress();
address.setAddressLine1(inputAddress.getAddressLine1());
address.setAddressLine2(inputAddress.getAddressLine2());
address.setCountry(inputAddress.getCountry());
address.setLocality(inputAddress.getLocality());
address.setPoBox(inputAddress.getPoBox());
address.setPostalCode(inputAddress.getPostalCode());
address.setPremises(inputAddress.getPremises());
address.setRegion(inputAddress.getRegion());
return address;
}
}

0 comments on commit abb1a95

Please sign in to comment.