Skip to content

Commit

Permalink
FSADT1-983: Added DOB in the DB and code (#611)
Browse files Browse the repository at this point in the history
* feat:
- Added DOB in the DB and code (FSADT1-983)

* Changed to LocalDate as per requested

* Changed to LocalDate as per requested

* Updated CSV with DOB

* Updated query

* test: Added logic for registered clients

---------

Co-authored-by: Paulo Gomes da Cruz Junior <[email protected]>
  • Loading branch information
mamartinezmejia and paulushcgcj authored Nov 15, 2023
1 parent 5ea56ef commit fd3b615
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 46 deletions.
6 changes: 5 additions & 1 deletion backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ public final class ApplicationConstant {
sd.client_number,
sd.organization_name,
ctc.description as client_type,
sd.good_standing_ind as good_standing
sd.good_standing_ind as good_standing,
sd.birthdate
FROM nrfc.submission s
left join nrfc.submission_status_code ssc on ssc.submission_status_code = s.submission_status_code\s
left join nrfc.submission_type_code stc on stc.submission_type_code = s.submission_type_code
left join nrfc.submission_detail sd on sd.submission_id = s.submission_id\s
left join nrfc.business_type_code btc on btc.business_type_code = sd.business_type_code\s
left join nrfc.client_type_code ctc on ctc.client_type_code = sd.client_type_code\s
where s.submission_id = :submissionId""";

public static final String SUBMISSION_CONTACTS_QUERY = """
SELECT
ROW_NUMBER() OVER (order by sc.submission_contact_id ) AS index,
Expand All @@ -62,6 +64,7 @@ public final class ApplicationConstant {
FROM nrfc.submission_contact sc
left join nrfc.contact_type_code ctc on ctc.contact_type_code = sc.contact_type_code
where sc.submission_id = :submissionId""";

public static final String SUBMISSION_LOCATION_QUERY = """
SELECT
ROW_NUMBER() OVER (order by sl.submission_location_id ) AS index,
Expand All @@ -78,6 +81,7 @@ public final class ApplicationConstant {
left join nrfc.province_code pc on (pc.province_code = sl.province_code and pc.country_code = cc.country_code)
where sl.submission_id = :submissionId
order by sl.submission_location_id""";

public static final String SUBMISSION_TYPE = "submissionType";
public static final String SUBMISSION_ID = "submissionId";
public static final String REFRESH_TOKEN = "refreshToken";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ca.bc.gov.app.dto.client;

import java.time.LocalDate;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;

public record ClientBusinessInformationDto(
Expand All @@ -9,7 +11,8 @@ public record ClientBusinessInformationDto(
String businessType,
String clientType,
String goodStandingInd,
String legalType) {
String legalType,
LocalDate birthdate) {
/**
* Returns a map containing the description of the client's business information.
*
Expand All @@ -22,7 +25,8 @@ public Map<String, Object> description() {
"businessType", StringUtils.isBlank(businessType) ? "" : businessType,
"clientType", StringUtils.isBlank(clientType) ? "" : clientType,
"goodStanding", StringUtils.isBlank(goodStandingInd) ? "" : goodStandingInd,
"legalType", StringUtils.isBlank(legalType) ? "" : legalType
"legalType", StringUtils.isBlank(legalType) ? "" : legalType,
"birthdate", Optional.ofNullable(birthdate).isPresent() ? birthdate : LocalDate.now()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package ca.bc.gov.app.dto.submissions;

import java.time.LocalDate;

public record SubmissionBusinessDto(
String businessType,
String incorporationNumber,
String clientNumber,
String organizationName,
String clientType,
String goodStandingInd
String goodStandingInd,
LocalDate birthdate
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.With;
import java.time.LocalDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
Expand Down Expand Up @@ -39,4 +40,7 @@ public class SubmissionDetailEntity {

@Column("good_standing_ind")
private String goodStandingInd;

@Column("birthdate")
private LocalDate birthdate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import ca.bc.gov.app.repository.client.SubmissionMatchDetailRepository;
import ca.bc.gov.app.repository.client.SubmissionRepository;
import ca.bc.gov.app.service.ches.ChesService;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
Expand Down Expand Up @@ -203,7 +204,8 @@ public Mono<SubmissionDetailsDto> getSubmissionDetail(Long id) {
row.get("client_number", String.class),
row.get("organization_name", String.class),
row.get("client_type", String.class),
row.get("good_standing", String.class)
row.get("good_standing", String.class),
row.get("birthdate", LocalDate.class)
),
List.of(),
List.of(),
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/java/ca/bc/gov/app/util/ClientMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public static SubmissionDetailEntity mapToSubmissionDetailEntity(
.withOrganizationName(clientBusinessInformationDto.businessName())
.withBusinessTypeCode(clientBusinessInformationDto.businessType())
.withClientTypeCode(clientBusinessInformationDto.clientType())
.withGoodStandingInd(clientBusinessInformationDto.goodStandingInd());
.withGoodStandingInd(clientBusinessInformationDto.goodStandingInd())
.withBirthdate(clientBusinessInformationDto.birthdate());
}

/**
* Maps a {@link ClientAddressDto} object to a {@link SubmissionLocationEntity} object,
* using the specified submission ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ comment on column nrfc.business_type_code.create_user is 'The user or proxy acco
comment on column nrfc.business_type_code.update_user is 'The user or proxy account that created or last updated the record.';

create table if not exists nrfc.submission(
submission_id integer not null,
submission_status_code varchar(5) null,
submission_type_code varchar(5) null,
submission_id integer not null,
submission_status_code varchar(5) null,
submission_type_code varchar(5) null,
submission_date timestamp null,
update_timestamp timestamp default current_timestamp,
create_user varchar(60) not null,
update_user varchar(60) null,
update_user varchar(60) null,
constraint submission_pk primary key (submission_id),
constraint submission_submission_status_code_fk foreign key (submission_status_code) references nrfc.submission_status_code(submission_status_code),
constraint submission_submission_type_code_fk foreign key (submission_type_code) references nrfc.submission_type_code(submission_type_code)
Expand All @@ -219,6 +219,7 @@ create table if not exists nrfc.submission_detail (
organization_name varchar(100) null,
client_type_code varchar(5) not null,
good_standing_ind varchar(1) null,
birthdate date null,
constraint submission_detail_id_pk primary key (submission_detail_id),
constraint submission_id_fk foreign key (submission_id) references nrfc.submission(submission_id),
constraint submission_detail_business_type_code_fk foreign key (business_type_code) references nrfc.business_type_code(business_type_code),
Expand All @@ -233,6 +234,7 @@ comment on column nrfc.submission_detail.incorporation_number is 'A number provi
comment on column nrfc.submission_detail.organization_name is 'The name of the client.';
comment on column nrfc.submission_detail.client_type_code is 'A code representing the type of a client.';
comment on column nrfc.submission_detail.good_standing_ind is 'An indicator that determines whether a client is in good standing with respect to their financial obligations.';
comment on column nrfc.submission_detail.birthdate is 'The date that the BC Services Card logged in person was born.';

create table if not exists nrfc.submission_matching_detail (
submission_matching_detail_id integer not null,
Expand Down
7 changes: 5 additions & 2 deletions backend/src/test/java/ca/bc/gov/app/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ca.bc.gov.app.dto.cognito.AuthResponseDto;
import ca.bc.gov.app.dto.cognito.RefreshResponseDto;
import ca.bc.gov.app.dto.cognito.RefreshResponseResultDto;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -412,7 +413,8 @@ public class TestConstants {
"R",
"P",
"Y",
"GP"
"GP",
null
),
new ClientLocationDto(
List.of(
Expand Down Expand Up @@ -452,7 +454,8 @@ public class TestConstants {
"U",
"I",
"",
"SP"
"SP",
LocalDate.now()
),
new ClientLocationDto(
List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import ca.bc.gov.app.dto.client.ClientLocationDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.client.ClientValueTextDto;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
Expand Down Expand Up @@ -35,9 +37,17 @@ private static ClientBusinessInformationDto createBusinessInformation(
String businessType = accessor.getString(5);
String legalType = accessor.getString(6);
String goodStanding = accessor.getString(7);
String birthdateAsString = accessor.getString(8);
LocalDate birthdate = LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(birthdateAsString));

return new ClientBusinessInformationDto(incorporationNumber, businessName, businessType,
clientType, goodStanding, legalType);
return new ClientBusinessInformationDto(
incorporationNumber,
businessName,
businessType,
clientType,
goodStanding,
legalType,
birthdate);
}

private static ClientLocationDto createLocation(ArgumentsAccessor accessor) {
Expand Down
44 changes: 22 additions & 22 deletions backend/src/test/resources/failValidationTest.csv
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
userId,businessInformationNull,incorporationNumber,businessName,clientType,businessType,legalType,goodStanding,locationNull,addressNull,addressEmpty,streetAddress,country,province,city,postalCode,contactsNull,contactsEmpty,contactType,contactFirstName,contactLastName,contactPhoneNumber,contactEmail
,true,1234,Auric Enterprises,A,R,GP,Y,true,true,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,true,1234,Auric Enterprises,C,R,GP,Y,true,true,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,true,1234,Auric Enterprises,C,R,GP,Y,true,true,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,true,true,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,true,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,true,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,true,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,false,true,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 Vancouver Street,CA,BC,Vancouver,A9A9A99,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,A89109,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,289109,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 Av Paulista,BR,SP,Sao Paul,01234567891,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 Vancouver Street,CA,AA,Vancouver,A9A9A9,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,BC,Las Vegas,89109,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,false,false,LP,James,Bond,987654321,[email protected]
userIdTest,false,1234,Auric Enterprises,A,R,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,false,false,LP,James,Bond,98765432101,[email protected]
userIdTest,false,1234,Auric Enterprises,ABC,DEF,GHI,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,false,false,LP,James,Bond,98765432101,[email protected]
userIdTest,false,1234,Auric Enterprises,A,U,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vega,89109,false,false,LP,James,Bond,98765432101,[email protected],false
userIdTest,false,1234,,A,U,GP,Y,false,false,false,3570 S Las Vegas Blvd,US,NV,Las Vega,89109,false,false,LP,James,Bond,98765432101,[email protected]
,false,,,,,,,false,false,false,,,,,,false,false,,,,,,false,,,,
userId,businessInformationNull,incorporationNumber,businessName,clientType,businessType,legalType,goodStanding,birthdate,locationNull,addressNull,addressEmpty,streetAddress,country,province,city,postalCode,contactsNull,contactsEmpty,contactType,contactFirstName,contactLastName,contactPhoneNumber,contactEmail,
,TRUE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,TRUE,TRUE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,TRUE,1234,Auric Enterprises,C,R,GP,Y,1986-11-11,TRUE,TRUE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,TRUE,1234,Auric Enterprises,C,R,GP,Y,1986-11-11,TRUE,TRUE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,TRUE,TRUE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,TRUE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,TRUE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,TRUE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,FALSE,TRUE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 Vancouver Street,CA,BC,Vancouver,A9A9A99,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,A89109,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,289109,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 Av Paulista,BR,SP,Sao Paul,01234567891,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 Vancouver Street,CA,AA,Vancouver,A9A9A9,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,BC,Las Vegas,89109,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,FALSE,FALSE,LP,James,Bond,987654321,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,ABC,DEF,GHI,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vegas,89109,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
userIdTest,FALSE,1234,Auric Enterprises,A,U,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vega,89109,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],FALSE
userIdTest,FALSE,1234,,A,U,GP,Y,1986-11-11,FALSE,FALSE,FALSE,3570 S Las Vegas Blvd,US,NV,Las Vega,89109,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
,FALSE,,,,,,,1986-11-11,FALSE,FALSE,FALSE,,,,,,FALSE,FALSE,,,,,,FALSE
5 changes: 3 additions & 2 deletions frontend/src/dto/ApplyClientNumberDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export interface FormDataDto {
incorporationNumber: string;
businessName: string;
goodStandingInd: string;
birthDate: string;
birthdate: string;
address: Address;

};
location: {
addresses: Address[];
Expand All @@ -53,7 +54,7 @@ export const formDataDto: FormDataDto = {
incorporationNumber: "",
businessName: "",
goodStandingInd: "",
birthDate: "",
birthdate: "",
address: {
locationName: "",
streetAddress: "",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/dto/CommonTypesDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface Submitter {
firstName: string;
lastName: string;
businessName: string;
birthDate: string;
birthdate: string;
address: Address;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/helpers/ForestClientUserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ForestClientUserSession implements SessionProperties {
name: toTitleCase(parsedUser["custom:idp_display_name"]),
provider: provider,
userId: `${provider}\\${parsedUser["custom:idp_username"] ?? parsedUser["custom:idp_user_id"]}`,
birthDate: parsedUser["birthdate"],
birthdate: parsedUser["birthdate"],
address: {
locationName: "",
streetAddress: toTitleCase(streetAddress.street_address),
Expand Down
Loading

0 comments on commit fd3b615

Please sign in to comment.