From a96ed5c5339aa88ce9fcca14077980a188cffd3b Mon Sep 17 00:00:00 2001 From: mruff-aeq Date: Tue, 8 Sep 2026 11:44:58 -0400 Subject: [PATCH] 34508-ar-reminder-template --- .../business-emailer/pyproject.toml | 2 +- .../ar_reminder_notification.py | 31 ++++--- .../email_templates/AR-REMINDER.html | 87 ------------------- .../email_templates/AR-REMINDER.md | 33 +++++++ .../resources/business_emailer.py | 5 +- .../test_ar_reminder_notification.py | 47 ++++++++-- .../tests/unit/test_worker.py | 2 +- .../tests/unit/test_worker_dispatch.py | 16 +--- 8 files changed, 97 insertions(+), 126 deletions(-) delete mode 100644 queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.html create mode 100644 queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.md diff --git a/queue_services/business-emailer/pyproject.toml b/queue_services/business-emailer/pyproject.toml index 46e4e8cd9d..6c196b76e2 100644 --- a/queue_services/business-emailer/pyproject.toml +++ b/queue_services/business-emailer/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "business-emailer" -version = "0.1.13" +version = "0.1.14" description = "This module is the service worker for sending emails about entity related events." authors = ["Hrvoje Fekete "] license = "BSD-3-Clause" diff --git a/queue_services/business-emailer/src/business_emailer/email_processors/ar_reminder_notification.py b/queue_services/business-emailer/src/business_emailer/email_processors/ar_reminder_notification.py index ec022a20d8..5385816089 100644 --- a/queue_services/business-emailer/src/business_emailer/email_processors/ar_reminder_notification.py +++ b/queue_services/business-emailer/src/business_emailer/email_processors/ar_reminder_notification.py @@ -20,41 +20,48 @@ from jinja2 import Template from business_emailer.email_processors import get_recipient_from_auth, substitute_template_parts -from business_model.models import Business, CorpType +from business_model.models import Business -def process(email_msg: dict, token: str, flag_on: bool) -> dict: +def process(email_msg: dict, token: str) -> dict: """Build the email for annual report reminder notification.""" current_app.logger.debug("ar_reminder_notification: %s", email_msg) ar_fee = email_msg["arFee"] ar_year = email_msg["arYear"] - # get template and fill in parts - template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/AR-REMINDER.html').read_text() - filled_template = substitute_template_parts(template) business = Business.find_by_internal_id(email_msg["businessId"]) - corp_type = CorpType.find_by_id(business.legal_type) + + # get template and fill in parts + template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/AR-REMINDER.md').read_text(encoding="utf-8") + filled_template = substitute_template_parts(template, "md") + + business_number = None + if len(business.tax_id or "") > 9: # noqa: PLR2004 + # Only show if bn15 is saved, format for ux + business_number = business.tax_id.replace("BC", " BC") # render template with vars jnja_template = Template(filled_template, autoescape=True) - html_out = jnja_template.render( - business=business.json(), + body = jnja_template.render( ar_fee=ar_fee, ar_year=ar_year, - entity_type=corp_type.full_desc, + business_identifier=business.identifier, + business_name=business.legal_name, + business_number=business_number, entity_dashboard_url=current_app.config.get("DASHBOARD_URL") + business.identifier, - disable_specific_service_provider=flag_on + legal_type=business.legal_type, + number_description="Incorporation" ) # get recipients recipients = get_recipient_from_auth(business.identifier, token) - subject = f"{business.legal_name} {ar_year} Annual Report Reminder" + subject = f"{business.legal_name} - Annual Report Reminder" return { "recipients": recipients, "requestBy": "BCRegistries@gov.bc.ca", "content": { "subject": subject, - "body": f"{html_out}", + "body": body, "attachments": [] } } diff --git a/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.html b/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.html deleted file mode 100644 index 9c306903b0..0000000000 --- a/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - Reminder of Annual Report from the Business Registry - [[style.html]] - - - - - - - - - - diff --git a/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.md b/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.md new file mode 100644 index 0000000000..1201b9ebc6 --- /dev/null +++ b/queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.md @@ -0,0 +1,33 @@ +# You can now file your {{ ar_year }} annual report with the BC Business Registry + +[Section 51 of the *Business Corporations Act*](https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/02057_02#section51) requires every BC company to file an annual report within two months of its anniversary date of recognition. The registrar may dissolve a company if the company fails to file for two consecutive years. For more information, please contact BC Registries. + +--- + +[[business-tombstone-basic.md]] + +--- + +## Next Steps + +You have 60 days to file your annual report to keep your business in good standing. + +1. Log onto your [BC Business Registry account]({{ entity_dashboard_url }}). +2. Verify that your business addresses and directors are correct. Ensure that this information is updated before filing your annual report. +3. File your annual report. (The filing fee is ${{ ar_fee }} + $1.50 service fee.) + +--- + +## Additional Resources + +For help with BC Registries filings, you may visit a Service BC location or call 1-877-370-1033. Visit [bcregistry.gov.bc.ca/filing](https://www.bcregistry.gov.bc.ca/filing) for your service options. + +Please note that Service BC does not provide legal or financial advice. + +If you require additional support to file your annual report, contact an accountant, lawyer or service provider of your choice. An additional fee may apply. +{% if legal_type in ['BEN', 'CBEN'] %} +In addition to filing the annual report with the Business Registry, there is a legal requirement for benefit companies to publish an annual Benefit Report. See section 51.994 of the Business Corporations Act for more information on the annual Benefit Report. We recommend seeking legal assistance when creating your annual Benefit Report. +{% endif %} +--- + +[[business-registry-footer.md]] diff --git a/queue_services/business-emailer/src/business_emailer/resources/business_emailer.py b/queue_services/business-emailer/src/business_emailer/resources/business_emailer.py index e15256c444..37781ffec8 100644 --- a/queue_services/business-emailer/src/business_emailer/resources/business_emailer.py +++ b/queue_services/business-emailer/src/business_emailer/resources/business_emailer.py @@ -59,7 +59,7 @@ ) from business_emailer.email_processors.util import FILING_TITLE from business_emailer.exceptions import EmailException, QueueException -from business_emailer.services import flags, gcp_queue, verify_gcp_jwt +from business_emailer.services import gcp_queue, verify_gcp_jwt from business_model.models import Filing, Furnishing, ReviewStatus bp = Blueprint("worker", __name__) @@ -218,8 +218,7 @@ def process_email(ce: SimpleCloudEvent): # pylint: disable=too-many-branches, t email = mras_notification.process(email_msg["email"]) send_email(email, token) elif etype == "annualReport" and option == "reminder": - flag_on = flags.is_on("disable-specific-service-provider") - email = ar_reminder_notification.process(email_msg["email"], token, flag_on) + email = ar_reminder_notification.process(email_msg["email"], token) send_email(email, token) elif etype == "agmLocationChange" and option == Filing.Status.COMPLETED.value: email = agm_location_change_notification.process(email_msg["email"], token) diff --git a/queue_services/business-emailer/tests/unit/email_processors/test_ar_reminder_notification.py b/queue_services/business-emailer/tests/unit/email_processors/test_ar_reminder_notification.py index c504d9e59b..db1e27a74c 100644 --- a/queue_services/business-emailer/tests/unit/email_processors/test_ar_reminder_notification.py +++ b/queue_services/business-emailer/tests/unit/email_processors/test_ar_reminder_notification.py @@ -14,21 +14,27 @@ """The Unit Tests for the annual report reminder email processor.""" from unittest.mock import patch -from business_model.models import Business +import pytest from business_emailer.email_processors import ar_reminder_notification +from business_model.models import Business from tests.unit import prep_incorp_filing -def test_ar_reminder_notification(app, session): +@pytest.mark.parametrize('test_name, legal_type, tax_id, expected_business_number', [ + ('BC_NO_BN', 'BC', None, None), + ('BC_BN9_HIDDEN', 'BC', '123456789', None), + ('BEN_BN15', 'BEN', '85684951BC0001', '85684951 BC0001'), +]) +def test_ar_reminder_notification(app, session, test_name, legal_type, tax_id, expected_business_number): """Assert that the ar reminder notification can be processed.""" # setup filing + business for email filing = prep_incorp_filing(session, 'BC1234567', 'COMPLETED') business = Business.find_by_internal_id(filing.business_id) - business.legal_type = 'BC' + business.legal_type = legal_type business.legal_name = 'test business' + business.tax_id = tax_id token = 'token' - flag_on = False # test processor with patch.object(ar_reminder_notification, 'get_recipient_from_auth', return_value='test@test.com') \ as mock_get_recipient_from_auth: @@ -36,12 +42,37 @@ def test_ar_reminder_notification(app, session): { 'businessId': filing.business_id, 'type': 'annualReport', 'option': 'reminder', - 'arFee': '100', 'arYear': 2021 - }, token, flag_on) - assert email['content']['subject'] == 'test business 2021 Annual Report Reminder' + 'arFee': '43.39', 'arYear': 2021 + }, token) + assert email['content']['subject'] == 'test business - Annual Report Reminder' assert 'test@test.com' in email['recipients'] - assert email['content']['body'] assert email['content']['attachments'] == [] assert mock_get_recipient_from_auth.call_args[0][0] == 'BC1234567' assert mock_get_recipient_from_auth.call_args[0][1] == token + + body = email['content']['body'] + assert body + assert '# You can now file your 2021 annual report with the BC Business Registry' in body + assert '[Section 51 of the *Business Corporations Act*]' \ + '(https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/02057_02#section51)' in body + assert '**Business Name:** test business' in body + assert '**Incorporation Number:** BC1234567' in body + if expected_business_number: + assert f'**Business Number:** {expected_business_number}' in body + else: + assert '**Business Number:**' not in body + assert '## Next Steps' in body + assert 'You have 60 days to file your annual report' in body + assert f'[BC Business Registry account]({app.config.get("DASHBOARD_URL")}BC1234567)' in body + assert 'The filing fee is $43.39 + $1.50 service fee.' in body + assert '## Additional Resources' in body + assert 'Service BC does not provide legal or financial advice' in body + assert 'contact an accountant, lawyer or service provider of your choice' in body + assert 'Dye & Durham' not in body + if legal_type in ['BEN', 'CBEN']: + assert 'annual Benefit Report' in body + else: + assert 'Benefit Report' not in body + assert '**Business Registry**' in body + assert '.md]]' not in body diff --git a/queue_services/business-emailer/tests/unit/test_worker.py b/queue_services/business-emailer/tests/unit/test_worker.py index 2dd3ee6886..6c6ed49ad5 100644 --- a/queue_services/business-emailer/tests/unit/test_worker.py +++ b/queue_services/business-emailer/tests/unit/test_worker.py @@ -296,7 +296,7 @@ def test_process_ar_reminder_email(app, session): ) call_args = mock_send_email.call_args - assert call_args[0][0]['content']['subject'] == 'test business 2021 Annual Report Reminder' + assert call_args[0][0]['content']['subject'] == 'test business - Annual Report Reminder' assert call_args[0][0]['recipients'] == CONTACT_POINT assert call_args[0][0]['content']['body'] assert 'Dye & Durham' not in call_args[0][0]['content']['body'] diff --git a/queue_services/business-emailer/tests/unit/test_worker_dispatch.py b/queue_services/business-emailer/tests/unit/test_worker_dispatch.py index a3d5e8339c..ae18171337 100644 --- a/queue_services/business-emailer/tests/unit/test_worker_dispatch.py +++ b/queue_services/business-emailer/tests/unit/test_worker_dispatch.py @@ -35,7 +35,6 @@ nr_notification, ) from business_emailer.resources import business_emailer as worker -from business_emailer.services import flags STUB_EMAIL = { @@ -163,27 +162,16 @@ def test_mras_dispatch(app, session, mocker, mock_send_email, etype): mock_send_email.assert_called_once_with(STUB_EMAIL, TOKEN) -def test_ar_reminder_dispatch_with_flag_on(app, session, mocker, mock_send_email): - mocker.patch.object(flags, "is_on", return_value=True) +def test_ar_reminder_dispatch(app, session, mocker, mock_send_email): mock_process = mocker.patch.object(ar_reminder_notification, "process", return_value=STUB_EMAIL) email = {"type": "annualReport", "option": "reminder"} worker.process_email(_ce({"email": email})) - mock_process.assert_called_once_with(email, TOKEN, True) + mock_process.assert_called_once_with(email, TOKEN) mock_send_email.assert_called_once_with(STUB_EMAIL, TOKEN) -def test_ar_reminder_dispatch_with_flag_off(app, session, mocker, mock_send_email): - mocker.patch.object(flags, "is_on", return_value=False) - mock_process = mocker.patch.object(ar_reminder_notification, "process", return_value=STUB_EMAIL) - email = {"type": "annualReport", "option": "reminder"} - - worker.process_email(_ce({"email": email})) - - mock_process.assert_called_once_with(email, TOKEN, False) - - def test_agm_location_change_completed_dispatches(app, session, mocker, mock_send_email): mock_process = mocker.patch.object(agm_location_change_notification, "process", return_value=STUB_EMAIL) email = {"type": "agmLocationChange", "option": COMPLETED}