diff --git a/legal-api/src/legal_api/core/filing.py b/legal-api/src/legal_api/core/filing.py index 107edc1404..6fe39b980c 100644 --- a/legal-api/src/legal_api/core/filing.py +++ b/legal-api/src/legal_api/core/filing.py @@ -88,6 +88,19 @@ class FilingTypes(str, Enum): SPECIALRESOLUTION = 'specialResolution' TRANSITION = 'transition' + class FilingTypesCompact(str, Enum): + """Render enum for filing types with sub-types.""" + + DISSOLUTION_VOLUNTARY = 'dissolution.voluntary' + DISSOLUTION_ADMINISTRATIVE = 'dissolution.administrative' + RESTORATION_FULL_RESTORATION = 'restoration.fullRestoration' + RESTORATION_LIMITED_RESTORATION = 'restoration.limitedRestoration' + RESTORATION_LIMITED_RESTORATION_EXT = 'restoration.limitedRestorationExtension' + RESTORATION_LIMITED_RESTORATION_TO_FULL = 'restoration.limitedRestorationToFull' + AMALGAMATION_APPLICATION_REGULAR = 'amalgamationApplication.regular' + AMALGAMATION_APPLICATION_VERTICAL = 'amalgamationApplication.vertical' + AMALGAMATION_APPLICATION_HORIZONTAL = 'amalgamationApplication.horizontal' + def __init__(self): """Create the Filing.""" self._storage: Optional[FilingStorage] = None diff --git a/legal-api/src/legal_api/services/authz.py b/legal-api/src/legal_api/services/authz.py index 3a11c0e88d..7489b3da1c 100644 --- a/legal-api/src/legal_api/services/authz.py +++ b/legal-api/src/legal_api/services/authz.py @@ -15,7 +15,7 @@ from datetime import datetime, timezone from enum import Enum from http import HTTPStatus -from typing import Final, List +from typing import List from urllib.parse import urljoin import jwt as pyjwt @@ -122,304 +122,318 @@ def has_roles(jwt: JwtManager, roles: List[str]) -> bool: return False -ALLOWABLE_FILINGS: Final = { - 'staff': { - Business.State.ACTIVE: { - 'adminFreeze': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'], - }, - 'agmExtension': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] - } - }, - 'agmLocationChange': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] - } - }, - 'alteration': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'amalgamationApplication': { - 'businessRequirement': BusinessRequirement.NO_RESTRICTION, - 'regular': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], +def get_allowable_filings_dict(): + """Return dictionary containing rules for when filings are allowed.""" + # importing here to avoid circular dependencies + # pylint: disable=import-outside-toplevel + from legal_api.core.filing import Filing as CoreFiling + + filing_types_compact = CoreFiling.FilingTypesCompact + + return { + 'staff': { + Business.State.ACTIVE: { + 'adminFreeze': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'], + }, + 'agmExtension': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'vertical': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'agmLocationChange': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'horizontal': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'alteration': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT] } - } - }, - 'annualReport': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'changeOfAddress': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'changeOfDirectors': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'changeOfRegistration': { - 'legalTypes': ['SP', 'GP'], - 'blockerChecks': { - 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'consentContinuationOut': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] - } - }, - 'continuationOut': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], - 'blockerChecks': { - 'business': [BusinessBlocker.NOT_IN_GOOD_STANDING], - 'completedFilings': ['consentContinuationOut'] - } - }, - 'conversion': { - 'legalTypes': ['SP', 'GP'] - }, - 'correction': { - 'legalTypes': ['CP', 'BEN', 'SP', 'GP', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'courtOrder': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] - }, - 'dissolution': { - 'voluntary': { - 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + }, + 'amalgamationApplication': { + 'businessRequirement': BusinessRequirement.NO_RESTRICTION, + 'regular': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + }, + 'vertical': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + }, + 'horizontal': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + } + }, + 'annualReport': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], 'blockerChecks': { - 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] + 'business': [BusinessBlocker.DEFAULT] } }, - 'administrative': { - 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + 'changeOfAddress': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], 'blockerChecks': { - 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], - 'business': [BusinessBlocker.DRAFT_PENDING] + 'business': [BusinessBlocker.DEFAULT] } - } - }, - 'incorporationApplication': { - 'legalTypes': ['CP', 'BC', 'BEN', 'ULC', 'CC'], - # only show filing when providing allowable filings not specific to a business - 'businessRequirement': BusinessRequirement.NOT_EXIST - }, - 'registrarsNotation': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] - }, - 'registrarsOrder': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] - }, - 'registration': { - 'legalTypes': ['SP', 'GP'], - # only show filing when providing allowable filings not specific to a business - 'businessRequirement': BusinessRequirement.NOT_EXIST - }, - 'specialResolution': { - 'legalTypes': ['CP'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'transition': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'] - }, - 'restoration': { - 'limitedRestorationExtension': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + }, + 'changeOfDirectors': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], 'blockerChecks': { - 'validStateFilings': ['restoration.limitedRestoration', - 'restoration.limitedRestorationExtension'], 'business': [BusinessBlocker.DEFAULT] } }, - 'limitedRestorationToFull': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'changeOfRegistration': { + 'legalTypes': ['SP', 'GP'], 'blockerChecks': { - 'validStateFilings': ['restoration.limitedRestoration', - 'restoration.limitedRestorationExtension'], + 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], 'business': [BusinessBlocker.DEFAULT] } - } - } - }, - Business.State.HISTORICAL: { - 'courtOrder': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'], - }, - 'putBackOn': { - 'legalTypes': ['SP', 'GP', 'BEN', 'CP', 'BC', 'CC', 'ULC'], - 'blockerChecks': { - 'validStateFilings': ['dissolution.administrative'] - } - }, - 'registrarsNotation': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] - }, - 'registrarsOrder': { - 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] - }, - 'restoration': { - 'fullRestoration': { + }, + 'consentContinuationOut': { 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], 'blockerChecks': { - 'invalidStateFilings': ['continuationIn', 'continuationOut'] + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'limitedRestoration': { + 'continuationOut': { 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], 'blockerChecks': { - 'invalidStateFilings': ['continuationIn', 'continuationOut'] + 'business': [BusinessBlocker.NOT_IN_GOOD_STANDING], + 'completedFilings': ['consentContinuationOut'] + } + }, + 'conversion': { + 'legalTypes': ['SP', 'GP'] + }, + 'correction': { + 'legalTypes': ['CP', 'BEN', 'SP', 'GP', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'courtOrder': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] + }, + 'dissolution': { + 'voluntary': { + 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + 'blockerChecks': { + 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] + } + }, + 'administrative': { + 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + 'blockerChecks': { + 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], + 'business': [BusinessBlocker.DRAFT_PENDING] + } + } + }, + 'incorporationApplication': { + 'legalTypes': ['CP', 'BC', 'BEN', 'ULC', 'CC'], + # only show filing when providing allowable filings not specific to a business + 'businessRequirement': BusinessRequirement.NOT_EXIST + }, + 'registrarsNotation': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] + }, + 'registrarsOrder': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] + }, + 'registration': { + 'legalTypes': ['SP', 'GP'], + # only show filing when providing allowable filings not specific to a business + 'businessRequirement': BusinessRequirement.NOT_EXIST + }, + 'specialResolution': { + 'legalTypes': ['CP'], + 'blockerChecks': { + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'transition': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'] + }, + 'restoration': { + 'limitedRestorationExtension': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'blockerChecks': { + 'validStateFilings': [filing_types_compact.RESTORATION_LIMITED_RESTORATION, + filing_types_compact.RESTORATION_LIMITED_RESTORATION_EXT], + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'limitedRestorationToFull': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'blockerChecks': { + 'validStateFilings': [filing_types_compact.RESTORATION_LIMITED_RESTORATION, + filing_types_compact.RESTORATION_LIMITED_RESTORATION_EXT], + 'business': [BusinessBlocker.DEFAULT] + } } - } - } - } - }, - 'general': { - Business.State.ACTIVE: { - 'agmExtension': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] - } - }, - 'agmLocationChange': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'alteration': { - 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] + Business.State.HISTORICAL: { + 'courtOrder': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'], + }, + 'putBackOn': { + 'legalTypes': ['SP', 'GP', 'BEN', 'CP', 'BC', 'CC', 'ULC'], + 'blockerChecks': { + 'validStateFilings': [filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + }, + 'registrarsNotation': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] + }, + 'registrarsOrder': { + 'legalTypes': ['SP', 'GP', 'CP', 'BC', 'BEN', 'CC', 'ULC'] + }, + 'restoration': { + 'fullRestoration': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'blockerChecks': { + 'invalidStateFilings': ['continuationIn', 'continuationOut'] + } + }, + 'limitedRestoration': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'blockerChecks': { + 'invalidStateFilings': ['continuationIn', 'continuationOut'] + } + } } - }, - 'amalgamationApplication': { - 'businessRequirement': BusinessRequirement.NO_RESTRICTION, - 'regular': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + } + }, + 'general': { + Business.State.ACTIVE: { + 'agmExtension': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'vertical': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'agmLocationChange': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - 'horizontal': { - 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'alteration': { + 'legalTypes': ['BC', 'BEN', 'ULC', 'CC'], 'blockerChecks': { - 'business': [BusinessBlocker.BUSINESS_FROZEN], - 'futureEffectiveFilings': ['dissolution'] + 'business': [BusinessBlocker.DEFAULT] } - } - }, - 'annualReport': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'changeOfAddress': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT], - } - }, - 'changeOfDirectors': { - 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'changeOfRegistration': { - 'legalTypes': ['SP', 'GP'], - 'blockerChecks': { - 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], - 'business': [BusinessBlocker.DEFAULT] - } - }, - 'consentContinuationOut': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] - } - }, - 'dissolution': { - 'voluntary': { - 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + }, + 'amalgamationApplication': { + 'businessRequirement': BusinessRequirement.NO_RESTRICTION, + 'regular': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + }, + 'vertical': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + }, + 'horizontal': { + 'legalTypes': ['BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.BUSINESS_FROZEN], + 'futureEffectiveFilings': [filing_types_compact.DISSOLUTION_VOLUNTARY, + filing_types_compact.DISSOLUTION_ADMINISTRATIVE] + } + } + }, + 'annualReport': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'changeOfAddress': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.DEFAULT], + } + }, + 'changeOfDirectors': { + 'legalTypes': ['CP', 'BEN', 'BC', 'ULC', 'CC'], + 'blockerChecks': { + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'changeOfRegistration': { + 'legalTypes': ['SP', 'GP'], 'blockerChecks': { 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'consentContinuationOut': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'], + 'blockerChecks': { 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] } }, - }, - 'incorporationApplication': { - 'legalTypes': ['CP', 'BC', 'BEN', 'ULC', 'CC'], - # only show filing when providing allowable filings not specific to a business - 'businessRequirement': BusinessRequirement.NOT_EXIST - }, - 'registration': { - 'legalTypes': ['SP', 'GP'], - # only show filing when providing allowable filings not specific to a business - 'businessRequirement': BusinessRequirement.NOT_EXIST - }, - 'specialResolution': { - 'legalTypes': ['CP'], - 'blockerChecks': { - 'business': [BusinessBlocker.DEFAULT] + 'dissolution': { + 'voluntary': { + 'legalTypes': ['CP', 'BC', 'BEN', 'CC', 'ULC', 'SP', 'GP'], + 'blockerChecks': { + 'warningTypes': [WarningType.MISSING_REQUIRED_BUSINESS_INFO], + 'business': [BusinessBlocker.DEFAULT, BusinessBlocker.NOT_IN_GOOD_STANDING] + } + }, + }, + 'incorporationApplication': { + 'legalTypes': ['CP', 'BC', 'BEN', 'ULC', 'CC'], + # only show filing when providing allowable filings not specific to a business + 'businessRequirement': BusinessRequirement.NOT_EXIST + }, + 'registration': { + 'legalTypes': ['SP', 'GP'], + # only show filing when providing allowable filings not specific to a business + 'businessRequirement': BusinessRequirement.NOT_EXIST + }, + 'specialResolution': { + 'legalTypes': ['CP'], + 'blockerChecks': { + 'business': [BusinessBlocker.DEFAULT] + } + }, + 'transition': { + 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'] } }, - 'transition': { - 'legalTypes': ['BC', 'BEN', 'CC', 'ULC'] - } - }, - Business.State.HISTORICAL: {} + Business.State.HISTORICAL: {} + } } -} # pylint: disable=(too-many-arguments,too-many-locals @@ -483,7 +497,7 @@ def get_allowed_filings(business: Business, # doing this check up front to cache result business_blocker_dict: dict = business_blocker_check(business, is_ignore_draft_blockers) - allowable_filings = ALLOWABLE_FILINGS.get(user_role, {}).get(state, {}) + allowable_filings = get_allowable_filings_dict().get(user_role, {}).get(state, {}) allowable_filing_types = [] for allowable_filing_key, allowable_filing_value in allowable_filings.items(): @@ -669,7 +683,7 @@ def has_blocker_future_effective_filing(business: Business, blocker_checks: dict pending_filings = Filing.get_filings_by_type_pairs(business.id, filing_type_pairs, - [Filing.Status.PENDING.value], + [Filing.Status.PENDING.value, Filing.Status.PAID.value], True) now = datetime.utcnow().replace(tzinfo=timezone.utc) @@ -722,7 +736,7 @@ def get_allowed(state: Business.State, legal_type: str, jwt: JwtManager): if jwt.contains_role([STAFF_ROLE, SYSTEM_ROLE, COLIN_SVC_ROLE]): user_role = 'staff' - allowable_filings = ALLOWABLE_FILINGS.get(user_role, {}).get(state, {}) + allowable_filings = get_allowable_filings_dict().get(user_role, {}).get(state, {}) allowable_filing_types = [] for allowable_filing_key, allowable_filing_value in allowable_filings.items(): if legal_types := allowable_filing_value.get('legalTypes', None): diff --git a/legal-api/tests/unit/services/test_authorization.py b/legal-api/tests/unit/services/test_authorization.py index a6cb6c9c36..4999b5c147 100644 --- a/legal-api/tests/unit/services/test_authorization.py +++ b/legal-api/tests/unit/services/test_authorization.py @@ -213,6 +213,7 @@ class FilingKey(str, Enum): BLOCKER_FILING_STATUSES = factory_incomplete_statuses() BLOCKER_FILING_STATUSES_AND_ADDITIONAL = factory_incomplete_statuses(['unknown_status_1', 'unknown_status_2']) +BLOCKER_DISSOLUTION_STATUSES_FOR_AMALG = [Filing.Status.PENDING.value, Filing.Status.PAID.value] BLOCKER_FILING_TYPES = ['alteration', 'correction'] AGM_EXTENSION_FILING_TEMPLATE = copy.deepcopy(FILING_TEMPLATE) @@ -1467,7 +1468,7 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me [ # active business - staff user ('staff_active_corps', Business.State.ACTIVE, ['BC', 'BEN', 'CC', 'ULC'], 'staff', [STAFF_ROLE], - ['dissolution'], [Filing.Status.PENDING.value], True, + ['dissolution.voluntary', 'dissolution.administrative'], BLOCKER_DISSOLUTION_STATUSES_FOR_AMALG, True, expected_lookup([FilingKey.ADMN_FRZE, FilingKey.COURT_ORDER, FilingKey.REGISTRARS_NOTATION, @@ -1476,13 +1477,13 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me # active business - general user ('general_user_corps', Business.State.ACTIVE, ['BC', 'BEN', 'CC', 'ULC'], 'general', [BASIC_USER], - ['dissolution'], [Filing.Status.PENDING.value], True, expected_lookup([FilingKey.TRANSITION])) + ['dissolution.voluntary', 'dissolution.administrative'], BLOCKER_DISSOLUTION_STATUSES_FOR_AMALG, True, + expected_lookup([FilingKey.TRANSITION])) ] ) def test_allowed_filings_blocker_filing_amalgamations(monkeypatch, app, session, jwt, test_name, state, - legal_types, username, roles, filing_types, filing_statuses, - is_fed, - expected): + legal_types, username, roles, filing_types, filing_statuses, + is_fed, expected): """Assert that get allowed returns valid filings when amalgamating business has blocker filings. A blocker filing in this instance is a pending future effective dissolution filing. @@ -1498,7 +1499,8 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me for legal_type in legal_types: for filing_status in filing_statuses: - for filing_type in filing_types: + for filing in filing_types: + filing_type, filing_sub_type = filing.split('.') business = create_business(legal_type, state) filing_dict = FILING_DATA.get(filing_type, None) create_incomplete_filing(business=business, @@ -1506,6 +1508,7 @@ def mock_auth(one, two): # pylint: disable=unused-argument; mocks of library me filing_status=filing_status, filing_dict=filing_dict, filing_type=filing_type, + filing_sub_type=filing_sub_type, is_future_effective=is_fed) allowed_filing_types = get_allowed_filings(business, state, legal_type, jwt) assert allowed_filing_types == expected