Skip to content

Commit

Permalink
Merge branch 'master' into PO-154
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS authored Jan 22, 2024
2 parents d0f5c01 + a676603 commit f933c71
Show file tree
Hide file tree
Showing 27 changed files with 855 additions and 230 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ dependencies {
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'


testImplementation 'com.github.fge:json-schema-validator:2.2.14'
testImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'

testImplementation 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
testImplementation 'org.testcontainers:junit-jupiter:1.19.3'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountActivitiesDto {

@JsonProperty(value = "account_activity")
private List<AccountActivityDto> accountActivity;

}
37 changes: 37 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonRootName(value = "account_activity")
public class AccountActivityDto {

@JsonProperty("activity_id")
private Integer activityId;

@JsonProperty("activity_type")
private String activityType;

@JsonProperty("activity_type_code")
private String activityTypeCode;

@JsonProperty("activity_text")
private String activityText;

@JsonProperty("posted_date")
private String postedDate;

@JsonProperty("posted_by")
private String postedBy;

@JsonProperty("amount")
private Double amount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DefendantAccountDto {

@JsonProperty("defendant_account_id")
private Long defendantAccountId;
@JsonProperty("account_number")
private String accountNumber;
@JsonProperty("amount_imposed")
private BigDecimal amountImposed;
@JsonProperty("amount_paid")
private BigDecimal amountPaid;
@JsonProperty("account_balance")
private BigDecimal accountBalance;
@JsonProperty("business_unit_id")
private int businessUnitId;
@JsonProperty("business_unit_name")
private String businessUnitName;
@JsonProperty("account_status")
private String accountStatus;
@JsonProperty("originator_name")
private String originatorName;
@JsonProperty("imposed_hearing_date")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate imposedHearingDate;
@JsonProperty("imposing_court_code")
private int imposingCourtCode;
@JsonProperty("last_hearing_date")
private String lastHearingDate;
@JsonProperty("last_hearing_court_code")
private int lastHearingCourtCode;
@JsonProperty("last_changed_date")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate lastChangedDate;
@JsonProperty("last_movement_date")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate lastMovementDate;
@JsonProperty("collection_order")
private boolean collectionOrder;
@JsonProperty("enforcing_court_code")
private int enforcingCourtCode;
@JsonProperty("last_enforcement")
private String lastEnforcement;
@JsonProperty("enf_override_result_id")
private String enfOverrideResultId;
@JsonProperty("enf_override_enforcer_code")
private Short enfOverrideEnforcerCode;
@JsonProperty("enf_override_tfo_lja_code")
private int enfOverrideTfoLjaCode;
@JsonProperty("prosecutor_case_reference")
private String prosecutorCaseReference;
@JsonProperty("account_comments")
private String accountComments;
@JsonProperty("payment_terms")
private PaymentTermsDto paymentTerms;
@JsonProperty("parties")
private PartiesDto parties;
@JsonProperty("impositions")
private ImpositionsDto impositions;
@JsonProperty("account_activities")
private AccountActivitiesDto accountActivities;

}
46 changes: 46 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/ImpositionDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonRootName(value = "imposition")
public class ImpositionDto {
@JsonProperty("imposition_id")
private Integer impositionId;

@JsonProperty("posted_date")
private String postedDate;

@JsonProperty("result_id")
private String resultId;

@JsonProperty("imposed_date")
private String imposedDate;

@JsonProperty("imposing_court_code")
private Integer imposingCourtCode;

@JsonProperty("imposed_amount")
private Double imposedAmount;

@JsonProperty("paid_amount")
private Double paidAmount;

@JsonProperty("offence_title")
private String offenceTitle;

@JsonProperty("creditor_account_number")
private String creditorAccountNumber;

@JsonProperty("creditor_name")
private String creditorName;

}
20 changes: 20 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/ImpositionsDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ImpositionsDto {

@JsonProperty(value = "imposition")
private List<ImpositionDto> imposition;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;
import uk.gov.hmcts.opal.dto.ToJsonString;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Jacksonized
public class LegacyAccountDetailsRequestDto implements ToJsonString {

//defendant_accounts.defendant_account_id
@JsonProperty("defendant_account_id")
private Long defendantAccountId;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;
import uk.gov.hmcts.opal.dto.AccountDetailsDto;
import uk.gov.hmcts.opal.dto.ToJsonString;
import uk.gov.hmcts.opal.service.DefendantAccountService;

import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Jacksonized
public class LegacyAccountDetailsResponseDto implements ToJsonString {

@JsonProperty("defendant_account")
private DefendantAccountDto defendantAccount;


public static AccountDetailsDto toAccountDetailsDto(LegacyAccountDetailsResponseDto legacy) {

DefendantAccountDto defendantAccountDto = legacy.getDefendantAccount();
PartyDto partyDto = defendantAccountDto.getParties().getParty().get(0);
PaymentTermsDto paymentTermsDto = defendantAccountDto.getPaymentTerms();

return AccountDetailsDto.builder()
.defendantAccountId(defendantAccountDto.getDefendantAccountId())
.accountNumber(defendantAccountDto.getAccountNumber())
.fullName(partyDto.getOrganisation()
? partyDto.getOrganisationName()
: partyDto.getFullName())
.accountCT(defendantAccountDto.getBusinessUnitName())
.address(DefendantAccountService.buildFullAddress(
partyDto.getAddressLine1(),
partyDto.getAddressLine2(),
partyDto.getAddressLine3(),
partyDto.getAddressLine4(),
partyDto.getAddressLine5()
))
.postCode(partyDto.getPostcode())
.dob(partyDto.getBirthDate())
.detailsChanged(defendantAccountDto.getLastChangedDate())
.lastCourtAppAndCourtCode(defendantAccountDto.getLastHearingDate()
+ " " + defendantAccountDto.getLastHearingCourtCode())
.lastMovement(defendantAccountDto.getLastMovementDate())
.commentField(List.of(defendantAccountDto.getAccountComments()))
.pcr(defendantAccountDto.getProsecutorCaseReference())
.paymentDetails(DefendantAccountService.buildPaymentDetails(
paymentTermsDto.getTermsTypeCode(),
paymentTermsDto.getInstalmentAmount(),
paymentTermsDto.getInstalmentPeriod(),
paymentTermsDto.getTermsDate()
))
.lumpSum(paymentTermsDto.getInstalmentLumpSum())
.commencing(paymentTermsDto.getTermsTypeCode().equals("I")
? paymentTermsDto.getTermsDate()
: null)
.daysInDefault(defendantAccountDto.getPaymentTerms().getJailDays())
.sentencedDate(defendantAccountDto.getImposedHearingDate())
.lastEnforcement(defendantAccountDto.getLastEnforcement())
.override(defendantAccountDto.getEnfOverrideResultId())
.enforcer(defendantAccountDto.getEnfOverrideEnforcerCode())
.enforcementCourt(defendantAccountDto.getEnforcingCourtCode())
.imposed(defendantAccountDto.getAmountImposed())
.amountPaid(defendantAccountDto.getAmountPaid())
.balance(defendantAccountDto.getAccountBalance())
.build();
}

}
19 changes: 19 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/legacy/PartiesDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package uk.gov.hmcts.opal.dto.legacy;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PartiesDto {

@JsonProperty(value = "party")
private List<PartyDto> party;
}
Loading

0 comments on commit f933c71

Please sign in to comment.