Skip to content

Commit c5a49b8

Browse files
authored
29852 - Adding FF to Filings (bcgov#3715)
* 29852 - Adding FF to Filings * updated message * updated linting * added business summary flag * updated condition * only summary doc * updated http code * added agm extension * local file update * updated all types for local * updated * updated mocked flags * updated flags * flags mock update * testing update
1 parent 52ef990 commit c5a49b8

20 files changed

Lines changed: 229 additions & 38 deletions

legal-api/src/legal_api/services/business/validations/validator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from legal_api.errors import Error
2020
from legal_api.models import Business
21+
from legal_api.services import flags
2122

2223

2324
document_rule_set = {
@@ -40,7 +41,10 @@ def validate_document_request(document_type, business: Business):
4041
"""Validate the business document request."""
4142
errors = []
4243
# basic checks
43-
44+
enabled_filings = flags.value('enabled-business-summary-entities').split()
45+
if enabled_filings and document_type == 'summary' and business.legal_type not in enabled_filings:
46+
return Error(HTTPStatus.FORBIDDEN,
47+
[{'error': babel(f'{business.legal_type} is not enabled business summary.')}])
4448
if document_rules := document_rule_set.get(document_type, None):
4549
excluded_legal_types = document_rules.get('excluded_types', None)
4650
if excluded_legal_types and business.legal_type in excluded_legal_types:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# noqa: I003
2121
from legal_api.errors import Error
2222
from legal_api.models import Business
23+
from legal_api.services import flags
2324
from legal_api.utils.legislation_datetime import LegislationDatetime
2425
from ...utils import get_bool, get_int, get_str # noqa: I003
2526
# noqa: I003
@@ -34,6 +35,10 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
3435
if not business or not filing:
3536
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}])
3637

38+
enabled_filings = flags.value('support-agm-extension-entities').split()
39+
if enabled_filings and business.legal_type not in enabled_filings:
40+
return Error(HTTPStatus.FORBIDDEN,
41+
[{'error': babel(f'{business.legal_type} does not support agm extension filing.')}])
3742
msg = []
3843

3944
is_first_agm = get_bool(filing, f'{AGM_EXTENSION_PATH}/isFirstAgm')

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# noqa: I003
2020
from legal_api.errors import Error
2121
from legal_api.models import Business
22+
from legal_api.services import flags
2223
from legal_api.services.utils import get_int
2324
from legal_api.utils.legislation_datetime import LegislationDatetime
2425
# noqa: I003
@@ -29,6 +30,11 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
2930
if not business or not filing:
3031
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}])
3132

33+
enabled_filings = flags.value('supported-agm-location-change-entities').split()
34+
if enabled_filings and business.legal_type not in enabled_filings:
35+
return Error(HTTPStatus.FORBIDDEN,
36+
[{'error': babel(f'{business.legal_type} does not support agm location change filing.')}])
37+
3238
msg = []
3339

3440
agm_year_path: Final = '/filing/agmLocationChange/year'

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# noqa: I003
2020
from legal_api.errors import Error
2121
from legal_api.models import Business, ConsentContinuationOut
22+
from legal_api.services import flags
2223
from legal_api.services.filings.validations.common_validations import (
2324
validate_court_order,
2425
validate_foreign_jurisdiction,
@@ -33,6 +34,11 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
3334
if not business or not filing:
3435
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}])
3536

37+
enabled_filings = flags.value('supported-amalgamation-out-entities').split()
38+
if enabled_filings and business.legal_type not in enabled_filings:
39+
return Error(HTTPStatus.FORBIDDEN,
40+
[{'error': babel(f'{business.legal_type} does not support amalgamation out filing.')}])
41+
3642
msg = []
3743
filing_type = 'amalgamationOut'
3844

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# noqa: I004
2121
from legal_api.errors import Error
2222
from legal_api.models import Business, ConsentContinuationOut
23+
from legal_api.services import flags
2324
from legal_api.services.filings.validations.common_validations import (
2425
validate_court_order,
2526
validate_foreign_jurisdiction,
@@ -37,6 +38,11 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
3738
'error': babel('Business should be Active and in Good Standing to file Consent Amalgamation Out.')
3839
}])
3940

41+
enabled_filings = flags.value('supported-consent-amalgamation-out-entities').split()
42+
if enabled_filings and business.legal_type not in enabled_filings:
43+
return Error(HTTPStatus.FORBIDDEN,
44+
[{'error': babel(f'{business.legal_type} does not support consent amalgamation out filing.')}])
45+
4046
msg = []
4147
filing_type = 'consentAmalgamationOut'
4248

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# noqa: I004
2121
from legal_api.errors import Error
2222
from legal_api.models import Business, ConsentContinuationOut
23+
from legal_api.services import flags
2324
from legal_api.services.filings.validations.common_validations import (
2425
validate_court_order,
2526
validate_foreign_jurisdiction,
@@ -37,6 +38,11 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
3738
'error': babel('Business should be Active and in Good Standing to file Consent Continuation Out.')
3839
}])
3940

