Skip to content

Commit

Permalink
Merge branch 'main' into fix/FSADT1-1002
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj authored Nov 22, 2023
2 parents 47780fb + 8681e29 commit 8c1ff8b
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.0.1</version>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
5 changes: 5 additions & 0 deletions backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public final class ApplicationConstant {
public static final String USERID_HEADER = "x-user-id";
public static final String USERMAIL_HEADER = "x-user-email";
public static final String USERNAME_HEADER = "x-user-name";

public static final String INDIVIDUAL_CLIENT_TYPE_CODE = "I";
public static final String REG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE = "RSP";
public static final String UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE = "USP";

public static final BcRegistryDocumentRequestBodyDto
BUSINESS_SUMMARY_FILING_HISTORY =
new BcRegistryDocumentRequestBodyDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public Map<String, Object> description() {
"clientType", StringUtils.isBlank(clientType) ? "" : clientType,
"goodStanding", StringUtils.isBlank(goodStandingInd) ? "" : goodStandingInd,
"legalType", StringUtils.isBlank(legalType) ? "" : legalType,
"birthdate", Optional.ofNullable(birthdate).isPresent() ? birthdate : LocalDate.now()
"birthdate", Optional.ofNullable(birthdate).isPresent()
? birthdate : LocalDate.of(1975, 1, 31)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import static ca.bc.gov.app.util.ClientValidationUtils.fieldIsMissingErrorMessage;

import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.client.BusinessTypeEnum;
import ca.bc.gov.app.dto.client.ClientBusinessInformationDto;
import ca.bc.gov.app.dto.client.ClientLocationDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -59,6 +61,21 @@ else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) {
errors.popNestedPath();
return;
}

String clientType = businessInformation.clientType();

if(StringUtils.isBlank(clientType)) {
errors.rejectValue("clientType", "Client does not have a type");
errors.popNestedPath();
return;
}

if (ApplicationConstant.REG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType)
|| ApplicationConstant.UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType)
|| ApplicationConstant.INDIVIDUAL_CLIENT_TYPE_CODE.equals(clientType)
) {
validateBirthdate(businessInformation.birthdate(), errors);
}

errors.popNestedPath();

Expand All @@ -72,6 +89,19 @@ else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) {
}
}

private void validateBirthdate(LocalDate birthdate, Errors errors) {
String dobFieldName = "birthdate";
if (birthdate == null) {
errors.rejectValue(dobFieldName, fieldIsMissingErrorMessage("Birthdate"));
}
else {
LocalDate minAgeDate = LocalDate.now().minusYears(18);
if (birthdate.isAfter(minAgeDate)) {
errors.rejectValue(dobFieldName, "Sole proprietorship must be at least 18 years old");
}
}
}

