Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions legal-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion legal-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "legal-api"
version = "3.1.83"
version = "3.1.84"
description = ""
authors = [
{name = "thor",email = "1042854+thorwolpert@users.noreply.github.com"}
Expand Down
11 changes: 8 additions & 3 deletions legal-api/src/legal_api/resources/v2/business/business_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,19 @@ def _add_ar_tasks(business: Business, tasks: list, order: int, pending_filings:
next_ar_year += len(annual_report_filings)

ar_min_date, ar_max_date = business.get_ar_dates(next_ar_year)
ar_due_date = business.get_ar_due_date(next_ar_year)

start_year = next_ar_year
while next_ar_year <= datetime.now(UTC).year and ar_min_date <= datetime.now(UTC).date():
enabled = not pending_filings and ar_min_date.year == start_year
tasks.append(create_todo(business, next_ar_year, ar_min_date, ar_max_date, order, enabled))
tasks.append(create_todo(
business, next_ar_year, ar_min_date, ar_max_date, ar_due_date, order, enabled
))

# Include all ar's to todo from last ar filing
next_ar_year += 1
ar_min_date, ar_max_date = business.get_ar_dates(next_ar_year)
ar_due_date = business.get_ar_due_date(next_ar_year)
order += 1

return tasks, order
Expand Down Expand Up @@ -469,7 +473,7 @@ def _add_tr_task(tasks: list, order: int, enabled: bool, # noqa: PLR0913
return tasks, order


def create_todo(business, ar_year, ar_min_date, ar_max_date, order, enabled): # noqa: PLR0913
def create_todo(business, ar_year, ar_min_date, ar_max_date, ar_due_date, order, enabled): # noqa: PLR0913
"""Return a to-do JSON object."""
todo = {
"task": {
Expand All @@ -480,7 +484,8 @@ def create_todo(business, ar_year, ar_min_date, ar_max_date, order, enabled): #
"ARFilingYear": ar_year,
"status": "NEW",
"arMinDate": ar_min_date.isoformat(),
"arMaxDate": ar_max_date.isoformat()
"arMaxDate": ar_max_date.isoformat(),
"arDueDate": ar_due_date.isoformat()
}
}
},
Expand Down
39 changes: 39 additions & 0 deletions legal-api/tests/unit/resources/v2/test_business_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,45 @@ def test_construct_task_list_ar(session, client, jwt, test_name, identifier, fou
assert tasks[0]['task']['todo']['business']['nextAnnualReport'][-14:] != '00:00:00+00:00'


@freeze_time('2026-12-02')
def test_get_tasks_includes_uncapped_ar_due_date(session, client, jwt):
"""Assert the AR todo includes the actual due date separately from the capped maximum date."""
identifier = 'BC1234567'
business = factory_business(
identifier,
founding_date=datetime(2025, 11, 22, 12, 0, tzinfo=UTC),
entity_type=Business.LegalTypes.COMP.value,
state=Business.State.ACTIVE,
)
factory_business_office(business, 'registeredOffice')
factory_business_office(business, 'recordsOffice')

with patch(
'business_model.models.business.LegislationDatetime.datenow',
return_value=datetime(2026, 12, 2).date(),
):
rv = client.get(
f'/api/v2/businesses/{identifier}/tasks',
headers=create_header(jwt, [STAFF_ROLE], identifier),
)

assert rv.status_code == HTTPStatus.OK

ar_tasks = [
task for task in rv.json['tasks']
if task.get('task', {}).get('todo', {}).get('header', {}).get('name') == 'annualReport'
]

assert len(ar_tasks) == 1

header = ar_tasks[0]['task']['todo']['header']

assert header['ARFilingYear'] == 2026
assert header['arMinDate'] == '2026-11-22'
assert header['arMaxDate'] == '2026-12-02'
assert header['arDueDate'] == '2027-01-21'


@pytest.mark.parametrize('test_name, identifier, legal_type, founding_date, last_ar_date, restored_date, incomplete_filing_type, expected', [
('TA_ONLY', 'BC1234567', Business.LegalTypes.COMP.value, datetime(1999, 7, 2, 8), datetime(2025, 7, 2, 8), datetime(2025, 9, 1), None, [{'order': 1, 'name': 'transition', 'enabled': True}]),
('TA_1_AR_2', 'BC1234567', Business.LegalTypes.BCOMP.value, datetime(1999, 7, 2, 8), datetime(2024, 7, 2, 8), datetime(2024, 6, 1), None, [{'order': 1, 'name': 'transition', 'enabled': True}, {'order': 2, 'name': 'annualReport', 'ARFilingYear': 2025, 'enabled': True}]),
Expand Down