diff --git a/src/registry_schemas/example_data/schema_data.py b/src/registry_schemas/example_data/schema_data.py index 3c0363d..8a8f77e 100644 --- a/src/registry_schemas/example_data/schema_data.py +++ b/src/registry_schemas/example_data/schema_data.py @@ -2342,6 +2342,7 @@ } CONTINUATION_IN = { + 'isApproved': False, 'business': { 'identifier': 'A1234567', # Identifier of the registered extra provincial business 'legalName': 'HAULER SERVICES IN BC' diff --git a/src/registry_schemas/schemas/continuation_in.json b/src/registry_schemas/schemas/continuation_in.json index 6ad8ce5..fa22e0d 100644 --- a/src/registry_schemas/schemas/continuation_in.json +++ b/src/registry_schemas/schemas/continuation_in.json @@ -10,14 +10,38 @@ "properties": { "continuationIn": { "type": "object", - "required": [ - "foreignJurisdiction", - "authorization", - "nameRequest", - "offices", - "parties" - ], + "if": { + "properties": { + "isApproved": { + "const": false + } + } + }, + "then": { + "$comment": "if isApproved is false or not defined", + "required": [ + "nameRequest", + "authorization", + "foreignJurisdiction", + "contactPoint" + ] + }, + "else": { + "required": [ + "nameRequest", + "authorization", + "foreignJurisdiction", + "contactPoint", + "offices", + "parties", + "shareStructure" + ] + }, "properties": { + "isApproved": { + "type": "boolean", + "title": "Continuation In Authorization has been approved." + }, "business": { "$ref": "https://bcrs.gov.bc.ca/.well_known/schemas/business#/properties/business", "title": "Provide identifier and/or taxId if already registered as extra provincial business." diff --git a/src/registry_schemas/version.py b/src/registry_schemas/version.py index 029133b..631c5bb 100644 --- a/src/registry_schemas/version.py +++ b/src/registry_schemas/version.py @@ -23,4 +23,4 @@ """ -__version__ = '2.18.28' # pylint: disable=invalid-name +__version__ = '2.18.29' # pylint: disable=invalid-name diff --git a/tests/unit/test_continuation_in.py b/tests/unit/test_continuation_in.py index c8b5e0f..e1ed8e6 100644 --- a/tests/unit/test_continuation_in.py +++ b/tests/unit/test_continuation_in.py @@ -114,6 +114,7 @@ def test_validate_no_offices(): def test_validate_no_parties(): """Assert not valid if parties are ommited.""" continuation_in_json = copy.deepcopy(CONTINUATION_IN) + continuation_in_json['isApproved'] = True del continuation_in_json['parties'] legal_filing = {'continuationIn': continuation_in_json} @@ -141,3 +142,41 @@ def test_validate_share_classes_no_name(): print(errors) assert not is_valid + + +def test_validate_continuation_in_submit_authorization(): + """Assert valid if continuation in can be submitted for approval without these props.""" + continuation_in_json = copy.deepcopy(CONTINUATION_IN) + del continuation_in_json['isApproved'] # removing isApproved will trigger 'then' (equivalent to False) + del continuation_in_json['offices'] + del continuation_in_json['parties'] + del continuation_in_json['shareStructure'] + legal_filing = {'continuationIn': continuation_in_json} + + is_valid, errors = validate(legal_filing, 'continuation_in') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert is_valid + + +def test_validate_continuation_in_submit_after_approval(): + """Assert not valid if these are ommited.""" + continuation_in_json = copy.deepcopy(CONTINUATION_IN) + continuation_in_json['isApproved'] = True + del continuation_in_json['offices'] + del continuation_in_json['parties'] + del continuation_in_json['shareStructure'] + legal_filing = {'continuationIn': continuation_in_json} + + is_valid, errors = validate(legal_filing, 'continuation_in') + + if errors: + for err in errors: + print(err.message) + print(errors) + + assert not is_valid