diff --git a/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java index 49a741bdd..6f4691186 100644 --- a/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java @@ -568,6 +568,7 @@ void testUpdateDraftAccount_success() throws Exception { .submittedBy("BUUID1") .validatedDate(testDateTime) .validatedBy("BUUID1") + .validatedByName("Donald Tester") .account(validAccountJson()) .accountSnapshot("{\"defendant_name\":\"Company ABC\",\"created_date\":\"2024-10-02T14:30:00Z\"," + "\"account_type\":\"Fine\",\"submitted_by\":\"BUUID1\"," @@ -595,6 +596,7 @@ void testUpdateDraftAccount_success() throws Exception { .andExpect(jsonPath("$.submitted_by").value("BUUID1")) .andExpect(jsonPath("$.validated_at").value("2024-10-03T14:30:00Z")) .andExpect(jsonPath("$.validated_by").value("BUUID1")) + .andExpect(jsonPath("$.validated_by_name").value("Donald Tester")) .andExpect(jsonPath("$.account.defendant.company_name") .value("company")) .andExpect(jsonPath("$.account_snapshot.defendant_name").value("Company ABC")) diff --git a/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java b/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java index 2ce3fbf3e..025f66178 100644 --- a/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java +++ b/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java @@ -252,6 +252,7 @@ DraftAccountResponseDto toGetResponseDto(DraftAccountEntity entity) { .submittedByName(entity.getSubmittedByName()) .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) + .validatedByName(entity.getValidatedByName()) .account(entity.getAccount()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) @@ -272,6 +273,7 @@ DraftAccountSummaryDto toSummaryDto(DraftAccountEntity entity) { .submittedBy(entity.getSubmittedBy()) .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) + .validatedByName(entity.getValidatedByName()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) .accountStatus(entity.getAccountStatus()) diff --git a/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountResponseDto.java b/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountResponseDto.java index 34184066b..8c3721687 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountResponseDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountResponseDto.java @@ -39,6 +39,9 @@ public class DraftAccountResponseDto implements ToJsonString { @JsonProperty("validated_by") private String validatedBy; + @JsonProperty("validated_by_name") + private String validatedByName; + @JsonProperty("account") @JsonRawValue private String account; diff --git a/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountSummaryDto.java b/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountSummaryDto.java index a132c39da..41cd111b5 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountSummaryDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/DraftAccountSummaryDto.java @@ -36,6 +36,9 @@ public class DraftAccountSummaryDto implements ToJsonString { @JsonProperty("validated_by") private String validatedBy; + @JsonProperty("validated_by_name") + private String validatedByName; + @JsonProperty("account_snapshot") @JsonRawValue private String accountSnapshot; diff --git a/src/main/java/uk/gov/hmcts/opal/dto/UpdateDraftAccountRequestDto.java b/src/main/java/uk/gov/hmcts/opal/dto/UpdateDraftAccountRequestDto.java index f6a02c3c8..a201ccf5b 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/UpdateDraftAccountRequestDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/UpdateDraftAccountRequestDto.java @@ -20,6 +20,9 @@ public class UpdateDraftAccountRequestDto implements ToJsonString { @JsonProperty("validated_by") private String validatedBy; + @JsonProperty("validated_by_name") + private String validatedByName; + @JsonProperty("business_unit_id") private Short businessUnitId; diff --git a/src/main/java/uk/gov/hmcts/opal/entity/DraftAccountEntity.java b/src/main/java/uk/gov/hmcts/opal/entity/DraftAccountEntity.java index 9afe58912..bf5a7564c 100644 --- a/src/main/java/uk/gov/hmcts/opal/entity/DraftAccountEntity.java +++ b/src/main/java/uk/gov/hmcts/opal/entity/DraftAccountEntity.java @@ -59,8 +59,8 @@ public class DraftAccountEntity { @Column(name = "validated_by", length = 20) private String validatedBy; - // @Column(name = "validate_by_name", length = 100) - // private String validateByName; + @Column(name = "validated_by_name", length = 100) + private String validatedByName; @Column(name = "account", columnDefinition = "json", nullable = false) @ColumnTransformer(write = "?::jsonb") diff --git a/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java b/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java index bff984bb2..ea64257e6 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java @@ -27,7 +27,6 @@ import uk.gov.hmcts.opal.util.JsonPathUtil; import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.EnumSet; @@ -160,7 +159,9 @@ public DraftAccountEntity updateDraftAccount(Long draftAccountId, UpdateDraftAcc if (newStatus == DraftAccountStatus.PENDING) { existingAccount.setValidatedDate(LocalDateTime.now()); existingAccount.setValidatedBy(dto.getValidatedBy()); + existingAccount.setValidatedByName(dto.getValidatedByName()); existingAccount.setAccountSnapshot(addSnapshotApprovedDate(existingAccount)); + existingAccount.setAccountStatusDate(LocalDateTime.now()); } // Set the timeline data as received from the front end existingAccount.setTimelineData(dto.getTimelineData()); @@ -176,8 +177,7 @@ private String addSnapshotApprovedDate(DraftAccountEntity existingAccount) { ObjectMapper mapper = new ObjectMapper(); ObjectNode rootNode = (ObjectNode) mapper.readTree(existingAccount.getAccountSnapshot()); - String approvedDate = existingAccount.getValidatedDate() - .atOffset(ZoneOffset.UTC) + String approvedDate = toUtcDateTime(existingAccount.getValidatedDate()) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); rootNode.put("approved_date", approvedDate); diff --git a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java index e0d2947a1..a98f04558 100644 --- a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java +++ b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java @@ -174,6 +174,7 @@ DraftAccountResponseDto toGetDto(DraftAccountEntity entity) { .submittedBy(entity.getSubmittedBy()) .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) + .validatedByName(entity.getValidatedByName()) .account(entity.getAccount()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) @@ -192,6 +193,7 @@ DraftAccountSummaryDto toSummaryDto(DraftAccountEntity entity) { .submittedBy(entity.getSubmittedBy()) .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) + .validatedByName(entity.getValidatedByName()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) .accountStatus(entity.getAccountStatus()) diff --git a/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java index e4141e66a..0e84e7bb0 100644 --- a/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java +++ b/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java @@ -348,6 +348,7 @@ void testUpdateDraftAccount_success() { .draftAccountId(draftAccountId) .accountStatus(DraftAccountStatus.PENDING) .validatedBy("TestValidator") + .validatedByName("Tester McValidator") .validatedDate(LocalDateTime.now()) .accountSnapshot("{\"created_date\":\"2024-10-01T10:00:00Z\",\"approved_date\":\"2024-10-03T14:30:00Z\"}") .timelineData("Updated timeline data") @@ -364,6 +365,7 @@ void testUpdateDraftAccount_success() { assertEquals(draftAccountId, result.getDraftAccountId()); assertEquals(DraftAccountStatus.PENDING, result.getAccountStatus()); assertEquals("TestValidator", result.getValidatedBy()); + assertEquals("Tester McValidator", result.getValidatedByName()); assertNotNull(result.getValidatedDate()); assertTrue(result.getAccountSnapshot().contains("approved_date")); assertEquals("Updated timeline data", result.getTimelineData());