diff --git a/legal-api/src/legal_api/services/filings/validations/continuation_in.py b/legal-api/src/legal_api/services/filings/validations/continuation_in.py index 3502cc795..59bb1dab4 100644 --- a/legal-api/src/legal_api/services/filings/validations/continuation_in.py +++ b/legal-api/src/legal_api/services/filings/validations/continuation_in.py @@ -192,21 +192,8 @@ def validate_business_in_colin(filing_json: dict, filing_type: str) -> list: elif legal_name != response_json['business']['legalName']: msg.append({'error': 'Legal name does not match with company legal name from Colin.', 'path': business_legal_name_path}) - else: - # Check if founding date is None - if founding_date is None: - msg.append({ - 'error': 'Founding date is missing in the filing data.', - 'path': business_founding_date_path - }) - else: - if dt.fromisoformat(founding_date) != dt.fromisoformat(response_json['business']['foundingDate']): - msg.append({ - 'error': ( - f"Founding date does not match with founding date from Colin. " - f"Filing founding_date: {founding_date}, " - f"Colin API founding_date: {response_json['business']['foundingDate']}" - ), - 'path': business_founding_date_path - }) + elif founding_date != response_json['business']['foundingDate']: + msg.append({'error': 'Founding date does not match with founding date from Colin.', + 'path': business_founding_date_path}) + return msg diff --git a/legal-api/tests/unit/services/filings/validations/test_continuation_in.py b/legal-api/tests/unit/services/filings/validations/test_continuation_in.py index 2f0e4553b..24192e6b0 100644 --- a/legal-api/tests/unit/services/filings/validations/test_continuation_in.py +++ b/legal-api/tests/unit/services/filings/validations/test_continuation_in.py @@ -753,7 +753,7 @@ def test_validate_business_in_colin_founding_date_mismatch(mocker, app, session) 'identifier': 'A0077779', 'legalName': 'Test Company Inc.', # Different founding date to trigger validation error - 'foundingDate': '2010-01-01T18:00:00-00:00' + 'foundingDate': '2010-01-01T18:21:13-00:00' } } )) @@ -763,6 +763,35 @@ def test_validate_business_in_colin_founding_date_mismatch(mocker, app, session) assert err[0]['path'] == '/filing/continuationIn/business/foundingDate' +def test_validate_business_in_colin_founding_date_match(mocker, app, session): + """Assert continuation EXPRO business with matching founding date.""" + filing = {'filing': {}} + filing['filing']['header'] = {'name': 'continuationIn', 'date': '2019-04-08', + 'certifiedBy': 'full name', 'email': 'no_one@never.get', 'filingId': 1} + filing['filing']['continuationIn'] = copy.deepcopy(CONTINUATION_IN) + + # Add the EXPRO business data with a matching founding date + filing['filing']['continuationIn']['business'] = { + 'identifier': 'A0077779', + 'legalName': 'Test Company Inc.', + 'foundingDate': '2009-07-23T18:31:24-00:00' + } + + mocker.patch('legal_api.services.colin.query_business', return_value=mocker.Mock( + status_code=HTTPStatus.OK, + json=lambda: { + 'business': { + 'identifier': 'A0077779', + 'legalName': 'Test Company Inc.', + 'foundingDate': '2009-07-23T18:31:24-00:00' + } + } + )) + + err = validate_business_in_colin(filing, 'continuationIn') + assert len(err) == 0 + + def test_validate_foreign_jurisdiction_incorporation_date(mocker, app, session): """Assert that an error is raised if the incorporation date is set to a future date.""" # Prepare a filing JSON with a future incorporation date