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
2 changes: 1 addition & 1 deletion python/common/business-registry-model/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "business-model"
version = "3.4.32"
version = "3.4.33"
description = ""
authors = [
{name = "thor",email = "1042854+thorwolpert@users.noreply.github.com"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ def next_lr_min_date(self) -> datetime | None:
years_to_add = next_lr_year - founding_date.year
return founding_date + datedelta.datedelta(years=years_to_add)

def get_ar_dates(self, next_ar_year):
"""Get ar min and max date for the specific year."""
def _get_ar_date_values(self, next_ar_year):
"""Get ar min date and uncapped max date for the specific year."""
ar_min_date = datetime(next_ar_year, 1, 1).date()
ar_max_date = datetime(next_ar_year, 12, 31).date()
covid_year = 2020
Expand All @@ -492,10 +492,22 @@ def get_ar_dates(self, next_ar_year):

ar_max_date = ar_min_date + datedelta.datedelta(days=60)

return ar_min_date, ar_max_date

def get_ar_dates(self, next_ar_year):
"""Get ar min and max date for the specific year."""
ar_min_date, ar_max_date = self._get_ar_date_values(next_ar_year)

ar_max_date = min(ar_max_date, LegislationDatetime.datenow()) # ar_max_date cannot be in future

return ar_min_date, ar_max_date

def get_ar_due_date(self, next_ar_year):
"""Get the uncapped annual report due date for the specific year."""
_, ar_due_date = self._get_ar_date_values(next_ar_year)

return ar_due_date

@property
def mailing_address(self):
"""Return the mailing address."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,70 @@ def test_next_lr_min_date(session, test_name, founding_date, in_liquidation_date

assert business.next_lr_min_date == expected_lr_min_date


@pytest.mark.parametrize(
'legal_type, founding_date, next_ar_year, expected_min_date, expected_due_date',
[
(
Business.LegalTypes.COMP.value,
datetime(2025, 11, 22, 12, 0, tzinfo=UTC),
2026,
date(2026, 11, 22),
date(2027, 1, 21),
),
(
Business.LegalTypes.COOP.value,
datetime(2020, 1, 1, tzinfo=UTC),
2026,
date(2026, 1, 1),
date(2027, 4, 30),
),
(
Business.LegalTypes.COOP.value,
datetime(2019, 1, 1, tzinfo=UTC),
2020,
date(2020, 1, 1),
date(2021, 10, 31),
),
(
Business.LegalTypes.SOLE_PROP.value,
datetime(2020, 1, 1, tzinfo=UTC),
2026,
date(2026, 1, 1),
date(2026, 12, 31),
),
],
)
def test_get_ar_due_date(
legal_type, founding_date, next_ar_year, expected_min_date, expected_due_date
):
"""Assert that the uncapped annual report due date is calculated correctly."""
business = Business(
legal_type=legal_type,
founding_date=founding_date,
)

assert business.get_ar_due_date(next_ar_year) == expected_due_date

ar_min_date, _ = business.get_ar_dates(next_ar_year)
assert ar_min_date == expected_min_date


def test_get_ar_dates_caps_max_date_at_today(monkeypatch):
"""Assert that get_ar_dates continues to cap the maximum date at today."""
today = date(2026, 12, 2)
monkeypatch.setattr(LegislationDatetime, 'datenow', lambda: today)

business = Business(
legal_type=Business.LegalTypes.COMP.value,
founding_date=datetime(2025, 11, 22, 12, 0, tzinfo=UTC),
)

ar_min_date, ar_max_date = business.get_ar_dates(2026)

assert ar_min_date == date(2026, 11, 22)
assert ar_max_date == today

# The actual due date should remain uncapped.
assert business.get_ar_due_date(2026) == date(2027, 1, 21)