diff --git a/backend/pom.xml b/backend/pom.xml index 55dd6a322c..e4a57736e5 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -40,7 +40,7 @@ ${project.build.directory}/coverage-reports ${maven.build.timestamp} yyyy-MM-dd HH:mm:ss - 1.19.3 + 1.19.1 5.9.1 1.9.1 ${project.version} diff --git a/backend/src/main/java/ca/bc/gov/app/controller/cognito/CognitoController.java b/backend/src/main/java/ca/bc/gov/app/controller/cognito/CognitoController.java index 840964fe96..fa85523d38 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/cognito/CognitoController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/cognito/CognitoController.java @@ -198,7 +198,7 @@ private ResponseCookie buildCookie( return ResponseCookie .from(cookieName, cookieValue) .httpOnly(false) - .sameSite("None") + .sameSite(isLocal() ? "Lax" : "None") .path("/") .maxAge(Duration.ofSeconds(expiresInSeconds != null ? expiresInSeconds : 3600)) .secure(!isLocal()) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java b/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java index 880c75b761..1c2827164d 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java @@ -1,6 +1,7 @@ package ca.bc.gov.app.dto.bcregistry; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.apache.commons.lang3.StringUtils; @JsonIgnoreProperties(ignoreUnknown = true) public record BcRegistryOfficerDto( @@ -10,4 +11,8 @@ public record BcRegistryOfficerDto( String middleInitial, String partyType ) { + + public boolean isPerson() { + return StringUtils.isNotBlank(partyType) && partyType.equalsIgnoreCase("Person"); + } } diff --git a/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java b/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java index 2787cd4e03..ae66f1efb1 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java @@ -54,4 +54,8 @@ public boolean isMatch( .stream() .anyMatch(provided::equals); } + + public boolean isPerson(){ + return officer != null && officer().isPerson(); + } } diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java index 69c61ca7f8..682dcba967 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java @@ -22,4 +22,13 @@ public enum ClientTypeCodeEnum { ClientTypeCodeEnum(String description) { this.description = description; } + + public static String as(String code) { + for (ClientTypeCodeEnum clientTypeCodeEnum : ClientTypeCodeEnum.values()) { + if (clientTypeCodeEnum.name().equals(code)) { + return clientTypeCodeEnum.description; + } + } + return code; + } } diff --git a/backend/src/main/java/ca/bc/gov/app/exception/UnsuportedClientTypeException.java b/backend/src/main/java/ca/bc/gov/app/exception/UnsuportedClientTypeException.java new file mode 100644 index 0000000000..8cce606115 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/exception/UnsuportedClientTypeException.java @@ -0,0 +1,17 @@ +package ca.bc.gov.app.exception; + +import ca.bc.gov.app.dto.legacy.ClientTypeCodeEnum; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.server.ResponseStatusException; + +@ResponseStatus(HttpStatus.NOT_ACCEPTABLE) +public class UnsuportedClientTypeException extends ResponseStatusException { + + public UnsuportedClientTypeException(String clientType) { + super(HttpStatus.NOT_ACCEPTABLE, + String.format("Client type %s is not supported at the moment", + ClientTypeCodeEnum.as(clientType))); + } + +} \ No newline at end of file diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java index a06fc579c3..8c68fe075c 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java @@ -14,6 +14,8 @@ import ca.bc.gov.app.exception.ClientAlreadyExistException; import ca.bc.gov.app.exception.InvalidAccessTokenException; import ca.bc.gov.app.exception.NoClientDataFound; +import ca.bc.gov.app.exception.UnableToProcessRequestException; +import ca.bc.gov.app.exception.UnsuportedClientTypeException; import ca.bc.gov.app.repository.client.ClientTypeCodeRepository; import ca.bc.gov.app.repository.client.ContactTypeCodeRepository; import ca.bc.gov.app.repository.client.CountryCodeRepository; @@ -102,29 +104,27 @@ public Mono getCountryByCode(String countryCode) { return countryCodeRepository .findByCountryCode(countryCode) .map(entity -> new CodeNameDto(entity.getCountryCode(), - entity.getDescription())); + entity.getDescription())); } /** - * Retrieves a client type by its unique code. - * This method queries the clientTypeCodeRepository to find a client type entity - * with the specified code. If a matching entity is found, it is converted to a - * {@code CodeNameDto} object containing the code and description, and wrapped - * in a Mono. If no matching entity is found, the Mono will complete without emitting - * any items. + * Retrieves a client type by its unique code. This method queries the clientTypeCodeRepository to + * find a client type entity with the specified code. If a matching entity is found, it is + * converted to a {@code CodeNameDto} object containing the code and description, and wrapped in a + * Mono. If no matching entity is found, the Mono will complete without emitting any items. * * @param code The unique code of the client type to retrieve. - * @return A Mono emitting a {@code CodeNameDto} if a matching client type is found, or an - * empty result if no match is found. + * @return A Mono emitting a {@code CodeNameDto} if a matching client type is found, or an empty + * result if no match is found. * @see CodeNameDto */ public Mono getClientTypeByCode(String code) { return clientTypeCodeRepository .findByCode(code) .map(entity -> new CodeNameDto(entity.getCode(), - entity.getDescription())); + entity.getDescription())); } - + /** *

List Provinces

*

List provinces by country (which include states) by page with a defined size. @@ -205,7 +205,17 @@ public Mono getClientDetails( ) ) .map(BcRegistryDocumentDto.class::cast) - .flatMap(buildDetails()); + + //if document type is SP and party contains only one entry that is not a person, fail + .filter(document -> + !("SP".equalsIgnoreCase(document.business().legalType()) + && document.parties().size() == 1 + && !document.parties().get(0).isPerson()) + ) + .flatMap(buildDetails()) + .switchIfEmpty(Mono.error(new UnableToProcessRequestException( + "Unable to process request. This sole proprietor is not owner by a person" + ))); } /** @@ -227,7 +237,14 @@ public Flux findByClientNameOrIncorporation(String value) { entry.status(), entry.legalType() ) - ); + ) + .flatMap(client ->{ + if(List.of("A", "I", "S", "SP","RSP","USP").contains(client.legalType())){ + return Mono.just(client); + } + return Mono.error(new UnsuportedClientTypeException(client.legalType())); + }) + .doOnError(System.out::println); } /** @@ -291,7 +308,8 @@ private Mono buildAddress( addressDto.addressCity(), addressDto.postalCode().trim().replaceAll("\\s+", ""), index.getAndIncrement(), - (addressDto.addressType() != null ? addressDto.addressType() : "").concat(" address").toUpperCase() + (addressDto.addressType() != null ? addressDto.addressType() : "").concat( + " address").toUpperCase() ) ) .flatMap(address -> loadCountry(address.country().text()).map(address::withCountry)) @@ -303,6 +321,8 @@ private Mono buildAddress( .defaultIfEmpty(new ArrayList<>()) .flatMap(addresses -> Flux.fromIterable(document.parties()) + .filter(party -> + !"SP".equalsIgnoreCase(document.business().legalType()) || party.isPerson()) .map(party -> new ClientContactDto( null, @@ -381,21 +401,21 @@ private Function> triggerEmailDuplicatedC String email, String userName) { return legacy -> chesService.sendEmail( - "matched", - email, - "Client number application can’t go ahead", - legacy.description(userName), - null) + "matched", + email, + "Client number application can’t go ahead", + legacy.description(userName), + null) .thenReturn(legacy); } private Mono triggerEmail(EmailRequestDto emailRequestDto) { return chesService.sendEmail( - emailRequestDto.templateName(), - emailRequestDto.email(), - emailRequestDto.subject(), - emailRequestDto.variables(), - null); + emailRequestDto.templateName(), + emailRequestDto.email(), + emailRequestDto.subject(), + emailRequestDto.variables(), + null); } } diff --git a/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java b/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java index b5d48570fd..a2c7e807ef 100644 --- a/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java +++ b/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java @@ -54,7 +54,7 @@ public static > boolean isValidEnum( } if (!EnumUtils.isValidEnum(enumClass, value)) { - errors.rejectValue(field, String.format("%s has an invalid value", field)); + errors.rejectValue(field, String.format("%s has an invalid value [%s]", field,value)); return false; } return true; diff --git a/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java b/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java index 4318215a90..6e61e2e522 100644 --- a/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java +++ b/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java @@ -8,6 +8,7 @@ import ca.bc.gov.app.dto.client.ClientLocationDto; import ca.bc.gov.app.dto.client.ClientSubmissionDto; import java.time.LocalDate; +import java.util.List; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.StringUtils; @@ -19,10 +20,11 @@ @Component @RequiredArgsConstructor public class ClientSubmitRequestValidator implements Validator { + private final RegisteredBusinessInformationValidator registeredBusinessInformationValidator; private final UnregisteredBusinessInformationValidator unregisteredBusinessInformationValidator; private final ClientLocationDtoValidator locationDtoValidator; - + @Override public boolean supports(Class clazz) { return ClientSubmissionDto.class.equals(clazz); @@ -49,14 +51,13 @@ private void validateBusinessInformation( return; } errors.pushNestedPath(businessInformationField); - + String businessType = businessInformation.businessType(); if (StringUtils.isAllBlank(businessType)) { errors.rejectValue("businessType", "You must choose an option"); errors.popNestedPath(); return; - } - else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) { + } else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) { errors.rejectValue("businessType", String.format("%s has an invalid value", "Business type")); errors.popNestedPath(); return; @@ -64,19 +65,24 @@ else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) { String clientType = businessInformation.clientType(); - if(StringUtils.isBlank(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) + || ApplicationConstant.UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType) + || ApplicationConstant.INDIVIDUAL_CLIENT_TYPE_CODE.equals(clientType) ) { validateBirthdate(businessInformation.birthdate(), errors); } - + + if (!List.of("A", "I", "S", "USP", "RSP","SP").contains(clientType)) { + errors.rejectValue("businessType", + String.format("%s %s is not supported at the moment", "Business type",clientType)); + } + errors.popNestedPath(); if (BusinessTypeEnum.U.toString().equals(businessType)) { @@ -93,8 +99,7 @@ private void validateBirthdate(LocalDate birthdate, Errors errors) { String dobFieldName = "birthdate"; if (birthdate == null) { errors.rejectValue(dobFieldName, fieldIsMissingErrorMessage("Birthdate")); - } - else { + } else { LocalDate minAgeDate = LocalDate.now().minusYears(19); if (birthdate.isAfter(minAgeDate)) { errors.rejectValue(dobFieldName, "Sole proprietorship must be at least 19 years old"); diff --git a/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java b/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java index a98fa6103f..d0cb7ea675 100644 --- a/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java +++ b/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java @@ -24,6 +24,12 @@ public void validate(Object target, Errors errors) { String businessNameField = "businessName"; ValidationUtils.rejectIfEmpty(errors, businessNameField, fieldIsMissingErrorMessage(businessNameField)); + + // fails if businessName does not contain whitespace, Ex: forest1 should fail, but forest 1 should pass + String businessName = (String) errors.getFieldValue(businessNameField); + if (businessName != null && !businessName.matches(".*\\s+.*")) { + errors.rejectValue(businessNameField, "Business name must be composed of first and last name"); + } errors.popNestedPath(); } } diff --git a/backend/src/main/resources/db/migration/V2__data_initialization.sql b/backend/src/main/resources/db/migration/V2__data_initialization.sql index ca96949e6a..91e75ab7c0 100644 --- a/backend/src/main/resources/db/migration/V2__data_initialization.sql +++ b/backend/src/main/resources/db/migration/V2__data_initialization.sql @@ -31,29 +31,29 @@ insert into nrfc.client_type_code (client_type_code, description, effective_date insert into nrfc.client_type_code (client_type_code, description, effective_date, create_user) values ('USP', 'Unregistered sole proprietorship', current_timestamp, 'mariamar') on conflict (client_type_code) do nothing; insert into nrfc.client_type_code (client_type_code, description, effective_date, create_user) values ('RSP', 'Registered sole proprietorship', current_timestamp, 'mariamar') on conflict (client_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('AP', 'Accounts Payable', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('AR', 'Accounts Receivable', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BA', 'First Nations Administrator', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BC', 'First Nations Council Member', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('AP', 'Accounts Payable', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('AR', 'Accounts Receivable', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BA', 'First Nations Administrator', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BC', 'First Nations Council Member', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BL', 'Billing', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BM', 'First Nations Manager', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BN', 'First Nations Treaty Negotiator', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('CH', 'Chief', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('CL', 'Collections', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BM', 'First Nations Manager', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BN', 'First Nations Treaty Negotiator', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('CH', 'Chief', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('CL', 'Collections', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('DI', 'Director', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('EX', 'Export', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('GP', 'General Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('IL', 'Interior Log Cost Reporting', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('LB', 'Log Broker', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('LP', 'Limited Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('RC', 'Recreation Agreement Holder', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('EX', 'Export', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('GP', 'General Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('IL', 'Interior Log Cost Reporting', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('LB', 'Log Broker', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('LP', 'Limited Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('RC', 'Recreation Agreement Holder', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SI', 'Scale Site Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SP', 'SPAR System Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SR', 'Stumpage Rates', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SS', 'Scaling Software Vendor Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('SS', 'Scaling Software Vendor Contact', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TC', 'BCTS Contractor', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TN', 'Tenure Administration', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; -insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TP', 'EDI Trading Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; +insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('TP', 'EDI Trading Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing; insert into nrfc.country_code (country_code, description, effective_date, create_user) values ('AD', 'Andorra', current_timestamp, 'mariamar') on conflict (country_code) do nothing; insert into nrfc.country_code (country_code, description, effective_date, create_user) values ('AE', 'United Arab Emirates', current_timestamp, 'mariamar') on conflict (country_code) do nothing; diff --git a/backend/src/test/java/ca/bc/gov/app/TestConstants.java b/backend/src/test/java/ca/bc/gov/app/TestConstants.java index 092ae94477..c042e4c4d6 100644 --- a/backend/src/test/java/ca/bc/gov/app/TestConstants.java +++ b/backend/src/test/java/ca/bc/gov/app/TestConstants.java @@ -348,8 +348,8 @@ public class TestConstants { "email": "", "firstName": "JAMES", "lastName": "BAXTER", - "middleInitial": "JAMES", - "partyType": "Director" + "middleInitial": "middleInitial", + "partyType": "person" }, "roles": [ { @@ -411,10 +411,10 @@ public class TestConstants { "1234", "Goldfinger", "R", - "P", + "RSP", "Y", - "GP", - LocalDate.now() + "SP", + LocalDate.now().minusYears(20) ), new ClientLocationDto( List.of( @@ -450,7 +450,48 @@ public class TestConstants { new ClientSubmissionDto( new ClientBusinessInformationDto( "", - "James", + "James Baxter", + "U", + "I", + "", + "SP", + LocalDate.of(1975, 1, 31) + ), + new ClientLocationDto( + List.of( + new ClientAddressDto( + "3570 S Las Vegas Blvd", + new ClientValueTextDto("US", ""), + new ClientValueTextDto("NV", ""), + "Las Vegas", "89109", + 0, + "Billing Address" + ) + ), + List.of( + new ClientContactDto( + new ClientValueTextDto("LP", "LP"), + "James", + "Bond", + "9876543210", + "bond_james_bond@007.com", + 0, + List.of( + new ClientValueTextDto( + "0", + "Billing Address" + ) + ) + ) + ) + ) + ); + + public static final ClientSubmissionDto UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO = + new ClientSubmissionDto( + new ClientBusinessInformationDto( + "", + "forest1", "U", "I", "", diff --git a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java index 0f7cf73bdf..0371e41649 100644 --- a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java @@ -165,7 +165,7 @@ void shouldListCountryData(Integer page, Integer size, String code, String name) @MethodSource("provinceCode") @DisplayName("List provinces by") void shouldListProvinceData(String countryCode, Integer page, Integer size, String code, - String name) { + String name) { //This is to allow parameter to be ommitted during test Function uri = uriBuilder -> { @@ -274,18 +274,18 @@ void shouldGetClientDetails( legacyStub .stubFor( get(urlPathEqualTo("/search/incorporationOrName")) - .withQueryParam("incorporationNumber", equalTo("AA0000001")) - .withQueryParam("companyName", equalTo("SAMPLE COMPANY")) - .willReturn(okJson(legacyResponse)) + .withQueryParam("incorporationNumber", equalTo("AA0000001")) + .withQueryParam("companyName", equalTo("SAMPLE COMPANY")) + .willReturn(okJson(legacyResponse)) ); WebTestClient.BodyContentSpec response = client .get() .uri("/api/clients/{clientNumber}", Map.of("clientNumber", clientNumber)) - .header(ApplicationConstant.USERID_HEADER,"testUserId") - .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca") - .header(ApplicationConstant.USERNAME_HEADER,"Test User") + .header(ApplicationConstant.USERID_HEADER, "testUserId") + .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca") + .header(ApplicationConstant.USERNAME_HEADER, "Test User") .exchange() .expectStatus().isEqualTo(HttpStatus.valueOf(responseStatus)) .expectBody() @@ -364,9 +364,9 @@ void shouldGetDataFromNameLookup() { client .get() .uri("/api/clients/name/Power") - .header(ApplicationConstant.USERID_HEADER,"testUserId") - .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca") - .header(ApplicationConstant.USERNAME_HEADER,"Test User") + .header(ApplicationConstant.USERID_HEADER, "testUserId") + .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca") + .header(ApplicationConstant.USERNAME_HEADER, "Test User") .exchange() .expectStatus().isOk() .expectBody() @@ -390,9 +390,9 @@ void shouldGetNoDataFromNameLookup() { client .get() .uri("/api/clients/name/Jhon") - .header(ApplicationConstant.USERID_HEADER,"testUserId") - .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca") - .header(ApplicationConstant.USERNAME_HEADER,"Test User") + .header(ApplicationConstant.USERID_HEADER, "testUserId") + .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca") + .header(ApplicationConstant.USERNAME_HEADER, "Test User") .exchange() .expectStatus().isOk() .expectBody() @@ -401,7 +401,7 @@ void shouldGetNoDataFromNameLookup() { @Test @DisplayName("Send an email for already existing client") - void shouldSendEmail(){ + void shouldSendEmail() { chesStub .stubFor( post("/chess/uri") @@ -424,7 +424,8 @@ void shouldSendEmail(){ legacyStub .stubFor( get(urlPathEqualTo("/search/incorporationOrName")) - .withQueryParam("incorporationNumber", equalTo(TestConstants.EMAIL_REQUEST.incorporation())) + .withQueryParam("incorporationNumber", + equalTo(TestConstants.EMAIL_REQUEST.incorporation())) .withQueryParam("companyName", equalTo(TestConstants.EMAIL_REQUEST.name())) .willReturn(okJson(TestConstants.LEGACY_OK)) ); @@ -441,7 +442,7 @@ void shouldSendEmail(){ @Test @DisplayName("get country by code") - void shoulGgetCountryByCode(){ + void shoulGgetCountryByCode() { client .get() @@ -475,7 +476,7 @@ private static Stream clientDetailing() { 200, TestConstants.BCREG_DOC_REQ_RES, 200, TestConstants.BCREG_DOC_DATA, 200, TestConstants.BCREG_RESPONSE_OK, - TestConstants.LEGACY_OK.replace("0000001","0000002") + TestConstants.LEGACY_OK.replace("0000001", "0000002") ), Arguments.of( "AA0000001", @@ -519,6 +520,18 @@ private static Stream clientDetailing() { 400, TestConstants.BCREG_400, 401, TestConstants.BCREG_RESPONSE_401, TestConstants.LEGACY_EMPTY + ), + Arguments.of( + "AA0000001", + 200, TestConstants.BCREG_DOC_REQ_RES, + 200, TestConstants.BCREG_DOC_DATA + .replace("\"partyType\": \"person\"", "\"partyType\": \"organization\"") + .replace("\"firstName\": \"JAMES\",", "\"organizationName\": \"OWNER ORG\",") + .replace("\"lastName\": \"BAXTER\",", "\"identifier\": \"BB0000001\",") + .replace("\"middleInitial\": \"middleInitial\",", "\"id\": \"1234467\",") + , + 422, "Unable to process request. This sole proprietor is not owner by a person", + TestConstants.LEGACY_EMPTY ) ); } diff --git a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java index d6e71dbacf..48edf92daf 100644 --- a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java @@ -1,6 +1,7 @@ package ca.bc.gov.app.controller.client; import static ca.bc.gov.app.TestConstants.REGISTERED_BUSINESS_SUBMISSION_DTO; +import static ca.bc.gov.app.TestConstants.UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO; import static ca.bc.gov.app.TestConstants.UNREGISTERED_BUSINESS_SUBMISSION_DTO; import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.post; @@ -10,6 +11,7 @@ import ca.bc.gov.app.ApplicationConstant; import ca.bc.gov.app.TestConstants; +import ca.bc.gov.app.dto.ValidationError; import ca.bc.gov.app.dto.client.ClientSubmissionDto; import ca.bc.gov.app.dto.submissions.SubmissionApproveRejectDto; import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest; @@ -210,7 +212,7 @@ void shouldListAndSearch( .jsonPath("$.[0].name").isEqualTo("Goldfinger") .jsonPath("$.[0].requestType").isEqualTo("Submission pending processing") .jsonPath("$.[0].status").isEqualTo("New") - .jsonPath("$.[0].clientType").isEqualTo("General Partnership") + .jsonPath("$.[0].clientType").isEqualTo("Registered sole proprietorship") .jsonPath("$.[0].user").isEqualTo("testUserId"); } } @@ -250,6 +252,25 @@ void shouldApproveOrReject() { .isEmpty(); } + @Test + @DisplayName("Submit broken Unregistered Business client data") + @Order(7) + void shouldSubmitBrokenUnregisteredBusinessData() { + client + .post() + .uri("/api/clients/submissions") + .header(ApplicationConstant.USERID_HEADER, "testUserId") + .header(ApplicationConstant.USERMAIL_HEADER, "test@mail.ca") + .header(ApplicationConstant.USERNAME_HEADER, "Test User") + .body(Mono.just(UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO), ClientSubmissionDto.class) + .exchange() + .expectStatus().isBadRequest() + .expectBodyList(ValidationError.class) + .hasSize(1) + .contains(new ValidationError("businessInformation.businessName", + "Business name must be composed of first and last name")); + } + private static Stream listValues() { return Stream.of( @@ -258,7 +279,7 @@ private static Stream listValues() { Arguments.of(null, null, 0, 10, true), Arguments.of(null, null, null, 10, true), Arguments.of("requestStatus", "N", null, null, true), - Arguments.of("clientType", "P", null, null, true), + Arguments.of("clientType", "RSP", null, null, true), Arguments.of("name", "Goldfinger", null, null, true), Arguments.of("name", "Auric", null, null, false), Arguments.of(null, null, 1, null, false), diff --git a/frontend/.devcontainer/frontend.code-workspace b/frontend/.devcontainer/frontend.code-workspace index 4762389c62..7a2c6b8e08 100644 --- a/frontend/.devcontainer/frontend.code-workspace +++ b/frontend/.devcontainer/frontend.code-workspace @@ -11,7 +11,7 @@ "editor.formatOnPaste": false, "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "editor.tabSize": 2, "vs-code-prettier-eslint.prettierLast": true, diff --git a/frontend/cypress/e2e/SubmissionReviewPage.cy.ts b/frontend/cypress/e2e/SubmissionReviewPage.cy.ts new file mode 100644 index 0000000000..0e447103de --- /dev/null +++ b/frontend/cypress/e2e/SubmissionReviewPage.cy.ts @@ -0,0 +1,188 @@ +import testCases from '../fixtures/test-cases-review-submissions.json'; + +/* eslint-disable no-undef */ +describe('Submission Review Page', () => { + + //Login before all tests + beforeEach(() => { + cy.visit("/"); + cy.wait(500); + + cy.get("#landing-title").should("contain", "Client Management System"); + + cy.get("#landing-subtitle").should( + "contain", + "Create and manage client accounts" + ); + + cy.login("uattest@gov.bc.ca", "Uat Test", "idir", + { + given_name: "James", + family_name: "Baxter" + } + ); + + //Some simple checks to make sure we are on the list page + cy.contains('Submission') + + cy + .get('h3') + .should('exist') + .should('contain', 'Submissions') + + cy + .get('.body-compact-01') + .should('exist') + .should('contain', 'Check and manage client submissions') + + }) + + testCases.forEach((testCase) => { + + if(testCase.approved){ + it(`Should check for ${testCase.name}`, () => { + //Load the fixture for the details + cy.intercept("GET", "api/clients/submissions/*", { + fixture: testCase.fixture, + }).as("loadSubmission"); + + + //Click any submission + cy + .get('[sort-id="0"] > :nth-child(2)') + .click() + + cy + .wait('@loadSubmission') + .its('response.body.submissionStatus') + .should('eq', 'Approved') + + cy + .get('.submission-details--title > span') + .should('contain', 'Auto approved client:') + + cy.get('[data-testid="display-row-icon"]') + .should('exist') + .should('have.prop', 'tagName', 'svg') + .should('have.attr', 'alt', 'Auto approved client'); + + cy.get('[data-testid="subtitle"]') + .should('exist') + .should('contain', 'Check this new client data'); + + cy.get('cds-actionable-notification') + .should('exist') + .should('contain', 'No matching client records or BC Registries standing issues were found. Review the details in the read-only version below.'); + + cy.get('.grouping-10 > :nth-child(2) > .body-compact-01') + .should('exist') + .should('contain', testCase.clientNumber); + + //Go to the submission list page + cy.visit('/submissions'); + + //Some simple checks to make sure we are on the list page + cy.contains('Submission') + + cy + .get('h3') + .should('exist') + .should('contain', 'Submissions') + + cy + .get('.body-compact-01') + .should('exist') + .should('contain', 'Check and manage client submissions') + + }); + }else{ + it(`Should check for ${testCase.name}`, () => { + //Load the fixture for the details + cy.intercept("GET", "api/clients/submissions/*", { + fixture: testCase.fixture, + }).as("loadSubmission"); + + + //Click any submission + cy + .get('[sort-id="0"] > :nth-child(2)') + .click() + + cy + .wait('@loadSubmission') + .its('response.body.submissionStatus') + .should('eq', 'New') + + cy + .get('.submission-details--title > span') + .should('contain', 'Review new client:') + + cy.get('[data-testid="display-row-icon"]') + .should('exist') + .should('have.prop', 'tagName', 'svg') + .should('have.attr', 'alt', 'Review new client'); + + cy.get('[data-testid="subtitle"]') + .should('exist') + .should('contain', 'Check and manage this submission for a new client number'); + + if(testCase.goodStanding){ + cy.get('cds-actionable-notification') + .should('exist') + .should('contain', "Check this client's standing with"); + } + + if(testCase.incorporationName){ + cy.get('cds-actionable-notification') + .should('exist') + .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:") + .should('contain', `Legal name: ${testCase.incorporationName}`); + } + + if(testCase.incorporationNumber){ + cy.get('cds-actionable-notification') + .should('exist') + .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:") + .should('contain', `Incorporation number: ${testCase.incorporationNumber}`); + } + + if(testCase.contact){ + cy.get('cds-actionable-notification') + .should('exist') + .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:") + .should('contain', `Contact: ${testCase.contact}`); + } + + cy.get('.grouping-15 > [kind="primary"]') + .should('exist') + + cy.get('.grouping-15 > [kind="danger"]') + .should('exist') + + + + }); + } + + }); + + + afterEach(() => { + //Go to the submission list page + cy.visit('/submissions'); + + //Some simple checks to make sure we are on the list page + cy.contains('Submission') + + cy + .get('h3') + .should('exist') + .should('contain', 'Submissions') + + cy + .get('.body-compact-01') + .should('exist') + .should('contain', 'Check and manage client submissions') + }); + +}) diff --git a/frontend/cypress/fixtures/test-case-review-all.json b/frontend/cypress/fixtures/test-case-review-all.json new file mode 100644 index 0000000000..db94cd27d2 --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-all.json @@ -0,0 +1,58 @@ +{ + "submissionId": "1", + "submissionStatus": "New", + "submissionType": "Review new client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-03 00:00:00", + "updateUser": "Isador Driver", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "GP12345678", + "clientNumber":"", + "organizationName": "KOVACEK, THOMPSON AND BOYER", + "clientType": "General partnership", + "goodStanding": null + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "290fae20-5694-4dfa-84a0-baabae352ad5" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"444 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": { + "goodStanding": "Value not found", + "corporationName":"00141847", + "incorporationNumber":"00151847", + "contact":"00161847" + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-case-review-auto-approved.json b/frontend/cypress/fixtures/test-case-review-auto-approved.json new file mode 100644 index 0000000000..2ef8542799 --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-auto-approved.json @@ -0,0 +1,53 @@ +{ + "submissionId": "1", + "submissionStatus": "Approved", + "submissionType": "Auto approved client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-02 01:00:00", + "updateUser": "CLIADMIN", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "XX12321254", + "clientNumber":"12345678", + "organizationName": "THE TIMBER SOCIETY OF NORTH SASKATCHEWAN AND REGION LLC", + "clientType": "Corporation", + "goodStanding": "Y" + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "db3cd337-38b2-4aa7-b18c-dc6ca2383f8a" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"1414 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": {} +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-case-review-contact.json b/frontend/cypress/fixtures/test-case-review-contact.json new file mode 100644 index 0000000000..253a100998 --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-contact.json @@ -0,0 +1,55 @@ +{ + "submissionId": "1", + "submissionStatus": "New", + "submissionType": "Review new client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-03 00:00:00", + "updateUser": "Isador Driver", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "GP12345678", + "clientNumber":"", + "organizationName": "KOVACEK, THOMPSON AND BOYER", + "clientType": "General partnership", + "goodStanding": null + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "290fae20-5694-4dfa-84a0-baabae352ad5" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"444 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": { + "contact":"00161847" + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-case-review-goodstanding.json b/frontend/cypress/fixtures/test-case-review-goodstanding.json new file mode 100644 index 0000000000..405ee25658 --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-goodstanding.json @@ -0,0 +1,55 @@ +{ + "submissionId": "1", + "submissionStatus": "New", + "submissionType": "Review new client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-03 00:00:00", + "updateUser": "Isador Driver", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "GP12345678", + "clientNumber":"", + "organizationName": "KOVACEK, THOMPSON AND BOYER", + "clientType": "General partnership", + "goodStanding": null + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "290fae20-5694-4dfa-84a0-baabae352ad5" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"444 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": { + "goodStanding": "Value not found" + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-case-review-incorporationName.json b/frontend/cypress/fixtures/test-case-review-incorporationName.json new file mode 100644 index 0000000000..adce0b8579 --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-incorporationName.json @@ -0,0 +1,55 @@ +{ + "submissionId": "1", + "submissionStatus": "New", + "submissionType": "Review new client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-03 00:00:00", + "updateUser": "Isador Driver", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "GP12345678", + "clientNumber":"", + "organizationName": "KOVACEK, THOMPSON AND BOYER", + "clientType": "General partnership", + "goodStanding": null + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "290fae20-5694-4dfa-84a0-baabae352ad5" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"444 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": { + "corporationName":"00141847" + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-case-review-incorporationNumber.json b/frontend/cypress/fixtures/test-case-review-incorporationNumber.json new file mode 100644 index 0000000000..058f13854c --- /dev/null +++ b/frontend/cypress/fixtures/test-case-review-incorporationNumber.json @@ -0,0 +1,55 @@ +{ + "submissionId": "1", + "submissionStatus": "New", + "submissionType": "Review new client", + "submittedTimestamp": "2024-01-01 00:00:00", + "updateTimestamp": "2024-01-02 00:00:00", + "approvedTimestamp": "2024-01-03 00:00:00", + "updateUser": "Isador Driver", + "business": { + "businessType": "Registered Business", + "incorporationNumber": "GP12345678", + "clientNumber":"", + "organizationName": "KOVACEK, THOMPSON AND BOYER", + "clientType": "General partnership", + "goodStanding": null + }, + "contact": [ + { + "index": 0, + "contactType": "Accounts Receivable", + "firstName": "Test", + "lastName": "Uat", + "phoneNumber": "2502502550", + "emailAddress": "uattest@gov.bc.ca", + "locations": [ + "Mailing address", + "Accountant's address" + ], + "userId": "290fae20-5694-4dfa-84a0-baabae352ad5" + } + ], + "address": [ + { + "index": 0, + "streetAddress":"444 Richmond Ave", + "country":"Canada", + "province":"Saskatchewan", + "city":"Hampton", + "postalCode": "H0H0H0", + "name": "Mailing address" + }, + { + "index": 1, + "streetAddress":"333 Oak St", + "country":"Canada", + "province":"British Columbia", + "city":"Deer Lake", + "postalCode":"V4V4V4", + "name": "Accountant's address" + } + ], + "matchers": { + "incorporationNumber":"00151847" + } +} \ No newline at end of file diff --git a/frontend/cypress/fixtures/test-cases-review-submissions.json b/frontend/cypress/fixtures/test-cases-review-submissions.json new file mode 100644 index 0000000000..4885e48173 --- /dev/null +++ b/frontend/cypress/fixtures/test-cases-review-submissions.json @@ -0,0 +1,41 @@ +[ + { + "name": "Auto Approved Corporation", + "fixture": "test-case-review-auto-approved.json", + "approved": true, + "clientNumber": "12345678" + }, + { + "name": "Review one match - good standing", + "fixture": "test-case-review-goodstanding.json", + "approved": false, + "goodStanding": true + }, + { + "name": "Review one match - incorporation name", + "fixture": "test-case-review-incorporationName.json", + "approved": false, + "incorporationName": "00141847" + }, + { + "name": "Review one match - incorporation number", + "fixture": "test-case-review-incorporationNumber.json", + "approved": false, + "incorporationNumber": "00151847" + }, + { + "name": "Review one match - contact", + "fixture": "test-case-review-contact.json", + "approved": false, + "contact": "00161847" + }, + { + "name": "Review multiple matches", + "fixture": "test-case-review-all.json", + "approved": false, + "goodStanding": true, + "incorporationName": "00141847", + "incorporationNumber": "00151847", + "contact": "00161847" + } +] \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index c10335d713..772d757b63 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -39,7 +39,9 @@ "posttest:e2e": "mv reports/.nyc_report reports/e2e", "test:report:merge": "mkdir -p .nyc_output && rm -rf coverage && nyc --config nyc.config.json merge reports && mv coverage.json .nyc_output/out.json && nyc --config nyc.config.json report --reporter lcov --reporter text-summary --report-dir coverage", "test:report:clean": "mkdir -p reports/.nyc_output/processinfo && mkdir -p coverage", - "test:build": "start-server-and-test preview http://127.0.0.1:3000/ 'cypress open'" + "test:build": "start-server-and-test preview http://127.0.0.1:3000/ 'cypress open'", + "test:flush": "rm -rf reports && rm -rf .nyc_output && rm -rf coverage", + "posttest:flush":"npm run coverage" }, "dependencies": { "@bcgov-nr/nr-fsa-theme": "^1.1.3", diff --git a/frontend/src/dto/CommonTypesDto.ts b/frontend/src/dto/CommonTypesDto.ts index 7d68daf02c..af07cf8609 100644 --- a/frontend/src/dto/CommonTypesDto.ts +++ b/frontend/src/dto/CommonTypesDto.ts @@ -166,5 +166,7 @@ export interface SubmissionDetailsAddress { export interface SubmissionDetailsMatchers { goodStanding: string - legalName: string + corporationName: string + incorporationNumber: string + contact: string } diff --git a/frontend/src/pages/FormBCeIDPage.vue b/frontend/src/pages/FormBCeIDPage.vue index bedb58d381..49db5a0d7b 100644 --- a/frontend/src/pages/FormBCeIDPage.vue +++ b/frontend/src/pages/FormBCeIDPage.vue @@ -328,6 +328,7 @@ const submit = () => { exitBus.on((event: Record) => { endAndLogOut.value = event.goodStanding ? event.goodStanding : false; mailAndLogOut.value = event.duplicated ? event.duplicated : false; + endAndLogOut.value = event.nonPersonSP ? event.nonPersonSP : endAndLogOut.value; }); progressIndicatorBus.on((event: ProgressNotification) => { diff --git a/frontend/src/pages/SubmissionReviewPage.vue b/frontend/src/pages/SubmissionReviewPage.vue index 07e9a1a602..062743c6e8 100644 --- a/frontend/src/pages/SubmissionReviewPage.vue +++ b/frontend/src/pages/SubmissionReviewPage.vue @@ -56,7 +56,10 @@ const data = ref({ address: [], matchers: { goodStanding: '', - legalName: '', + corporationName: '', + incorporationNumber: '', + contact: '', + } }) @@ -190,6 +193,20 @@ const tagColor = (status: string) =>{ return 'purple' } } + +const matchingData = computed(() => { + let results = [] + if(data.value.matchers.corporationName){ + results = [...results, ...data.value.matchers.corporationName.split(',')] + } + if(data.value.matchers.incorporationNumber){ + results = [...results, ...data.value.matchers.incorporationNumber.split(',')] + } + if(data.value.matchers.contact){ + results = [...results, ...data.value.matchers.contact.split(',')] + } + return results +})