Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23b1d7b

Browse files
authored
Merge pull request #4738 from mruff-aeq/34522_remove-active-cao-validation
34522 - Remove Active CAO Validation for Amalgamation Out Filing
2 parents f8650ac + 9e0e625 commit 23b1d7b

2 files changed

Lines changed: 9 additions & 51 deletions

File tree

legal-api/src/legal_api/services/filings/validations/amalgamation_out.py

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from flask_babel import _ as babel
1919

2020
from business_common.utils.legislation_datetime import LegislationDatetime
21-
from business_model.models import Business, ConsentContinuationOut
21+
from business_model.models import Business
2222
from legal_api.errors import Error
2323
from legal_api.services import flags
2424
from legal_api.services.filings.validations.common_validations import (
@@ -41,20 +41,11 @@ def validate(business: Business, filing: dict) -> Error | None:
4141
msg = []
4242
filing_type = "amalgamationOut"
4343

44-
is_valid_co_date = True
45-
is_valid_foreign_jurisdiction = True
46-
47-
if err := validate_amalgamation_out_date(filing, f"/filing/{filing_type}/amalgamationOutDate"):
48-
msg.extend(err)
49-
is_valid_co_date = False
50-
51-
if err := validate_foreign_jurisdiction(filing["filing"][filing_type]["foreignJurisdiction"],
52-
f"/filing/{filing_type}/foreignJurisdiction"):
53-
msg.extend(err)
54-
is_valid_foreign_jurisdiction = False
55-
56-
if is_valid_co_date and is_valid_foreign_jurisdiction:
57-
msg.extend(validate_active_cao(business, filing, filing_type))
44+
msg.extend(validate_amalgamation_out_date(filing, f"/filing/{filing_type}/amalgamationOutDate"))
45+
msg.extend(validate_foreign_jurisdiction(
46+
filing["filing"][filing_type]["foreignJurisdiction"],
47+
f"/filing/{filing_type}/foreignJurisdiction"
48+
))
5849

5950
if court_order := filing.get("filing", {}).get(filing_type, {}).get("courtOrder", None):
6051
court_order_path: Final = f"/filing/{filing_type}/courtOrder"
@@ -65,35 +56,6 @@ def validate(business: Business, filing: dict) -> Error | None:
6556
return None
6657

6758

68-
def validate_active_cao(business: Business, filing: dict, filing_type: str) -> list:
69-
"""Validate active consent amalgamation out."""
70-
msg = []
71-
amalgamation_out_date_str = filing["filing"][filing_type]["amalgamationOutDate"]
72-
amalgamation_out_date = LegislationDatetime.as_legislation_timezone_from_date_str(amalgamation_out_date_str)
73-
74-
foreign_jurisdiction = filing["filing"][filing_type]["foreignJurisdiction"]
75-
country_code = foreign_jurisdiction.get("country")
76-
region = foreign_jurisdiction.get("region")
77-
78-
amalgamation_out_date_utc = LegislationDatetime.as_utc_timezone(amalgamation_out_date)
79-
caos = ConsentContinuationOut.get_active_cco(business.id, amalgamation_out_date_utc, country_code, region,
80-
consent_type=ConsentContinuationOut.ConsentTypes.amalgamation_out)
81-
82-
active_consent = False
83-
# Make sure amalgamation_out_date is on or after consent filing effective date
84-
for consent in caos:
85-
if amalgamation_out_date.date() >= \
86-
LegislationDatetime.as_legislation_timezone(consent.filing.effective_date).date():
87-
active_consent = True
88-
break
89-
90-
if not active_consent:
91-
msg.extend([{"error": "No active consent amalgamation out for this date and/or jurisdiction.",
92-
"path": f"/filing/{filing_type}/amalgamationOutDate"}])
93-
94-
return msg
95-
96-
9759
def validate_amalgamation_out_date(filing: dict, amalgamation_out_date_path: str) -> list:
9860
"""Validate amalgamation out date."""
9961
msg = []

legal-api/tests/unit/services/filings/validations/test_amalgamation_out.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
date_format = '%Y-%m-%d'
3030
legal_name = 'Test name request'
31-
validate_active_cao_path = 'legal_api.services.filings.validations.amalgamation_out.validate_active_cao'
3231

3332

3433
def _create_consent_amalgamation_out(business, foreign_jurisdiction, effective_date=datetime.utcnow()):
@@ -55,7 +54,7 @@ def _create_consent_amalgamation_out(business, foreign_jurisdiction, effective_d
5554
'test_name, expected_code, message',
5655
[
5756
('FAIL_IN_FUTURE', HTTPStatus.BAD_REQUEST, 'Amalgamation out date must be today or past.'),
58-
('FAIL_NO_CAO', HTTPStatus.BAD_REQUEST, 'No active consent amalgamation out for this date and/or jurisdiction.'),
57+
('SUCCESS_NO_CAO', None, None),
5958
('SUCCESS', None, None)
6059
]
6160
)
@@ -76,7 +75,7 @@ def test_validate_amalgamation_out_date(session, test_name, expected_code, messa
7675
if test_name == 'FAIL_IN_FUTURE':
7776
filing['filing']['amalgamationOut']['amalgamationOutDate'] = \
7877
(LegislationDatetime.now() + datedelta.datedelta(days=1)).strftime(date_format)
79-
elif test_name == 'FAIL_NO_CAO':
78+
elif test_name == 'SUCCESS_NO_CAO':
8079
effective_date -= datedelta.datedelta(months=6, days=1)
8180

8281
_create_consent_amalgamation_out(business,
@@ -85,7 +84,7 @@ def test_validate_amalgamation_out_date(session, test_name, expected_code, messa
8584
err = validate(business, filing)
8685

8786
# validate outcomes
88-
if test_name != 'SUCCESS':
87+
if test_name == 'FAIL_IN_FUTURE':
8988
assert expected_code == err.code
9089
assert message == err.msg[0]['error']
9190
else:
@@ -126,7 +125,6 @@ def test_validate_foreign_jurisdiction(session, mocker, test_name, expected_code
126125
filing['filing']['amalgamationOut']['foreignJurisdiction']['country'] = 'US'
127126
filing['filing']['amalgamationOut']['foreignJurisdiction']['region'] = 'NONE'
128127

129-
mocker.patch(validate_active_cao_path, return_value=[])
130128
err = validate(business, filing)
131129

132130
# validate outcomes
@@ -147,7 +145,6 @@ def test_valid_foreign_jurisdiction(session, mocker, monkeypatch):
147145
business = factory_business(identifier='BC1234567', entity_type='BC', founding_date=datetime.utcnow())
148146
filing = copy.deepcopy(FILING_HEADER)
149147
filing['filing']['header']['name'] = 'amalgamationOut'
150-
mocker.patch(validate_active_cao_path, return_value=[])
151148

152149
for country in pycountry.countries:
153150
filing['filing']['amalgamationOut'] = copy.deepcopy(AMALGAMATION_OUT)
@@ -191,7 +188,6 @@ def test_amalgamation_out_court_order(session, mocker, test_status, file_number,
191188
else:
192189
del filing['filing']['amalgamationOut']['courtOrder']['fileNumber']
193190

194-
mocker.patch(validate_active_cao_path, return_value=[])
195191
err = validate(business, filing)
196192

197193
# validate outcomes

0 commit comments

Comments
 (0)