Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixing data loading due to date type #1373

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import lombok.SneakyThrows;
Expand Down Expand Up @@ -110,7 +111,7 @@ private String obfuscate(String propName, String propType, Object value) {
}

if ("birthdate".equals(propName)) {
return obfuscateBirthdate((LocalDate) value);
return obfuscateBirthdate((LocalDateTime) value);
}

return value.toString();
Expand All @@ -122,7 +123,7 @@ private String obfuscate(String propName, String propType, Object value) {
* @param value The birthdate to obfuscate.
* @return The obfuscated birthdate as a string.
*/
private String obfuscateBirthdate(LocalDate value) {
private String obfuscateBirthdate(LocalDateTime value) {
return String.format("%d-**-**", value.getYear());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.bc.gov.app.dto.legacy;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import lombok.With;

Expand Down Expand Up @@ -49,10 +49,10 @@ public record ForestClientDetailsDto(
String clientAcronym,
String wcbFirmNumber,
String clientComment,
LocalDate clientCommentUpdateDate,
LocalDateTime clientCommentUpdateDate,
String clientCommentUpdateUser,
String goodStandingInd,
LocalDate birthdate,
LocalDateTime birthdate,

List<ForestClientLocationDto> addresses,
List<ForestClientContactDto> contacts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -59,7 +61,7 @@ void shouldNotObfuscateForNonViewers() throws Exception {
String json = mapper.writeValueAsString(getDto());
assertThat(json)
.contains("\"clientIdentification\":\"12345678\"")
.contains("\"birthdate\":\"1070-12-13\"");
.contains("\"birthdate\":\"1070-12-13T00:00\"");
}

@Test
Expand All @@ -68,7 +70,7 @@ void shouldNotObfuscateEvenIfHasViewer() throws Exception {
String json = mapper.writeValueAsString(getDto());
assertThat(json)
.contains("\"clientIdentification\":\"12345678\"")
.contains("\"birthdate\":\"1070-12-13\"");
.contains("\"birthdate\":\"1070-12-13T00:00\"");
}

private ForestClientDetailsDto getDto() {
Expand All @@ -92,7 +94,7 @@ private ForestClientDetailsDto getDto() {
null,
null,
null,
LocalDate.of(1070, 12, 13),
LocalDateTime.of(LocalDate.of(1070, 12, 13), LocalTime.MIN),
List.of(),
List.of(),
List.of()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.bc.gov.app.service.client;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -41,6 +42,7 @@ class ClientServiceIntegrationTest extends AbstractTestContainerIntegrationTest
void testGetClientDetailsWithGoodStandingIndicator() {
String clientNumber = "123456";
String corpRegnNmbr = "9607514";
LocalDateTime date = LocalDateTime.of(2021, 1, 1, 0, 0, 0);

ForestClientDetailsDto initialDto = new ForestClientDetailsDto(
clientNumber,
Expand All @@ -59,7 +61,7 @@ void testGetClientDetailsWithGoodStandingIndicator() {
"MYCO",
"678",
"Test Client",
LocalDate.now(),
date,
"Admin",
null,
null,
Expand Down Expand Up @@ -143,7 +145,7 @@ void testGetClientDetailsWithGoodStandingIndicator() {
"MYCO",
"678",
"Test Client",
LocalDate.now(),
date,
"Admin",
"Y",
null,
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/pages/client-details/SummaryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const doingBusinessAs = computed(() => {
const birthdateLabel = computed(() =>
props.data.birthdate.length > 4 ? "Date of birth" : "Year of birth",
);

const dateOfBirth = computed(() => {

if(props.data.birthdate) {
return new Date(props.data.birthdate).toISOString().split('T')[0];
}
return '';
});
</script>

<template>
Expand Down Expand Up @@ -78,8 +86,8 @@ const birthdateLabel = computed(() =>
>
<span class="body-compact-01">{{ props.data.clientIdentification }}</span>
</read-only-component>
<read-only-component :label="birthdateLabel" id="dateOfBirth" v-if="props.data.birthdate">
<span class="body-compact-01">{{ props.data.birthdate }}</span>
<read-only-component :label="birthdateLabel" id="dateOfBirth" v-if="dateOfBirth">
<span class="body-compact-01">{{ dateOfBirth }}</span>
</read-only-component>
<read-only-component label="Status" id="status">
<span class="body-compact-01">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ca.bc.gov.app.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import lombok.With;

Expand All @@ -22,14 +22,14 @@ public record ForestClientDetailsDto(
String clientAcronym,
String wcbFirmNumber,
String clientComment,
LocalDate clientCommentUpdateDate,
LocalDateTime clientCommentUpdateDate,
String clientCommentUpdateUser,
String goodStandingInd,
LocalDate birthdate,
LocalDateTime birthdate,

List<ForestClientLocationDto> addresses,
List<ForestClientContactDto> contacts,
List<ClientDoingBusinessAsDto> doingBusinessAs
) {
}
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Flux<ForestClientEntity> findClientByIncorporationOrName(
c.client_acronym,
c.wcb_firm_number,
c.client_comment,
fca.update_userid as latest_update_userid,
fca.update_timestamp as latest_update_timestamp,
fca.update_userid as client_comment_update_user,
fca.update_timestamp as client_comment_update_date,
'' as good_standing_ind,
c.birthdate
from the.forest_client c
Expand Down
Loading