private void validateLocation(ClientLocationDto location, Errors errors) {

String locationField = "location";
Expand Down
4 changes: 2 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 @@ -414,7 +414,7 @@ public class TestConstants {
"P",
"Y",
"GP",
null
LocalDate.now()
),
new ClientLocationDto(
List.of(
Expand Down Expand Up @@ -455,7 +455,7 @@ public class TestConstants {
"I",
"",
"SP",
LocalDate.now()
LocalDate.of(1975, 1, 31)
),
new ClientLocationDto(
List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.params.aggregator.ArgumentsAccessor;
import org.junit.jupiter.params.aggregator.ArgumentsAggregationException;
Expand Down Expand Up @@ -38,7 +39,10 @@ private static ClientBusinessInformationDto createBusinessInformation(
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));
LocalDate birthdate =
StringUtils.isNotBlank(birthdateAsString)
? LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(birthdateAsString))
: null;

return new ClientBusinessInformationDto(
incorporationNumber,
Expand All @@ -52,17 +56,17 @@ private static ClientBusinessInformationDto createBusinessInformation(

private static ClientLocationDto createLocation(ArgumentsAccessor accessor) {

boolean locationNull = accessor.getBoolean(8);
boolean locationNull = accessor.getBoolean(9);
if (locationNull) {
return null;
}

boolean addressNull = accessor.getBoolean(9);
boolean addressNull = accessor.getBoolean(10);
if (addressNull) {
new ClientLocationDto(null, null);
}

boolean addressEmpty = accessor.getBoolean(10);
boolean addressEmpty = accessor.getBoolean(11);
if (addressEmpty) {
return new ClientLocationDto(List.of(), List.of());
}
Expand All @@ -75,11 +79,11 @@ private static ClientLocationDto createLocation(ArgumentsAccessor accessor) {

private static ClientAddressDto createAddress(ArgumentsAccessor accessor) {

String streetAddress = accessor.getString(11);
String country = accessor.getString(12);
String province = accessor.getString(13);
String city = accessor.getString(14);
String postalCode = accessor.getString(15);
String streetAddress = accessor.getString(12);
String country = accessor.getString(13);
String province = accessor.getString(14);
String city = accessor.getString(15);
String postalCode = accessor.getString(16);

return new ClientAddressDto(
streetAddress, new ClientValueTextDto(country, country),
Expand Down
8 changes: 8 additions & 0 deletions backend/src/test/resources/failValidationTest.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ userIdTest,FALSE,1234,Auric Enterprises,A,R,GP,Y,1986-11-11,FALSE,FALSE,FALSE,35
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,Auric Enterprises,A,USP,SP,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,Auric Enterprises,A,RSP,SP,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
pipin,FALSE,XX0000104,The Samples Enterprise,RSP,R,SP,Y,1986-11-11,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
pipin,FALSE,,James Bond,USP,U,,Y,1986-11-11,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
pipin,FALSE,,James Bond,I,U,,Y,1986-11-11,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
pipin,FALSE,,James Bond,,U,,Y,1986-11-11,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
pipin,FALSE,,James Bond,I,U,,Y,,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
pipin,FALSE,,James Bond,I,U,,Y,2010-11-11,FALSE,FALSE,FALSE,2975 Jutland Rd,CA,BC,Victoria,V8W3Z8,FALSE,FALSE,LP,James,Bond,98765432101,[email protected],
11 changes: 11 additions & 0 deletions frontend/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
--light-theme-miscellaneous-interactive: #0073e6;
--light-theme-background-background-selected: #93939533;
--light-theme-text-text-disabled: rgba(19, 19, 21, 0.25);
--light-theme-text-text-on-color: #FFFFFF;

//Buttons
--cds-button-disabled: #c6c6c8;
Expand Down Expand Up @@ -296,6 +297,7 @@ div#app {
align-items: center;
background: var(--light-theme-layer-layer-02, #fff);
flex-grow: 1;
margin-top: 3.5rem;
}

.full {
Expand Down Expand Up @@ -1005,6 +1007,15 @@ cds-header-global-action {
background: var(--light-theme-layer-layer-02, #FFF) !important;
}

cds-header-menu-button::part(svg) {
width: 1rem;
height: 1rem;
}

cds-header-menu-button:not([active])::part(svg) {
fill: var(--light-theme-text-text-on-color, #FFF);
}

cds-header-global-action svg {
fill: var(--dark-theme-focus-focus);
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/MainHeaderComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ watchEffect((onCleanup) => {
<cds-header-menu-button
v-if="$session?.user?.provider === 'idir'"
button-label-active="Close menu"
button-label-inactive="Open menu">
button-label-inactive="Open menu"
v-shadow="2"
>
</cds-header-menu-button>

<a href="https://gov.bc.ca" v-if="$session.user?.provider !== 'idir'" class="bclogotop">
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/pages/FormBCeIDPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ let formDataDto = ref<FormDataDto>({ ...newFormDataDto() });
//---- Form Data ----//
let formData = reactive<FormDataDto>({
...formDataDto.value,
businessInformation: {
...formDataDto.value.businessInformation,
birthdate: "",
},
location: {
addresses: formDataDto.value.location.addresses,
contacts: [submitterContact],
Expand Down
2 changes: 1 addition & 1 deletion legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.0.1</version>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>3.0.1</version>
<version>3.0.3</version>
<scope>test</scope>
</dependency>

Expand Down

0 comments on commit 8c1ff8b

Please sign in to comment.