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 queue_services/business-emailer/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <hrvoje.fekete@mindpoweredtech.com>"]
license = "BSD-3-Clause"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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]]
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,65 @@
"""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:
email = ar_reminder_notification.process(
{
'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
2 changes: 1 addition & 1 deletion queue_services/business-emailer/tests/unit/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
16 changes: 2 additions & 14 deletions queue_services/business-emailer/tests/unit/test_worker_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
nr_notification,
)
from business_emailer.resources import business_emailer as worker
from business_emailer.services import flags


STUB_EMAIL = {
Expand Down Expand Up @@ -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}
Expand Down
Loading