From 0b75138e01c27bbdcadfb6082adef570c68ea5a8 Mon Sep 17 00:00:00 2001 From: meawong Date: Thu, 3 Dec 2026 16:41:17 -0700 Subject: [PATCH] 35736 - Add arDueDate to tasks response --- legal-api/poetry.lock | 4 +- legal-api/pyproject.toml | 2 +- .../resources/v2/business/business_tasks.py | 11 ++++-- .../unit/resources/v2/test_business_tasks.py | 39 +++++++++++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/legal-api/poetry.lock b/legal-api/poetry.lock index 86628eeb97..4aed281dc7 100644 --- a/legal-api/poetry.lock +++ b/legal-api/poetry.lock @@ -316,7 +316,7 @@ files = [ [[package]] name = "business-model" -version = "3.4.32" +version = "3.4.33" description = "" optional = false python-versions = ">=3.13,<3.14" @@ -343,7 +343,7 @@ sql-versioning = {git = "https://github.com/bcgov/lear.git", rev = "main", subdi type = "git" url = "https://github.com/bcgov/lear.git" reference = "main" -resolved_reference = "9a98d029df260eab2906c89e79780905e6214ab2" +resolved_reference = "5a0bd798e3369f9e552b43a492090a6a34473728" subdirectory = "python/common/business-registry-model" [[package]] diff --git a/legal-api/pyproject.toml b/legal-api/pyproject.toml index b77b830f4b..26cf893a40 100644 --- a/legal-api/pyproject.toml +++ b/legal-api/pyproject.toml @@ -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"} diff --git a/legal-api/src/legal_api/resources/v2/business/business_tasks.py b/legal-api/src/legal_api/resources/v2/business/business_tasks.py index 0a9d5eda20..3d227ad079 100644 --- a/legal-api/src/legal_api/resources/v2/business/business_tasks.py +++ b/legal-api/src/legal_api/resources/v2/business/business_tasks.py @@ -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 @@ -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": { @@ -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() } } }, diff --git a/legal-api/tests/unit/resources/v2/test_business_tasks.py b/legal-api/tests/unit/resources/v2/test_business_tasks.py index 4b4e561e3e..52d39f7230 100644 --- a/legal-api/tests/unit/resources/v2/test_business_tasks.py +++ b/legal-api/tests/unit/resources/v2/test_business_tasks.py @@ -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}]),