Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0037746

Browse files
authored
Merge pull request #4764 from mruff-aeq/34508-ar-reminder-template
34508 - AR reminder template changes
2 parents 9d01165 + a96ed5c commit 0037746

8 files changed

Lines changed: 97 additions & 126 deletions

File tree

queue_services/business-emailer/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "business-emailer"
3-
version = "0.1.13"
3+
version = "0.1.14"
44
description = "This module is the service worker for sending emails about entity related events."
55
authors = ["Hrvoje Fekete <[email protected]>"]
66
license = "BSD-3-Clause"

queue_services/business-emailer/src/business_emailer/email_processors/ar_reminder_notification.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,48 @@
2020
from jinja2 import Template
2121

2222
from business_emailer.email_processors import get_recipient_from_auth, substitute_template_parts
23-
from business_model.models import Business, CorpType
23+
from business_model.models import Business
2424

2525

26-
def process(email_msg: dict, token: str, flag_on: bool) -> dict:
26+
def process(email_msg: dict, token: str) -> dict:
2727
"""Build the email for annual report reminder notification."""
2828
current_app.logger.debug("ar_reminder_notification: %s", email_msg)
2929
ar_fee = email_msg["arFee"]
3030
ar_year = email_msg["arYear"]
31-
# get template and fill in parts
32-
template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/AR-REMINDER.html').read_text()
33-
filled_template = substitute_template_parts(template)
3431
business = Business.find_by_internal_id(email_msg["businessId"])
35-
corp_type = CorpType.find_by_id(business.legal_type)
32+
33+
# get template and fill in parts
34+
template = Path(f'{current_app.config.get("TEMPLATE_PATH")}/AR-REMINDER.md').read_text(encoding="utf-8")
35+
filled_template = substitute_template_parts(template, "md")
36+
37+
business_number = None
38+
if len(business.tax_id or "") > 9: # noqa: PLR2004
39+
# Only show if bn15 is saved, format for ux
40+
business_number = business.tax_id.replace("BC", " BC")
3641