41+
enabled_filings = flags.value('supported-consent-continuation-out-entities').split()
42+
if enabled_filings and business.legal_type not in enabled_filings:
43+
return Error(HTTPStatus.FORBIDDEN,
44+
[{'error': babel(f'{business.legal_type} does not support consent continuation out filing.')}])
45+
4046
msg = []
4147
filing_type = 'consentContinuationOut'
4248

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from legal_api.errors import Error
2121
from legal_api.models import Business, PartyRole
22-
from legal_api.services import colin
22+
from legal_api.services import colin, flags
2323
from legal_api.services.filings.validations.common_validations import (
2424
validate_court_order,
2525
validate_foreign_jurisdiction,
@@ -54,6 +54,11 @@ def validate(filing_json: dict) -> Optional[Error]: # pylint: disable=too-many-
5454
msg.append({'error': babel('Legal type is required.'), 'path': legal_type_path})
5555
return msg # Cannot continue validation without legal_type
5656

57+
enabled_filings = flags.value('supported-continuation-in-entities').split()
58+
if enabled_filings and legal_type not in enabled_filings:
59+
return Error(HTTPStatus.FORBIDDEN,
60+
[{'error': babel(f'{legal_type} does not support continuation in filing.')}])
61+
5762
msg.extend(validate_business_in_colin(filing_json, filing_type))
5863
msg.extend(validate_continuation_in_authorization(filing_json, filing_type, legal_type))
5964
msg.extend(_validate_foreign_jurisdiction(filing_json, filing_type, legal_type))

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# noqa: I003
2020
from legal_api.errors import Error
2121
from legal_api.models import Business, ConsentContinuationOut
22+
from legal_api.services import flags
2223
from legal_api.services.filings.validations.common_validations import (
2324
validate_court_order,
2425
validate_foreign_jurisdiction,
@@ -33,6 +34,11 @@ def validate(business: Business, filing: Dict) -> Optional[Error]:
3334
if not business or not filing:
3435
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}])
3536

37+
enabled_filings = flags.value('supported-continuation-out-entities').split()
38+
if enabled_filings and business.legal_type not in enabled_filings:
39+
return Error(HTTPStatus.FORBIDDEN,
40+
[{'error': babel(f'{business.legal_type} does not support continuation out filing.')}])
41+
3642
msg = []
3743
filing_type = 'continuationOut'
3844

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# noqa: I004
2020
from legal_api.errors import Error
2121
from legal_api.models import Business
22+
from legal_api.services import flags
2223
from legal_api.services.filings.validations.common_validations import validate_court_order
2324
from legal_api.services.utils import get_str # noqa: I003; needed as the linter gets confused from the babel override.
2425

@@ -27,6 +28,11 @@ def validate(business: Business, put_back_on: Dict) -> Optional[Error]:
2728
"""Validate the Court Order filing."""
2829
if not business or not put_back_on:
2930
return Error(HTTPStatus.BAD_REQUEST, [{'error': babel('A valid business and filing are required.')}])
31+
32+
enabled_filings = flags.value('supported-put-back-on-entities').split()
33+
if enabled_filings and business.legal_type not in enabled_filings:
34+
return Error(HTTPStatus.FORBIDDEN,
35+
[{'error': babel(f'{business.legal_type} does not support put back on filing.')}])
3036
msg = []
3137

3238
if not get_str(put_back_on, '/filing/putBackOn/details'):

legal-api/tests/unit/resources/v2/test_business_documents.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def test_get_coop_documents_with_correction_and_special_resolution(session, clie
251251
assert info_mem.get('includedInResolutionDate') == '2021-01-01T00:00:00+00:00'
252252

253253

254-
def test_get_business_summary_involuntary_dissolution(requests_mock, session, client, jwt):
254+
def test_get_business_summary_involuntary_dissolution(requests_mock, session, client, jwt, monkeypatch):
255255
"""Assert that business summary returns correct information for Involuntary Dissolution."""
256256
# setup
257257
identifier = 'CP7654321'
@@ -282,6 +282,10 @@ def test_get_business_summary_involuntary_dissolution(requests_mock, session, cl
282282
# create and save the filing
283283
factory_completed_filing(business, INVOLUNTARY_DISSOLUTION, filing_type='dissolution',
284284
filing_sub_type='involuntary')
285+
monkeypatch.setattr(
286+
'legal_api.services.flags.value',
287+
lambda flag: "CP BEN SP GP CBEN BC CC ULC C CCC CUL" if flag == 'enabled-business-summary-entities' else {}
288+
)
285289
# mock the meta_data property
286290
with patch('legal_api.models.Filing.meta_data', new_callable=PropertyMock) as mock_meta_data:
287291
mock_meta_data.return_value = {

0 commit comments

Comments
 (0)