diff --git a/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java b/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java index ddfde0500..a695b23c7 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java @@ -45,9 +45,12 @@ public class AccountDetailsDto implements ToJsonString { //defendant_accounts.last_movement_date private LocalDate lastMovement; - //notes.note_text + //notes.note_text = AC private List commentField; + //notes.note_text = AA + private String accountNotes; + //defendant_accounts.prosecutor_case_reference private String pcr; diff --git a/src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java b/src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java index 6c0beb2a7..c0f551af4 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/legacy/AccountActivityDto.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.opal.dto.legacy; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; import lombok.AllArgsConstructor; @@ -7,6 +8,8 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.time.LocalDateTime; + @Builder @Data @AllArgsConstructor @@ -27,7 +30,8 @@ public class AccountActivityDto { private String activityText; @JsonProperty("posted_date") - private String postedDate; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime postedDate; @JsonProperty("posted_by") private String postedBy; diff --git a/src/main/java/uk/gov/hmcts/opal/dto/legacy/LegacyAccountDetailsResponseDto.java b/src/main/java/uk/gov/hmcts/opal/dto/legacy/LegacyAccountDetailsResponseDto.java index 2c0d66a13..05d6e59fc 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/legacy/LegacyAccountDetailsResponseDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/legacy/LegacyAccountDetailsResponseDto.java @@ -10,6 +10,7 @@ import uk.gov.hmcts.opal.dto.ToJsonString; import uk.gov.hmcts.opal.service.DefendantAccountService; +import java.util.Comparator; import java.util.List; @Data @@ -28,6 +29,8 @@ public static AccountDetailsDto toAccountDetailsDto(LegacyAccountDetailsResponse DefendantAccountDto defendantAccountDto = legacy.getDefendantAccount(); PartyDto partyDto = defendantAccountDto.getParties().getParty().get(0); PaymentTermsDto paymentTermsDto = defendantAccountDto.getPaymentTerms(); + AccountActivityDto accountActivityDto = getLatestAccountActivity(defendantAccountDto.getAccountActivities() + .getAccountActivity()); return AccountDetailsDto.builder() .defendantAccountId(defendantAccountDto.getDefendantAccountId()) @@ -50,6 +53,7 @@ public static AccountDetailsDto toAccountDetailsDto(LegacyAccountDetailsResponse + " " + defendantAccountDto.getLastHearingCourtCode()) .lastMovement(defendantAccountDto.getLastMovementDate()) .commentField(List.of(defendantAccountDto.getAccountComments())) + .accountNotes(accountActivityDto.getActivityText()) .pcr(defendantAccountDto.getProsecutorCaseReference()) .paymentDetails(DefendantAccountService.buildPaymentDetails( paymentTermsDto.getTermsTypeCode(), @@ -73,4 +77,10 @@ public static AccountDetailsDto toAccountDetailsDto(LegacyAccountDetailsResponse .build(); } + private static AccountActivityDto getLatestAccountActivity(List accountActivities) { + + return accountActivities.stream() + .max(Comparator.comparing(AccountActivityDto::getPostedDate)) + .orElse(new AccountActivityDto()); + } } diff --git a/src/main/java/uk/gov/hmcts/opal/repository/NoteRepository.java b/src/main/java/uk/gov/hmcts/opal/repository/NoteRepository.java index de4f7e23a..6c7c2f023 100644 --- a/src/main/java/uk/gov/hmcts/opal/repository/NoteRepository.java +++ b/src/main/java/uk/gov/hmcts/opal/repository/NoteRepository.java @@ -11,4 +11,7 @@ public interface NoteRepository extends JpaRepository { List findByAssociatedRecordIdAndNoteType(String associatedRecordId, String noteType); + NoteEntity findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc( + String associatedRecordId, String noteType); + } diff --git a/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java b/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java index 063b191b8..e4eb8c305 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java @@ -154,9 +154,13 @@ public AccountDetailsDto getAccountDetailsByDefendantAccountId(Long defendantAcc .getEnforcementOverrideEnforcerId()); //query DB for NoteEntity by associatedRecordId (defendantAccountId) and noteType ("AC") - List noteEntity = noteRepository.findByAssociatedRecordIdAndNoteType( + List noteEntityAC = noteRepository.findByAssociatedRecordIdAndNoteType( defendantAccountEntity.getDefendantAccountId().toString(), "AC"); + //query DB for NoteEntity by associatedRecordId (defendantAccountId) and noteType ("AA") + // returning only latest (postedDate) + NoteEntity noteEntityAA = noteRepository.findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc( + defendantAccountEntity.getDefendantAccountId().toString(), "AA"); //build fullAddress final String fullAddress = buildFullAddress(partyEntity.getAddressLine1(), @@ -172,7 +176,8 @@ public AccountDetailsDto getAccountDetailsByDefendantAccountId(Long defendantAcc paymentTermsEntity.getEffectiveDate()); //build comments - final List comments = buildCommentsFromAssociatedNotes(noteEntity); + final List comments = buildCommentsFromAssociatedNotes(noteEntityAC); + //populate accountDetailsDto and return return AccountDetailsDto.builder() @@ -190,6 +195,7 @@ public AccountDetailsDto getAccountDetailsByDefendantAccountId(Long defendantAcc + " " + defendantAccountEntity.getLastHearingCourtId().getCourtCode()) .lastMovement(defendantAccountEntity.getLastMovementDate()) .commentField(comments) + .accountNotes(noteEntityAA.getNoteText()) .pcr(defendantAccountEntity.getProsecutorCaseReference()) .paymentDetails(paymentDetails) .lumpSum(paymentTermsEntity.getInstalmentLumpSum()) diff --git a/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java index 15c0a92dc..efefbc903 100644 --- a/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java +++ b/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java @@ -181,7 +181,10 @@ void testGetAccountDetailsByDefendantAccountId() { .thenReturn(buildEnforcersEntity()); when(noteRepository.findByAssociatedRecordIdAndNoteType(any(),any())) - .thenReturn(buildNotesEntity()); + .thenReturn(buildNotesEntityComment()); + + when(noteRepository.findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc(any(),any())) + .thenReturn(buildNotesEntityActivity()); //act AccountDetailsDto result = defendantAccountService.getAccountDetailsByDefendantAccountId(1L); @@ -215,7 +218,10 @@ void testGetAccountDetailsByDefendantAccountId_PaymentByDate() { .thenReturn(buildEnforcersEntity()); when(noteRepository.findByAssociatedRecordIdAndNoteType(any(),any())) - .thenReturn(buildNotesEntity()); + .thenReturn(buildNotesEntityComment()); + + when(noteRepository.findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc(any(),any())) + .thenReturn(buildNotesEntityActivity()); AccountDetailsDto expectedDetails = buildAccountDetailsDto(); expectedDetails.setPaymentDetails(LocalDate.of(2012, 1,1).toString() + " By Date"); @@ -252,7 +258,10 @@ void testGetAccountDetailsByDefendantAccountId_PaymentPaid() { .thenReturn(buildEnforcersEntity()); when(noteRepository.findByAssociatedRecordIdAndNoteType(any(),any())) - .thenReturn(buildNotesEntity()); + .thenReturn(buildNotesEntityComment()); + + when(noteRepository.findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc(any(),any())) + .thenReturn(buildNotesEntityActivity()); AccountDetailsDto expectedDetails = buildAccountDetailsDto(); expectedDetails.setPaymentDetails("Paid"); @@ -289,7 +298,10 @@ void testGetAccountDetailsByDefendantAccountId_Organisation() { .thenReturn(buildEnforcersEntity()); when(noteRepository.findByAssociatedRecordIdAndNoteType(any(),any())) - .thenReturn(buildNotesEntity()); + .thenReturn(buildNotesEntityComment()); + + when(noteRepository.findTopByAssociatedRecordIdAndNoteTypeOrderByPostedDateDesc(any(),any())) + .thenReturn(buildNotesEntityActivity()); AccountDetailsDto expectedDetails = buildAccountDetailsDto(); expectedDetails.setFullName("The Bank of England"); @@ -321,6 +333,7 @@ public static AccountDetailsDto buildAccountDetailsDto() { + " " + 1212) .lastMovement(LocalDate.of(2012, 1,1)) .commentField(List.of("Comment1")) + .accountNotes("Activity") .pcr("123456") .paymentDetails("100.0 / PCM") .lumpSum(BigDecimal.valueOf(100.00)) @@ -405,7 +418,7 @@ public static EnforcersEntity buildEnforcersEntity() { .build(); } - public static List buildNotesEntity() { + public static List buildNotesEntityComment() { List notes = new ArrayList<>(); @@ -416,6 +429,14 @@ public static List buildNotesEntity() { return notes; } + public static NoteEntity buildNotesEntityActivity() { + + return NoteEntity.builder() + .noteType("AA") + .noteText("Activity") + .build(); + } + private class TestDefendantAccountSummary implements DefendantAccountSummary { @Override diff --git a/src/test/java/uk/gov/hmcts/opal/service/LegacyDefendantAccountServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/LegacyDefendantAccountServiceTest.java index a3bf02aed..6e17953c6 100644 --- a/src/test/java/uk/gov/hmcts/opal/service/LegacyDefendantAccountServiceTest.java +++ b/src/test/java/uk/gov/hmcts/opal/service/LegacyDefendantAccountServiceTest.java @@ -21,8 +21,12 @@ import uk.gov.hmcts.opal.dto.AccountSearchDto; import uk.gov.hmcts.opal.dto.AccountSearchResultsDto; import uk.gov.hmcts.opal.dto.ToJsonString; +import uk.gov.hmcts.opal.dto.legacy.AccountActivitiesDto; +import uk.gov.hmcts.opal.dto.legacy.AccountActivityDto; import uk.gov.hmcts.opal.dto.legacy.DefendantAccountDto; import uk.gov.hmcts.opal.dto.legacy.DefendantAccountSearchResult; +import uk.gov.hmcts.opal.dto.legacy.ImpositionDto; +import uk.gov.hmcts.opal.dto.legacy.ImpositionsDto; import uk.gov.hmcts.opal.dto.legacy.LegacyAccountDetailsRequestDto; import uk.gov.hmcts.opal.dto.legacy.LegacyAccountDetailsResponseDto; import uk.gov.hmcts.opal.dto.legacy.PartiesDto; @@ -38,6 +42,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -459,6 +464,8 @@ private DefendantAccountDto buildDefendantAccountDto() { .lastEnforcement("ENF") .prosecutorCaseReference("123456") .accountComments("Comment1") + .accountActivities(buildAccountActivitiesDto()) + .impositions(buildImpositionsDto()) .build(); } @@ -482,6 +489,7 @@ private PartyDto buildPartyDto() { .fullName("Mr John Smith") .organisation(false) .birthDate(LocalDate.of(1979,12,12)) + .lastChangedDate("2020-02-02") .build(); } @@ -494,6 +502,59 @@ private PaymentTermsDto buildPaymentTermsDto() { .termsDate(LocalDate.of(2012, 1,1)) .jailDays(10) .instalmentLumpSum(BigDecimal.valueOf(100.00)) + .wording("wording") + .build(); + } + + private AccountActivitiesDto buildAccountActivitiesDto() { + + return AccountActivitiesDto.builder() + .accountActivity(List.of(buildAccountActivityDto(),buildAccountActivityDtoOlder())) + .build(); + } + + private AccountActivityDto buildAccountActivityDto() { + + return AccountActivityDto.builder() + .activityId(1) + .activityText("Activity") + .activityType("Activity") + .activityTypeCode("AA") + .postedDate(LocalDateTime.of(2021, 1,1, 21,0,0)) + .build(); + } + + private ImpositionsDto buildImpositionsDto() { + + return ImpositionsDto.builder() + .imposition(List.of(buildImpositionDto())) + .build(); + } + + private ImpositionDto buildImpositionDto() { + + return ImpositionDto.builder() + .creditorAccountNumber("123") + .creditorName("John") + .imposedAmount(1000.00) + .imposedDate("2020-01-01") + .imposingCourtCode(12) + .impositionId(1) + .offenceTitle("A title") + .paidAmount(100.00) + .postedDate("2020-01-01") + .resultId("1") + .build(); + } + + private AccountActivityDto buildAccountActivityDtoOlder() { + + return AccountActivityDto.builder() + .activityId(2) + .activityText("Activity OLD") + .activityType("Activity") + .activityTypeCode("AA") + .postedDate(LocalDateTime.of(2020, 1,1, 21,0,0)) .build(); } diff --git a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_in.json b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_in.json index f8bfd8716..7a135cca8 100644 --- a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_in.json +++ b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_in.json @@ -1,10 +1,6 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "defendant_account_id": { - "type": "integer" + "$schema": "https://json-schema.org/draft-07/schema#", + "properties": { + "defendant_account_id": {"type": "integer"} } - }, - "required": ["defendant_account_id"] -} +} \ No newline at end of file diff --git a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.json b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.json index 87653ce06..75a495818 100644 --- a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.json +++ b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.json @@ -1,126 +1,218 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "defendant_account": { - "type": "object", - "properties": { - "defendant_account_id": { "type": "integer" }, - "account_number": { "type": "string" }, - "amount_imposed": { "type": "number" }, - "amount_paid": { "type": "number" }, - "account_balance": { "type": "number" }, - "business_unit_id": { "type": "integer" }, - "business_unit_name": { "type": "string" }, - "account_status": { "type": "string" }, - "originator_name": { "type": "string" }, - "imposed_hearing_date": { "type": "string" }, - "imposing_court_code": { "type": "integer" }, - "last_hearing_date": { "type": "string" }, - "last_hearing_court_code": { "type": "integer" }, - "last_changed_date": { "type": "string" }, - "last_movement_date": { "type": "string" }, - "collection_order": { "type": "boolean" }, - "enforcing_court_code": { "type": "integer" }, - "last_enforcement": { "type": "string" }, - "enf_override_result_id": { "type": "string" }, - "enf_override_enforcer_code": { "type": "integer" }, - "enf_override_tfo_lja_code": { "type": "integer" }, - "prosecutor_case_reference": { "type": "string" }, - "account_comments": { "type": "string" }, - "payment_terms": { - "type": "object", - "properties": { - "terms_date": { "type": "string" }, - "terms_type_code": { "type": "string" }, - "instalment_amount": { "type": "number" }, - "instalment_period": { "type": "string" }, - "instalment_lump_sum": { "type": "number" }, - "jail_days": { "type": "integer" }, - "wording": { "type": "string" } - } + "$schema": "https://json-schema.org/draft-07/schema#", + "definitions": { + "defendant_account.payment_terms": { + "type": "object", + "required": [ + "terms_type_code", + "wording" + ], + "properties": { + "terms_date": { + "type": "string" + }, + "terms_type_code": {"type": "string"}, + "instalment_amount": {"type": "number"}, + "instalment_period": {"type": "string"}, + "instalment_lump_sum": {"type": "number"}, + "jail_days": {"type": "integer"}, + "wording": {"type": "string"} + } + }, + "defendant_account.parties.party": { + "type": "object", + "required": [ + "party_id", + "association_type", + "debtor", + "organisation", + "last_changed_date", + "full_name", + "address_line_1" + ], + "properties": { + "party_id": {"type": "integer"}, + "association_type": {"type": "string"}, + "debtor": {"type": "boolean"}, + "organisation": {"type": "boolean"}, + "organisation_name": {"type": "string"}, + "surname": {"type": "string"}, + "forenames": {"type": "string"}, + "initials": {"type": "string"}, + "title": {"type": "string"}, + "birth_date": { + "type": "string" + }, + "age": {"type": "integer"}, + "national_insurance_number": {"type": "string"}, + "last_changed_date": { + "type": "string" + }, + "full_name": {"type": "string"}, + "address_line_1": {"type": "string"}, + "address_line_2": {"type": "string"}, + "address_line_3": {"type": "string"}, + "address_line_4": {"type": "string"}, + "address_line_5": {"type": "string"}, + "postcode": {"type": "string"} + } + }, + "defendant_account.parties": { + "type": "object", + "required": ["party"], + "properties": { + "party": { + "type": "array", + "items": {"$ref": "#/definitions/defendant_account.parties.party"}, + "maxItems": 2, + "minItems": 1 + } + } }, - "parties": { - "type": "object", - "properties": { - "party": { - "type": "array", - "items": { - "type": "object", - "properties": { - "party_id": { "type": "integer" }, - "association_type": { "type": "string" }, - "debtor": { "type": "boolean" }, - "organisation": { "type": "boolean" }, - "organisation_name": { "type": "string" }, - "surname": { "type": "string" }, - "forenames": { "type": "string" }, - "initials": { "type": "string" }, - "title": { "type": "string" }, - "birth_date": { "type": "string" }, - "age": { "type": "integer" }, - "national_insurance_number": { "type": "string" }, - "last_changed_date": { "type": "string" }, - "full_name": { "type": "string" }, - "address_line_1": { "type": "string" }, - "address_line_2": { "type": "string" }, - "address_line_3": { "type": "string" }, - "address_line_4": { "type": "string" }, - "address_line_5": { "type": "string" }, - "postcode": { "type": "string" } + "defendant_account.impositions.imposition": { + "type": "object", + "required": [ + "imposition_id", + "posted_date", + "result_id", + "imposed_date", + "imposing_court_code", + "imposed_amount", + "paid_amount", + "offence_title", + "creditor_account_number", + "creditor_name" + ], + "properties": { + "imposition_id": {"type": "integer"}, + "posted_date": { + "type": "string" }, - "required": ["party_id", "association_type", "debtor", "organisation", "address_line_1", "postcode"] - } + "result_id": {"type": "string"}, + "imposed_date": { + "type": "string" + }, + "imposing_court_code": {"type": "integer"}, + "imposed_amount": {"type": "number"}, + "paid_amount": {"type": "number"}, + "offence_title": {"type": "string"}, + "creditor_account_number": {"type": "string"}, + "creditor_name": {"type": "string"} + } + }, + "defendant_account.impositions": { + "type": "object", + "required": ["imposition"], + "properties": { + "imposition": { + "type": "array", + "items": {"$ref": "#/definitions/defendant_account.impositions.imposition"}, + "minItems": 1 + } } - } }, - "impositions": { - "type": "object", - "properties": { - "imposition": { - "type": "array", - "items": { - "type": "object", - "properties": { - "imposition_id": { "type": "integer" }, - "posted_date": { "type": "string" }, - "result_id": { "type": "string" }, - "imposed_date": { "type": "string" }, - "imposing_court_code": { "type": "integer" }, - "imposed_amount": { "type": "number" }, - "paid_amount": { "type": "number" }, - "offence_title": { "type": "string" }, - "creditor_account_number": { "type": "string" }, - "creditor_name": { "type": "string" } + "defendant_account.account_activities.account_activity": { + "type": "object", + "required": [ + "activity_id", + "activity_type", + "activity_type_code", + "posted_date" + ], + "properties": { + "activity_id": {"type": "integer"}, + "activity_type": {"type": "string"}, + "activity_type_code": {"type": "string"}, + "activity_text": {"type": "string"}, + "posted_date": { + "type": "string" + }, - "required": ["imposition_id", "posted_date", "result_id", "imposed_date", "offence_title"] - } + "posted_by": {"type": "string"}, + "amount": {"type": "number"} + } + }, + "defendant_account.account_activities": { + "type": "object", + "properties": { + "account_activity": { + "type": "array", + "items": {"$ref": "#/definitions/defendant_account.account_activities.account_activity"}, + "minItems": 0 + } } - } }, - "account_activities": { - "type": "object", - "properties": { - "account_activity": { - "type": "array", - "items": { - "type": "object", - "properties": { - "activity_id": { "type": "integer" }, - "activity_type": { "type": "string" }, - "activity_type_code": { "type": "string" }, - "activity_text": { "type": "string" }, - "posted_date": { "type": "string" }, - "posted_by": { "type": "string" }, - "amount": { "type": "number" } + "defendant_account": { + "type": "object", + "required": [ + "defendant_account_id", + "account_number", + "amount_imposed", + "amount_paid", + "account_balance", + "business_unit_id", + "business_unit_name", + "account_status", + "originator_name", + "imposed_hearing_date", + "imposing_court_code", + "last_hearing_date", + "last_hearing_court_code", + "last_changed_date", + "last_movement_date", + "collection_order", + "enforcing_court_code", + "last_enforcement", + "enf_override_result_id", + "enf_override_enforcer_code", + "enf_override_tfo_lja_code", + "prosecutor_case_reference", + "account_comments", + "payment_terms", + "parties", + "impositions", + "account_activities" + ], + "properties": { + "defendant_account_id": {"type": "integer"}, + "account_number": {"type": "string"}, + "amount_imposed": {"type": "number"}, + "amount_paid": {"type": "number"}, + "account_balance": {"type": "number"}, + "business_unit_id": {"type": "integer"}, + "business_unit_name": {"type": "string"}, + "account_status": {"type": "string"}, + "originator_name": {"type": "string"}, + "imposed_hearing_date": { + "type": "string" + }, + "imposing_court_code": {"type": "integer"}, + "last_hearing_date": { + "type": "string" + }, + "last_hearing_court_code": {"type": "integer"}, + "last_changed_date": { + "type": "string" + }, + "last_movement_date": { + "type": "string" }, - "required": ["activity_id", "activity_type", "posted_date", "activity_text"] - } + "collection_order": {"type": "boolean"}, + "enforcing_court_code": {"type": "integer"}, + "last_enforcement": {"type": "string"}, + "enf_override_result_id": {"type": "string"}, + "enf_override_enforcer_code": {"type": "integer"}, + "enf_override_tfo_lja_code": {"type": "integer"}, + "prosecutor_case_reference": {"type": "string"}, + "account_comments": {"type": "string"}, + "payment_terms": {"$ref": "#/definitions/defendant_account.payment_terms"}, + "parties": {"$ref": "#/definitions/defendant_account.parties"}, + "impositions": {"$ref": "#/definitions/defendant_account.impositions"}, + "account_activities": {"$ref": "#/definitions/defendant_account.account_activities"} } - } } - }, - "required": ["defendant_account_id", "account_number", "amount_imposed", "amount_paid", "account_balance", "business_unit_id", "business_unit_name", "account_status", "originator_name", "imposing_court_code", "last_hearing_date", "last_hearing_court_code", "last_changed_date", "last_movement_date", "collection_order", "enforcing_court_code", "last_enforcement", "prosecutor_case_reference"] + }, + "properties": { + "defendant_account": {"$ref": "#/definitions/defendant_account"} } - } } diff --git a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.xsd b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.xsd index 804594b14..d1c2562ba 100644 --- a/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.xsd +++ b/src/test/resources/schemas/AccountDetails/of_f_get_defendant_account_out.xsd @@ -20,7 +20,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -102,7 +102,7 @@ - + diff --git a/src/test/resources/schemas/AccountNotes/of_create_note_in.json b/src/test/resources/schemas/AccountNotes/of_create_note_in.json index ca78c2aa7..b0b84df69 100644 --- a/src/test/resources/schemas/AccountNotes/of_create_note_in.json +++ b/src/test/resources/schemas/AccountNotes/of_create_note_in.json @@ -1,16 +1,31 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "note": { - "type": "object", - "properties": { - "associated_record_id": { "type": "string" }, - "associated_record_type": { "type": "string", "enum": ["defendant_accounts", "creditor_accounts", "suspense_accounts"] }, - "note_text": { "type": "string" }, - "posted_by": { "type": "string" } - }, - "required": ["associated_record_id", "associated_record_type", "note_text", "posted_by"] + "$schema": "https://json-schema.org/draft-07/schema#", + "definitions": { + "note": { + "type": "object", + "required": [ + "associated_record_id", + "associated_record_type", + "note_text", + "posted_by" + ], + "properties": { + "associated_record_id": {"type": "string"}, + "associated_record_type": {"$ref": "#/definitions/recordType"}, + "note_text": {"type": "string"}, + "posted_by": {"type": "string"} + } + }, + "recordType": { + "type": "string", + "enum": [ + "defendant_accounts", + "creditor_accounts", + "suspense_accounts" + ] + } + }, + "properties": { + "note": {"$ref": "#/definitions/note"} } - } -} +} \ No newline at end of file diff --git a/src/test/resources/schemas/AccountNotes/of_create_note_out.json b/src/test/resources/schemas/AccountNotes/of_create_note_out.json index dc1756826..2d1135bb2 100644 --- a/src/test/resources/schemas/AccountNotes/of_create_note_out.json +++ b/src/test/resources/schemas/AccountNotes/of_create_note_out.json @@ -1,10 +1,6 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "note_id": { - "type": "integer" + "$schema": "https://json-schema.org/draft-07/schema#", + "properties": { + "note_id": {"type": "integer"} } - }, - "required": ["note_id"] -} +} \ No newline at end of file diff --git a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_in.json b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_in.json index a332b3f0a..f052cea7c 100644 --- a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_in.json +++ b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_in.json @@ -1,27 +1,34 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "defendantAccountSearchCriteria": { - "type": "object", - "properties": { - "account_number": { "type": "string" }, - "business_unit_id": { "type": "integer" }, - "organisation": { "type": "boolean" }, - "organisation_name": { "type": "string" }, - "surname": { "type": "string" }, - "forenames": { "type": "string" }, - "initials": { "type": "string" }, - "birth_date": { "type": "string", "format": "date-time" }, - "national_insurance_number": { "type": "string" }, - "prosecutor_case_reference": { "type": "string" }, - "address_line_1": { "type": "string" }, - "searchAliases": { "type": "boolean" }, - "liveOnly": { "type": "boolean" }, - "firstRowNumber": { "type": "integer" }, - "lastRowNumber": { "type": "integer" } - }, - "required": ["firstRowNumber", "lastRowNumber"] + "$schema": "https://json-schema.org/draft-07/schema#", + "definitions": { + "defendantAccountSearchCriteria": { + "type": "object", + "required": [ + "firstRowNumber", + "lastRowNumber" + ], + "properties": { + "account_number": {"type": "string"}, + "business_unit_id": {"type": "integer"}, + "organisation": {"type": "boolean"}, + "organisation_name": {"type": "string"}, + "surname": {"type": "string"}, + "forenames": {"type": "string"}, + "initials": {"type": "string"}, + "birth_date": { + "type": "string" + }, + "national_insurance_number": {"type": "string"}, + "prosecutor_case_reference": {"type": "string"}, + "address_line_1": {"type": "string"}, + "searchAliases": {"type": "boolean"}, + "liveOnly": {"type": "boolean"}, + "firstRowNumber": {"type": "integer"}, + "lastRowNumber": {"type": "integer"} + } + } + }, + "properties": { + "defendantAccountSearchCriteria": {"$ref": "#/definitions/defendantAccountSearchCriteria"} } - } } diff --git a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.json b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.json index e2624cce0..d3f7cd448 100644 --- a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.json +++ b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.json @@ -1,44 +1,49 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "defendantAccountSearchResults": { - "type": "object", - "properties": { - "defendantAccountsSearchResult": { - "type": "array", - "items": { + "$schema": "https://json-schema.org/draft-07/schema#", + "definitions": { + "defendantAccountSearchResults.defendantAccountSearchResult": { "type": "object", - "properties": { - "defendant_account_id": { "type": "integer" }, - "account_number": { "type": "string" }, - "business_unit_id": { "type": "integer" }, - "business_unit_name": { "type": "string" }, - "organisation": { "type": "boolean" }, - "organisation_name": { "type": "string" }, - "surname": { "type": "string" }, - "forenames": { "type": "string" }, - "initials": { "type": "string" }, - "title": { "type": "string" }, - "birth_date": { "type": "string", "format": "date-time" }, - "address_line_1": { "type": "string" }, - "account_balance": { "type": "number" }, - "rowNumber": { "type": "integer" } - }, "required": [ - "defendant_account_id", - "account_number", - "business_unit_id", - "business_unit_name", - "organisation", - "address_line_1", - "account_balance", - "rowNumber" - ] - } + "defendant_account_id", + "account_number", + "business_unit_id", + "business_unit_name", + "organisation", + "address_line_1", + "account_balance", + "rowNumber" + ], + "properties": { + "defendant_account_id": {"type": "integer"}, + "account_number": {"type": "string"}, + "business_unit_id": {"type": "integer"}, + "business_unit_name": {"type": "string"}, + "organisation": {"type": "boolean"}, + "organisation_name": {"type": "string"}, + "surname": {"type": "string"}, + "forenames": {"type": "string"}, + "initials": {"type": "string"}, + "title": {"type": "string"}, + "birth_date": { + "type": "string" + }, + "address_line_1": {"type": "string"}, + "account_balance": {"type": "number"}, + "rowNumber": {"type": "integer"} + } + }, + "defendantAccountSearchResults": { + "type": "object", + "properties": { + "defendantAccountSearchResult": { + "type": "array", + "items": {"$ref": "#/definitions/defendantAccountSearchResults.defendantAccountSearchResult"}, + "minItems": 0 + } + } } - }, - "required": ["defendantAccountsSearchResult"] + }, + "properties": { + "defendantAccountSearchResults": {"$ref": "#/definitions/defendantAccountSearchResults"} } - } } diff --git a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.xsd b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.xsd index 0d7688587..c7f4c5d7a 100644 --- a/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.xsd +++ b/src/test/resources/schemas/AccountSearch/of_f_search_defendant_accounts_out.xsd @@ -3,7 +3,7 @@ - +