3742
# render template with vars
3843
jnja_template = Template(filled_template, autoescape=True)
39-
html_out = jnja_template.render(
40-
business=business.json(),
44+
body = jnja_template.render(
4145
ar_fee=ar_fee,
4246
ar_year=ar_year,
43-
entity_type=corp_type.full_desc,
47+
business_identifier=business.identifier,
48+
business_name=business.legal_name,
49+
business_number=business_number,
4450
entity_dashboard_url=current_app.config.get("DASHBOARD_URL") + business.identifier,
45-
disable_specific_service_provider=flag_on
51+
legal_type=business.legal_type,
52+
number_description="Incorporation"
4653
)
4754

4855
# get recipients
4956
recipients = get_recipient_from_auth(business.identifier, token)
50-
subject = f"{business.legal_name} {ar_year} Annual Report Reminder"
57+
subject = f"{business.legal_name} - Annual Report Reminder"
5158

5259
return {
5360
"recipients": recipients,
5461
"requestBy": "[email protected]",
5562
"content": {
5663
"subject": subject,
57-
"body": f"{html_out}",
64+
"body": body,
5865
"attachments": []
5966
}
6067
}

queue_services/business-emailer/src/business_emailer/email_templates/AR-REMINDER.html

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# You can now file your {{ ar_year }} annual report with the BC Business Registry
2+
3+
[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.
4+
5+
---
6+
7+
[[business-tombstone-basic.md]]
8+
9+
---
10+
11+
## Next Steps
12+
13+
You have 60 days to file your annual report to keep your business in good standing.
14+
15+
1. Log onto your [BC Business Registry account]({{ entity_dashboard_url }}).
16+
2. Verify that your business addresses and directors are correct. Ensure that this information is updated before filing your annual report.
17+
3. File your annual report. (The filing fee is ${{ ar_fee }} + $1.50 service fee.)
18+
19+
---
20+
21+
## Additional Resources
22+
23+
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.
24+
25+
Please note that Service BC does not provide legal or financial advice.
26+
27+
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.
28+
{% if legal_type in ['BEN', 'CBEN'] %}
29+
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.
30+
{% endif %}
31+
---
32+
33+
[[business-registry-footer.md]]

queue_services/business-emailer/src/business_emailer/resources/business_emailer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
)
6060
from business_emailer.email_processors.util import FILING_TITLE
6161
from business_emailer.exceptions import EmailException, QueueException
62-
from business_emailer.services import flags, gcp_queue, verify_gcp_jwt
62+
from business_emailer.services import gcp_queue, verify_gcp_jwt
6363
from business_model.models import Filing, Furnishing, ReviewStatus
6464

6565
bp = Blueprint("worker", __name__)
@@ -218,8 +218,7 @@ def process_email(ce: SimpleCloudEvent): # pylint: disable=too-many-branches, t
218218
email = mras_notification.process(email_msg["email"])
219219
send_email(email, token)
220220
elif etype == "annualReport" and option == "reminder":
221-
flag_on = flags.is_on("disable-specific-service-provider")
222-
email = ar_reminder_notification.process(email_msg["email"], token, flag_on)
221+
email = ar_reminder_notification.process(email_msg["email"], token)
223222
send_email(email, token)
224223
elif etype == "agmLocationChange" and option == Filing.Status.COMPLETED.value:
225224
email = agm_location_change_notification.process(email_msg["email"], token)

queue_services/business-emailer/tests/unit/email_processors/test_ar_reminder_notification.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,65 @@
1414
"""The Unit Tests for the annual report reminder email processor."""
1515
from unittest.mock import patch
1616

17-
from business_model.models import Business
17+
import pytest
1818

1919
from business_emailer.email_processors import ar_reminder_notification
20+
from business_model.models import Business
2021
from tests.unit import prep_incorp_filing
2122

2223

23-
def test_ar_reminder_notification(app, session):
24+
@pytest.mark.parametrize('test_name, legal_type, tax_id, expected_business_number', [
25+
('BC_NO_BN', 'BC', None, None),
26+
('BC_BN9_HIDDEN', 'BC', '123456789', None),
27+
('BEN_BN15', 'BEN', '85684951BC0001', '85684951 BC0001'),
28+
])
29+
def test_ar_reminder_notification(app, session, test_name, legal_type, tax_id, expected_business_number):
2430
"""Assert that the ar reminder notification can be processed."""
2531
# setup filing + business for email
2632
filing = prep_incorp_filing(session, 'BC1234567', 'COMPLETED')
2733
business = Business.find_by_internal_id(filing.business_id)
28-
business.legal_type = 'BC'
34+
business.legal_type = legal_type
2935
business.legal_name = 'test business'
36+
business.tax_id = tax_id
3037
token = 'token'
31-
flag_on = False
3238
# test processor
3339
with patch.object(ar_reminder_notification, 'get_recipient_from_auth', return_value='[email protected]') \
3440
as mock_get_recipient_from_auth:
3541
email = ar_reminder_notification.process(
3642
{
3743
'businessId': filing.business_id,
3844
'type': 'annualReport', 'option': 'reminder',
39-
'arFee': '100', 'arYear': 2021
40-
}, token, flag_on)
41-
assert email['content']['subject'] == 'test business 2021 Annual Report Reminder'
45+
'arFee': '43.39', 'arYear': 2021
46+
}, token)
47+
assert email['content']['subject'] == 'test business - Annual Report Reminder'
4248

