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

Skip to content

Commit 039df64

Browse files
authored
34821 Suppress Annual Report filing todos for mainframe entities (#4763)
* 34821 Suppress Annual Report filing todos for mainframe entities * comment
1 parent 957e0bc commit 039df64

2 files changed

Lines changed: 47 additions & 3 deletions

File tree

legal-api/src/legal_api/resources/v2/business/business_tasks.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ def construct_task_list(business: Business): # noqa: PLR0915
9797
9898
- Corporations must file one AR per year, on or after the anniversary of the founding date
9999
"""
100-
entity_types_no_ar = ["SP", "GP"]
100+
# Legal types that never get AR todos. SP/GP don't file annual reports at all. The rest are
101+
# legacy/mainframe migrated legal types where annualReport filing is disabled/greyed out in the
102+
# UI - some of these were founded decades ago (for example,1940s), so without this exclusion they'd
103+
# generate a large backlog of AR todos that can never actually be filed.
104+
entity_types_no_ar = [
105+
"SP", "GP",
106+
"RLY", # Railways
107+
"LIB", # Public Library Association
108+
"CEM", # Cemetery
109+
"TMY", # Tramways
110+
"PFS", # Pension Funded Society
111+
"SB", # Society Branch
112+
]
101113
tasks = []
102114
order = 1
103115

@@ -151,8 +163,8 @@ def construct_task_list(business: Business): # noqa: PLR0915
151163
tasks.append(task)
152164
order += 1
153165

154-
# Skip AR todos when founding date is the COLIN year 0001 (for legacy data like railways). Without this,
155-
# a sentinel founding_date of 0001-01-01 generates ~2000 AR todos and a multi-MB /tasks payload.
166+
# Also skip AR todos when founding date is the COLIN year-1 sentinel/unknown - without this, a
167+
# sentinel founding_date of 0001-01-01 generates ~2000 AR todos and a multi-MB /tasks payload.
156168
unknown_founding_date = (
157169
not business.founding_date or business.founding_date.year <= 1
158170
)

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,38 @@ def test_get_tasks_sentinel_founding_date_skips_ar(session, client, jwt):
116116
assert len(ar_tasks) == 0
117117

118118

119+
@pytest.mark.parametrize('test_name, legal_type', [
120+
('railways', Business.LegalTypes.RAILWAYS.value),
121+
('library', Business.LegalTypes.LIBRARY.value),
122+
('cemetery', Business.LegalTypes.CEMETARY.value),
123+
('tramways', Business.LegalTypes.TRAMWAYS.value),
124+
('pension_funded_society', Business.LegalTypes.PENS_FUND_SOC.value),
125+
('society_branch', Business.LegalTypes.SOCIETY_BRANCH.value),
126+
])
127+
def test_get_tasks_legacy_migrated_types_no_ar(session, client, jwt, test_name, legal_type):
128+
"""Assert legacy/mainframe-migrated legal types never get AR todos, even with a real old founding date.
129+
130+
These legal types don't support annualReport filing (see ANNUAL_REPORT_LEGAL_TYPES in authz.py), so
131+
filing is greyed out in the UI regardless. Businesses founded decades ago (e.g. 1940) should not
132+
generate a huge backlog of AR todos that can never actually be filed.
133+
"""
134+
identifier = 'BC1234567'
135+
factory_business(
136+
identifier,
137+
founding_date=datetime(1940, 1, 1, tzinfo=UTC),
138+
entity_type=legal_type,
139+
state=Business.State.ACTIVE,
140+
)
141+
142+
rv = client.get(f'/api/v2/businesses/{identifier}/tasks', headers=create_header(jwt, [STAFF_ROLE], identifier))
143+
assert rv.status_code == HTTPStatus.OK
144+
ar_tasks = [
145+
t for t in rv.json.get('tasks')
146+
if t.get('task', {}).get('todo', {}).get('header', {}).get('name') == 'annualReport'
147+
]
148+
assert len(ar_tasks) == 0
149+
150+
119151
def test_get_tasks_next_year(session, client, jwt):
120152
"""Assert that one todo item is returned in the calendar year following incorporation."""
121153
identifier = 'CP7654321'

0 commit comments

Comments
 (0)