4349
assert '[email protected]' in email['recipients']
44-
assert email['content']['body']
4550
assert email['content']['attachments'] == []
4651
assert mock_get_recipient_from_auth.call_args[0][0] == 'BC1234567'
4752
assert mock_get_recipient_from_auth.call_args[0][1] == token
53+
54+
body = email['content']['body']
55+
assert body
56+
assert '# You can now file your 2021 annual report with the BC Business Registry' in body
57+
assert '[Section 51 of the *Business Corporations Act*]' \
58+
'(https://www.bclaws.gov.bc.ca/civix/document/id/complete/statreg/02057_02#section51)' in body
59+
assert '**Business Name:** test business' in body
60+
assert '**Incorporation Number:** BC1234567' in body
61+
if expected_business_number:
62+
assert f'**Business Number:** {expected_business_number}' in body
63+
else:
64+
assert '**Business Number:**' not in body
65+
assert '## Next Steps' in body
66+
assert 'You have 60 days to file your annual report' in body
67+
assert f'[BC Business Registry account]({app.config.get("DASHBOARD_URL")}BC1234567)' in body
68+
assert 'The filing fee is $43.39 + $1.50 service fee.' in body
69+
assert '## Additional Resources' in body
70+
assert 'Service BC does not provide legal or financial advice' in body
71+
assert 'contact an accountant, lawyer or service provider of your choice' in body
72+
assert 'Dye & Durham' not in body
73+
if legal_type in ['BEN', 'CBEN']:
74+
assert 'annual Benefit Report' in body
75+
else:
76+
assert 'Benefit Report' not in body
77+
assert '**Business Registry**' in body
78+
assert '.md]]' not in body

queue_services/business-emailer/tests/unit/test_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def test_process_ar_reminder_email(app, session):
296296
)
297297

298298
call_args = mock_send_email.call_args
299-
assert call_args[0][0]['content']['subject'] == 'test business 2021 Annual Report Reminder'
299+
assert call_args[0][0]['content']['subject'] == 'test business - Annual Report Reminder'
300300
assert call_args[0][0]['recipients'] == CONTACT_POINT
301301
assert call_args[0][0]['content']['body']
302302
assert 'Dye & Durham' not in call_args[0][0]['content']['body']

queue_services/business-emailer/tests/unit/test_worker_dispatch.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
nr_notification,
3636
)
3737
from business_emailer.resources import business_emailer as worker
38-
from business_emailer.services import flags
3938

4039

4140
STUB_EMAIL = {
@@ -163,27 +162,16 @@ def test_mras_dispatch(app, session, mocker, mock_send_email, etype):
163162
mock_send_email.assert_called_once_with(STUB_EMAIL, TOKEN)
164163

165164

166-
def test_ar_reminder_dispatch_with_flag_on(app, session, mocker, mock_send_email):
167-
mocker.patch.object(flags, "is_on", return_value=True)
165+
def test_ar_reminder_dispatch(app, session, mocker, mock_send_email):
168166
mock_process = mocker.patch.object(ar_reminder_notification, "process", return_value=STUB_EMAIL)
169167
email = {"type": "annualReport", "option": "reminder"}
170168

171169
worker.process_email(_ce({"email": email}))
172170

173-
mock_process.assert_called_once_with(email, TOKEN, True)
171+
mock_process.assert_called_once_with(email, TOKEN)
174172
mock_send_email.assert_called_once_with(STUB_EMAIL, TOKEN)
175173

176174

177-
def test_ar_reminder_dispatch_with_flag_off(app, session, mocker, mock_send_email):
178-
mocker.patch.object(flags, "is_on", return_value=False)
179-
mock_process = mocker.patch.object(ar_reminder_notification, "process", return_value=STUB_EMAIL)
180-
email = {"type": "annualReport", "option": "reminder"}
181-
182-
worker.process_email(_ce({"email": email}))
183-
184-
mock_process.assert_called_once_with(email, TOKEN, False)
185-
186-
187175
def test_agm_location_change_completed_dispatches(app, session, mocker, mock_send_email):
188176
mock_process = mocker.patch.object(agm_location_change_notification, "process", return_value=STUB_EMAIL)
189177
email = {"type": "agmLocationChange", "option": COMPLETED}

0 commit comments

Comments
 (0)